From e44f44af934a104a4e7ee4bcb17df1359e76b653 Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Thu, 6 Aug 2026 18:11:47 +0100 Subject: [PATCH 1/2] fix(restrictions): Apply the app config overwrite to the typed getters AppConfigOverwrite only overrode the deprecated getValue(). Server code has since moved to the typed getters, so the overwrite that lateSetupRestrictions() installs to force `shareapi_only_share_with_group_members` when "Hide other accounts from guests" is enabled was silently ignored by them. Most notably OC\Collaboration\Collaborators\UserPlugin reads the option with getValueString(), so the share recipient autocompletion offered guests every account of the instance instead of only the members of their own groups. OCA\Guests\Config::isSharingRestrictedToGroup() reads it with getValueBool() and was equally unaffected by the overwrite. Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- lib/AppConfigOverwrite.php | 18 +++++++++ tests/stub.php | 6 +++ tests/unit/AppConfigOverwriteTest.php | 55 +++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 tests/unit/AppConfigOverwriteTest.php diff --git a/lib/AppConfigOverwrite.php b/lib/AppConfigOverwrite.php index da6ab2f8..967bc65d 100644 --- a/lib/AppConfigOverwrite.php +++ b/lib/AppConfigOverwrite.php @@ -30,4 +30,22 @@ public function getValue($app, $key, $default = '') { return parent::getValue($app, $key, $default); } + + #[\Override] + public function getValueString(string $app, string $key, string $default = '', bool $lazy = false): string { + if (isset($this->overWrite[$app]) && isset($this->overWrite[$app][$key])) { + return $this->overWrite[$app][$key]; + } + + return parent::getValueString($app, $key, $default, $lazy); + } + + #[\Override] + public function getValueBool(string $app, string $key, bool $default = false, bool $lazy = false): bool { + if (isset($this->overWrite[$app]) && isset($this->overWrite[$app][$key])) { + return in_array(strtolower($this->overWrite[$app][$key]), ['1', 'true', 'yes', 'on'], true); + } + + return parent::getValueBool($app, $key, $default, $lazy); + } } diff --git a/tests/stub.php b/tests/stub.php index cbddd7d4..ca982ce1 100644 --- a/tests/stub.php +++ b/tests/stub.php @@ -133,6 +133,12 @@ public function __construct( */ public function getValue($app, $key, $default = '') { } + + public function getValueString(string $app, string $key, string $default = '', bool $lazy = false): string { + } + + public function getValueBool(string $app, string $key, bool $default = false, bool $lazy = false): bool { + } } } diff --git a/tests/unit/AppConfigOverwriteTest.php b/tests/unit/AppConfigOverwriteTest.php new file mode 100644 index 00000000..8f10c3a6 --- /dev/null +++ b/tests/unit/AppConfigOverwriteTest.php @@ -0,0 +1,55 @@ +appConfig = Server::get(AppConfigOverwrite::class); + $this->appConfig->setOverwrite(['core' => [self::KEY => 'yes']]); + } + + protected function tearDown(): void { + $this->appConfig->setOverwrite([]); + + parent::tearDown(); + } + + /** + * The server reads the overwritten values through several getters: + * IConfig::getAppValue() ends up in getValue(), the share recipient + * autocompletion uses getValueString() and OCA\Guests\Config uses + * getValueBool(). All of them have to see the overwrite. + */ + public function testOverwriteIsAppliedToAllGetters(): void { + $this->assertSame('yes', $this->appConfig->getValue('core', self::KEY, 'no')); + $this->assertSame('yes', $this->appConfig->getValueString('core', self::KEY, 'no')); + $this->assertTrue($this->appConfig->getValueBool('core', self::KEY)); + } + + public function testWithoutOverwriteTheStoredValueIsUsed(): void { + $this->appConfig->setOverwrite([]); + + $this->assertSame('no', $this->appConfig->getValue('core', self::KEY, 'no')); + $this->assertSame('no', $this->appConfig->getValueString('core', self::KEY, 'no')); + $this->assertFalse($this->appConfig->getValueBool('core', self::KEY)); + } +} From 4d53f9d27e22f21d49fb8cfc7e5ddddb04140ee4 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Fri, 21 Aug 2026 10:43:16 +0200 Subject: [PATCH 2/2] fix: Add more missing override methods Signed-off-by: Carl Schwan --- lib/AppConfigOverwrite.php | 28 ++++++++++++++++++++++++++++ tests/stub.php | 9 +++++++++ 2 files changed, 37 insertions(+) diff --git a/lib/AppConfigOverwrite.php b/lib/AppConfigOverwrite.php index 967bc65d..1bb2ceab 100644 --- a/lib/AppConfigOverwrite.php +++ b/lib/AppConfigOverwrite.php @@ -48,4 +48,32 @@ public function getValueBool(string $app, string $key, bool $default = false, bo return parent::getValueBool($app, $key, $default, $lazy); } + + #[\Override] + public function getValueInt(string $app, string $key, int $default = 0, bool $lazy = false): int { + if (isset($this->overWrite[$app]) && isset($this->overWrite[$app][$key])) { + return (int)$this->overWrite[$app][$key]; + } + + return parent::getValueInt($app, $key, $default, $lazy); + } + + #[\Override] + public function getValueFloat(string $app, string $key, float $default = 0, bool $lazy = false): float { + if (isset($this->overWrite[$app]) && isset($this->overWrite[$app][$key])) { + return (float)$this->overWrite[$app][$key]; + } + + return parent::getValueFloat($app, $key, $default, $lazy); + } + + #[\Override] + public function getValueArray(string $app, string $key, array $default = [], bool $lazy = false): array { + if (isset($this->overWrite[$app]) && isset($this->overWrite[$app][$key])) { + $value = json_decode($this->overWrite[$app][$key], true); + return is_array($value) ? $value : $default; + } + + return parent::getValueArray($app, $key, $default, $lazy); + } } diff --git a/tests/stub.php b/tests/stub.php index ca982ce1..310dd4c7 100644 --- a/tests/stub.php +++ b/tests/stub.php @@ -139,6 +139,15 @@ public function getValueString(string $app, string $key, string $default = '', b public function getValueBool(string $app, string $key, bool $default = false, bool $lazy = false): bool { } + + public function getValueInt(string $app, string $key, int $default = 0, bool $lazy = false): int { + } + + public function getValueFloat(string $app, string $key, float $default = 0, bool $lazy = false): float { + } + + public function getValueArray(string $app, string $key, array $default = [], bool $lazy = false): array { + } } }