Skip to content

Commit 839c9fb

Browse files
authored
Merge pull request #60532 from nextcloud/backport/59646/stable32
[stable32] fix(UserConfig): cast getTypedValue() result to string in getValueBool()
2 parents 2a417a6 + 476da53 commit 839c9fb

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
@@ -3478,6 +3478,11 @@
34783478
<code><![CDATA[$CONFIG]]></code>
34793479
</UndefinedVariable>
34803480
</file>
3481+
<file src="lib/private/Config/UserConfig.php">
3482+
<RedundantCast>
3483+
<code><![CDATA[(string)$this->getTypedValue($userId, $app, $key, $default ? 'true' : 'false', $lazy, ValueType::BOOL)]]></code>
3484+
</RedundantCast>
3485+
</file>
34813486
<file src="lib/private/Console/Application.php">
34823487
<NoInterfaceProperties>
34833488
<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
@@ -682,7 +682,11 @@ public function getValueBool(
682682
bool $default = false,
683683
bool $lazy = false,
684684
): bool {
685-
$b = strtolower($this->getTypedValue($userId, $app, $key, $default ? 'true' : 'false', $lazy, ValueType::BOOL));
685+
// The explicit (string) cast guards against a PHP OPcache bug where values passed
686+
// by reference across function boundaries can have their type corrupted (e.g. bool
687+
// returned as int). Affects PHP 8.x with OPcache enabled; fixed upstream in
688+
// https://github.com/php/php-src/pull/21973. Keep until minimum PHP version is bumped.
689+
$b = strtolower((string)$this->getTypedValue($userId, $app, $key, $default ? 'true' : 'false', $lazy, ValueType::BOOL));
686690
return in_array($b, ['1', 'true', 'yes', 'on']);
687691
}
688692

0 commit comments

Comments
 (0)