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']);
}