Skip to content

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

Open
thereisnotime wants to merge 1 commit intonextcloud:masterfrom
thereisnotime:fix/userconfig-getvaluebool-strtolower-type-error-v2
Open

fix(UserConfig): cast getTypedValue() result to string in getValueBool()#59646
thereisnotime wants to merge 1 commit intonextcloud:masterfrom
thereisnotime:fix/userconfig-getvaluebool-strtolower-type-error-v2

Conversation

@thereisnotime
Copy link
Copy Markdown

@thereisnotime thereisnotime commented Apr 15, 2026

Summary

PHP 8.4 made passing non-strings to strtolower() a fatal TypeError. UserConfig::getValueBool() calls strtolower() directly on the return value of getTypedValue(), which can return a non-string under certain conditions. The (string) cast prevents the TypeError regardless of what getTypedValue() returns.

Verified in production on NC 33.0.2 / PHP 8.4 — LDAP users were getting 500 errors on every authenticated request.

TODO

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@thereisnotime thereisnotime requested a review from a team as a code owner April 15, 2026 10:41
@thereisnotime thereisnotime requested review from Altahrim, ArtificialOwl, nfebe and sorbaugh and removed request for a team April 15, 2026 10:41
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.

Fixes nextcloud#59629

Signed-off-by: There Is No TIme <37583483+thereisnotime@users.noreply.github.com>
@thereisnotime thereisnotime force-pushed the fix/userconfig-getvaluebool-strtolower-type-error-v2 branch from 194792a to 6bfa36a Compare April 15, 2026 10:42
Copy link
Copy Markdown
Collaborator

@artonge artonge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it the same as #59630 ?

@CarlSchwan
Copy link
Copy Markdown
Member

Isn't it the same as #59630 ?

yes but the diff is clean

bool $lazy = false,
): bool {
$b = strtolower($this->getTypedValue($userId, $app, $key, $default ? 'true' : 'false', $lazy, ValueType::BOOL));
$b = strtolower((string)$this->getTypedValue($userId, $app, $key, $default ? 'true' : 'false', $lazy, ValueType::BOOL));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get how getTypedValue can return something which is not a string

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty string on oracle is null?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See stack trace in linked issue. It is a string. Php would throw if it is not a string due to strict types.

I suspect a faulty PHP build being used on that machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: NC 33 / PHP 8.4: TypeError in UserConfig::getValueBool() — strtolower() receives non-string from getTypedValue()

5 participants