Skip to content

Commit 889e32c

Browse files
Merge pull request #60333 from nextcloud/backport/59646/stable33
[stable33] fix(UserConfig): cast getTypedValue() result to string in getValueBool()
2 parents 8b0c6b3 + e7ee810 commit 889e32c

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

build/psalm-baseline.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3460,6 +3460,11 @@
34603460
<code><![CDATA[$CONFIG]]></code>
34613461
</UndefinedVariable>
34623462
</file>
3463+
<file src="lib/private/Config/UserConfig.php">
3464+
<RedundantCast>
3465+
<code><![CDATA[(string)$this->getTypedValue($userId, $app, $key, $default ? 'true' : 'false', $lazy, ValueType::BOOL)]]></code>
3466+
</RedundantCast>
3467+
</file>
34633468
<file src="lib/private/Console/Application.php">
34643469
<NoInterfaceProperties>
34653470
<code><![CDATA[$this->request->server]]></code>

lib/private/Config/UserConfig.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,11 @@ public function getValueBool(
685685
bool $default = false,
686686
bool $lazy = false,
687687
): bool {
688-
$b = strtolower($this->getTypedValue($userId, $app, $key, $default ? 'true' : 'false', $lazy, ValueType::BOOL));
688+
// The explicit (string) cast guards against a PHP OPcache bug where values passed
689+
// by reference across function boundaries can have their type corrupted (e.g. bool
690+
// returned as int). Affects PHP 8.x with OPcache enabled; fixed upstream in
691+
// https://github.com/php/php-src/pull/21973. Keep until minimum PHP version is bumped.
692+
$b = strtolower((string)$this->getTypedValue($userId, $app, $key, $default ? 'true' : 'false', $lazy, ValueType::BOOL));
689693
return in_array($b, ['1', 'true', 'yes', 'on']);
690694
}
691695

0 commit comments

Comments
 (0)