-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[4.3] Fix issue Deprecated: trim(): Passing null on PHP 8.1 #38511
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
|
Think we need some more info here because the is_string call immediately above this line should fail before you've reached the trim |
|
I agree I would say we should not pass an empty string to that method in the first place. |
If I test in my local with var_dump Result Below |
|
Yes thats the reason I would not like to add that if else catch in every method that is handeling strings and hide the issues of passing null or empty strings to methods which should not be called with empty strings in the first place. |
Yeah! I fixed it in my component. Anyway, I think other extensions will face that when customer update PHP to 8.1 |
|
yes when the extension is ready for 8.1 that message does not come up right? When it is not ready for 8.1 yet the issue should be reported to the developer so it can be fixed right? Right now its not an fatal error by php yet anyway so "hiding" error messages "hides" the issue in the same way but allows the developer to find and fix it too. |
|
Maybe the |
|
As long as a library accepts null values is should work properly and not throw different errors on different PHP versions. So making a change in the library is fine. |
You are right! I updated code with Best Regards, |
|
This is now a BC break as an exception is thrown when the path is null, which wasn't before. |
May you me give a suggestion? Raise Thanks & Best Regards, |
|
I would go with something like: |
|
@laoneo Thank you for the suggestion! Because no one came up with a better idea. I have updated the code as per your suggestion. Please help me check it again! |
|
Looks correct now. Thanks! |
|
When you update the test instructions and expected/actual result the way, that the testers know what to do, then it is very likely that you change gets merged. You can put something like in testing instructions with some files in core:
Similar to what I did in #38535. |
|
@laoneo Thank you! I updated test instructions. Best Regards, |
|
I have tested this item ✅ successfully on 3ae8337 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38511. |
|
I have tested this item ✅ successfully on 7e61399 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38511. |
|
@alikon , can you please retest since a change was made? This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38511. |
|
no need to retest @jwaisner only branch merge |
|
I have tested this item ✅ successfully on daaf175 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38511. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38511. |
|
This has to go into 4.3 as it adds a deprecation. So waiting for the upmerge to make a rebase. |
|
PR for manual can be found here joomla/Manual#33. |
|
Thank you all for working on this issue! |
* Update new-deprecations.md * Moved to correct version --------- Co-authored-by: Harald <[email protected]>


Pull Request for Issue #38510 .
Summary of Changes
If $path is null, it will get '' value instead of run trim() function.
Testing Instructions
Actual result BEFORE applying this Pull Request
Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /{root}/libraries/src/Filesystem/Path.php on line 198Expected result AFTER applying this Pull Request
Warning disappear
Documentation Changes Required
No