Merge pull request #60726 from nextcloud/backport/60654/stable34
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Integration sqlite / changes (push) Waiting to run
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, --tags ~@large files_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, capabilities_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, collaboration_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, comments_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, dav_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, federation_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, file_conversions) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, files_reminders) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, filesdrop_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, guests_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, ldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, openldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, openldap_numerical_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, remoteapi_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, routing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, setup_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, sharees_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, sharing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, theming_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable34, main, 8.4, stable34, videoverification_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite-summary (push) Blocked by required conditions
Psalm static code analysis / changes (push) Waiting to run
Psalm static code analysis / static-code-analysis (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-security (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-ocp (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-ncu (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-strict (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-summary (push) Blocked by required conditions

[stable34] fix(config): add null coalescing fallback in getValueBool before strtolower
This commit is contained in:
John Molakvoæ 2026-05-27 14:36:41 +02:00 committed by GitHub
commit 3bb7b3db4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 11 deletions

View file

@ -3550,11 +3550,6 @@
<code><![CDATA[$CONFIG]]></code>
</UndefinedVariable>
</file>
<file src="lib/private/Config/UserConfig.php">
<RedundantCast>
<code><![CDATA[(string)$this->getTypedValue($userId, $app, $key, $default ? 'true' : 'false', $lazy, ValueType::BOOL)]]></code>
</RedundantCast>
</file>
<file src="lib/private/Console/Application.php">
<NoInterfaceProperties>
<code><![CDATA[$this->request->server]]></code>

View file

@ -437,7 +437,15 @@ class AppConfig implements IAppConfig {
*/
#[\Override]
public function getValueBool(string $app, string $key, bool $default = false, bool $lazy = false): bool {
$b = strtolower($this->getTypedValue($app, $key, $default ? 'true' : 'false', $lazy, self::VALUE_BOOL));
// The explicit (string) cast and ?? null guard defend against a PHP OPcache bug where
// values passed by reference across function boundaries can have their type corrupted
// (e.g. bool returned as int, or null). Affects PHP 8.x with OPcache enabled; fixed
// upstream in https://github.com/php/php-src/pull/21973. Keep until minimum PHP version
// is bumped. Psalm sees the declared return type (string) and flags these as redundant.
/** @psalm-suppress RedundantCondition, TypeDoesNotContainNull */
$value = $this->getTypedValue($app, $key, $default ? 'true' : 'false', $lazy, self::VALUE_BOOL) ?? ($default ? 'true' : 'false');
/** @psalm-suppress RedundantCast */
$b = strtolower((string)$value);
return in_array($b, ['1', 'true', 'yes', 'on']);
}

View file

@ -705,11 +705,15 @@ class UserConfig implements IUserConfig {
bool $default = false,
bool $lazy = false,
): bool {
// The explicit (string) cast guards against a PHP OPcache bug where values passed
// by reference across function boundaries can have their type corrupted (e.g. bool
// returned as int). Affects PHP 8.x with OPcache enabled; fixed upstream in
// https://github.com/php/php-src/pull/21973. Keep until minimum PHP version is bumped.
$b = strtolower((string)$this->getTypedValue($userId, $app, $key, $default ? 'true' : 'false', $lazy, ValueType::BOOL));
// The explicit (string) cast and ?? null guard defend against a PHP OPcache bug where
// values passed by reference across function boundaries can have their type corrupted
// (e.g. bool returned as int, or null). Affects PHP 8.x with OPcache enabled; fixed
// upstream in https://github.com/php/php-src/pull/21973. Keep until minimum PHP version
// is bumped. Psalm sees the declared return type (string) and flags these as redundant.
/** @psalm-suppress RedundantCondition, TypeDoesNotContainNull */
$value = $this->getTypedValue($userId, $app, $key, $default ? 'true' : 'false', $lazy, ValueType::BOOL) ?? ($default ? 'true' : 'false');
/** @psalm-suppress RedundantCast */
$b = strtolower((string)$value);
return in_array($b, ['1', 'true', 'yes', 'on']);
}