fix(UserConfig): cast getTypedValue() result to string in getValueBool()

PHP 8.4 made passing non-strings to strtolower() a fatal TypeError.
getTypedValue() can return a non-string under certain conditions, causing
the strtolower() call to throw. The (string) cast guards against this.

Signed-off-by: There Is No TIme <37583483+thereisnotime@users.noreply.github.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
There Is No TIme 2026-04-15 13:40:08 +03:00 committed by backportbot[bot]
parent 100f80492e
commit e7ee810c0b
2 changed files with 10 additions and 1 deletions

View file

@ -3460,6 +3460,11 @@
<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

@ -685,7 +685,11 @@ class UserConfig implements IUserConfig {
bool $default = false,
bool $lazy = false,
): bool {
$b = strtolower($this->getTypedValue($userId, $app, $key, $default ? 'true' : 'false', $lazy, ValueType::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));
return in_array($b, ['1', 'true', 'yes', 'on']);
}