Skip to content

Commit b4dbff6

Browse files
committed
fix(accounts): address review feedback — remove $throwOnData from testPropertyScope and fix @SInCE
- Remove the always-true $throwOnData parameter from testPropertyScope; the dead else-branches (setScope(LOCAL)) are dropped, all paths now throw directly - Fix @SInCE annotation on UNPUBLISHED_PROPERTIES to 34.0.0 AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3ed04e2 commit b4dbff6

2 files changed

Lines changed: 8 additions & 21 deletions

File tree

lib/private/Accounts/AccountManager.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ protected function testValueLengths(array $properties, bool $throwOnData = false
115115
}
116116
}
117117

118-
protected function testPropertyScope(IAccountProperty $property, array $allowedScopes, bool $throwOnData): void {
119-
if ($throwOnData && !in_array($property->getScope(), $allowedScopes, true)) {
118+
protected function testPropertyScope(IAccountProperty $property, array $allowedScopes): void {
119+
if (!in_array($property->getScope(), $allowedScopes, true)) {
120120
throw new InvalidArgumentException('scope');
121121
}
122122

@@ -125,36 +125,23 @@ protected function testPropertyScope(IAccountProperty $property, array $allowedS
125125
in_array($property->getName(), self::UNPUBLISHED_PROPERTIES, true)
126126
&& in_array($property->getScope(), [self::SCOPE_FEDERATED, self::SCOPE_PUBLISHED], true)
127127
) {
128-
if ($throwOnData) {
129-
throw new InvalidArgumentException('scope');
130-
} else {
131-
$property->setScope(self::SCOPE_LOCAL);
132-
}
128+
throw new InvalidArgumentException('scope');
133129
}
134130

135131
// PUBLISHED scope requires the lookup server upload to be enabled by the admin.
136132
if ($property->getScope() === self::SCOPE_PUBLISHED) {
137133
$lookupServerUploadEnabled = $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'no') === 'yes';
138134
if (!$lookupServerUploadEnabled) {
139-
if ($throwOnData) {
140-
throw new InvalidArgumentException('scope');
141-
} else {
142-
$property->setScope(self::SCOPE_LOCAL);
143-
}
135+
throw new InvalidArgumentException('scope');
144136
}
145137
}
146138

147139
if (
148140
$property->getScope() === self::SCOPE_PRIVATE
149141
&& in_array($property->getName(), [self::PROPERTY_DISPLAYNAME, self::PROPERTY_EMAIL])
150142
) {
151-
if ($throwOnData) {
152-
// v2-private is not available for these fields
153-
throw new InvalidArgumentException('scope');
154-
} else {
155-
// default to local
156-
$property->setScope(self::SCOPE_LOCAL);
157-
}
143+
// v2-private is not available for these fields
144+
throw new InvalidArgumentException('scope');
158145
} else {
159146
// migrate scope values to the new format
160147
// invalid scopes are mapped to a default value
@@ -901,7 +888,7 @@ public function updateAccount(IAccount $account): void {
901888
}
902889

903890
foreach ($account->getAllProperties() as $property) {
904-
$this->testPropertyScope($property, self::ALLOWED_SCOPES, true);
891+
$this->testPropertyScope($property, self::ALLOWED_SCOPES);
905892
}
906893

907894
$oldData = $this->getUser($account->getUser(), false);

lib/public/Accounts/IAccountManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ interface IAccountManager {
151151
* published to the global lookup server or shared via federation.
152152
* This matches the frontend's UNPUBLISHED_READABLE_PROPERTIES constant.
153153
*
154-
* @since 32.0.0
154+
* @since 34.0.0
155155
*/
156156
public const UNPUBLISHED_PROPERTIES = [
157157
self::PROPERTY_BIOGRAPHY,

0 commit comments

Comments
 (0)