From e7ee810c0b5e069d6f7663e1c823b3d28f0c82de Mon Sep 17 00:00:00 2001 From: There Is No TIme <37583483+thereisnotime@users.noreply.github.com> Date: Wed, 15 Apr 2026 13:40:08 +0300 Subject: [PATCH] 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 --- build/psalm-baseline.xml | 5 +++++ lib/private/Config/UserConfig.php | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index 9ab194db69d28..164f02da8458b 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -3460,6 +3460,11 @@ + + + getTypedValue($userId, $app, $key, $default ? 'true' : 'false', $lazy, ValueType::BOOL)]]> + + request->server]]> diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php index 5a5488e34187e..bf761f15cac4a 100644 --- a/lib/private/Config/UserConfig.php +++ b/lib/private/Config/UserConfig.php @@ -685,7 +685,11 @@ public function getValueBool( 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']); }