-
-
Couldn't load subscription status.
- Fork 3.7k
[3.10] [PHP 8.1] Mysqli database driver escape function fix #36787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixes `Deprecated: mysqli_real_escape_string(): Passing null to parameter #2 ($string) of type string is deprecated in libraries/joomla/database/driver/mysqli.php on line 254`
|
I have tested this item ✅ successfully on a807845 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36787. |
|
@beat Does it need to be fixed in the other drivers, too? And for 4.x it needs to make a PR with the same fix here: https://github.com/joomla-framework/database . Will you do that, or shall I? |
|
Ah no, I see it's not necessary since already handled before. |
|
All my PHP 8.1 fixes should be checked if they need to also be done in other Joomla branches as well. Same also as you well asked and checked, if they should be done in other files as well. At this time, I'm just testing Joomla and CB on PHP 8.1 in all functionality, and fixing in parallel in CB, CB add-ons and Joomla 3.10 and 4.0 things I see (just looking around the fix itself if nearby functions need the same fix). And I guess that I will have a few more days of work to do so at least, way more than I never had to do in a previous PHP new version since PHP 4! PHP made this strange decision to deprecate null as string in ancient string functions, breaking many code that worked in 8.0. Actually, I think it's not a good decision, ancient string functions should be left alone, and a new string class, like in many OO languages be made native and implicit (e.g. "text".strlen()). Is there a PHP RFC or discussion for that ? is it too late to comment against this for removal in PHP 8.2 ? it will break unneededly a massive amount of PHP code, just because So, if you have time to check and fix if needed other branches and files, it would be awesome and then just comment in each fix that you checked it and result (as you did above for other functions), so that we all know. If not, I might do it at some time when I catched up other tasks as this takes way longer than planed. Thank you for your reviews and help in all cases 👍 |
|
I don't know if I have the time to check everything on other branches, but I can handle the database driver stuff. |
|
For the framework see joomla-framework/database#260 . |
[CMS PR 36787] Fix also the other db drivers
|
I have tested this item ✅ successfully on 2bfda40 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36787. |
|
I have tested this item ✅ successfully on 2bfda40 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36787. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36787. |
|
Hmm I dont like that we try to cast stuff to strings where the original input should have been an string in the first place. So I would like to understand where the issue is comming from, do we have a stack trace? But I guess we have to do it here to not break the int and float case right? |
@zero-24 I've worried especially about the int case, see the additional comment in the description of the PR here: joomla-framework/database#260 . |
|
Will merge this here as workaround for 3.10. But yes I agree with you that we should find a better solution upstream within J4 |
|
@zero-24 here the stack trace (saving a user in admin with CB): CB is calling the save() function without any parameters, so it's the defaults Didn't see a less B/C-risky way to fix it. |
|
Oh, just saw it got merged. All ok then! |

Pull Request for Issue # none.
Summary of Changes
Fixes
Deprecated: mysqli_real_escape_string(): Passing null to parameter #2 ($string) of type string is deprecated in libraries/joomla/database/driver/mysqli.php on line 254Testing Instructions
Source-code review should be enough here.
Just test that site continues to work.
I saw this error while saving a user in admin aera with CB.
Actual result BEFORE applying this Pull Request
Deprecated: mysqli_real_escape_string(): Passing null to parameter #2 ($string) of type string is deprecated in libraries/joomla/database/driver/mysqli.php on line 254Expected result AFTER applying this Pull Request
That warning is not displayed
Documentation Changes Required
None.