fix(UserConfig): cast getTypedValue() result to string in getValueBool()#59646
Conversation
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>
194792a to
6bfa36a
Compare
yes but the diff is clean |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
|
@artonge @CarlSchwan @nickvergessen @susnux this is still broken in 33.0.3 which shipped April 30. Every authenticated request returns 500. We have this patched manually in production right now as a workaround — without it the entire instance is down. This is not an edge case. Multiple users confirmed this in the linked issues weeks ago. The PR has been sitting open since April 15 with no merge, no backport, no release. That's three weeks of a known production-breaking regression going unaddressed. If you're not merging this, explain why. If there's a blocker, say so. Leaving it open with zero progress while people's production environments are on fire is not acceptable. |
It seems from the issue this is solved for people if they restart their containers so this more seems like a php caching issue which would make sense based on the wrong error code shown. |
|
@thereisnotime Got time to answer the question so this can be included in the May updates if we have the explanation? |
|
Still reproducible on 33.0.3 without the manual patch. A few notes on susnux's caching theory:
Happy to pull together reproduction steps or env details if that helps move this forward for the May update. |
Maybe you can share a backup of the affected rows. I only see code that writes If you could run the following 2 database queries and share the result with us (e.g. via email to SELECT * FROM oc_preferences WHERE appid = 'user_ldap' AND configkey = 'isDeleted' AND configvalue != '1';
-- Replace $USERID with the id of an affected user
SELECT * FROM oc_preferences WHERE appid = 'user_ldap' AND userid = '$USERID'; |
|
Just a heads up if you not subscribed to the issue: |
|
Ran both queries on a production instance running 33.0.3. Query 1 ( Query 2 (full row for an affected user): This confirms susnux's opcache diagnosis — the data is fine, the corruption happens at the PHP type level as the value passes through We are already running the patched Happy to provide further info if needed. |
|
In that case I would add an explicit comment in the line above referencing the PHP issue or PR and (if known) affected PHP versions, so it is not removed (by psalm or other automation), until we require a higher PHP version |
Summary
PHP 8.4 made passing non-strings to
strtolower()a fatalTypeError.UserConfig::getValueBool()callsstrtolower()directly on the return value ofgetTypedValue(), which can return a non-string under certain conditions. The(string)cast prevents the TypeError regardless of whatgetTypedValue()returns.Verified in production on NC 33.0.2 / PHP 8.4 — LDAP users were getting 500 errors on every authenticated request.
TODO
getTypedValue()returns a non-string (see discussion in [Bug]: NC 33 / PHP 8.4: TypeError in UserConfig::getValueBool() — strtolower() receives non-string from getTypedValue() #59629)Checklist
AI (if applicable)