RTC bug PR-5.2-dev Pending

User tests: Successful: Unsuccessful:

avatar alikon
alikon
13 Feb 2025

Pull Request for Issue ##44872 .

Summary of Changes

fix PHP Deprecated: trim(): Passing null to parameter

Testing Instructions

Set Error Reporting to Maximum.
Edit a banner.
Type in a new category.
Select Save & Close button.
See PHP error log:

Actual result BEFORE applying this Pull Request

Deprecated

Expected result AFTER applying this Pull Request

no more Deprecated

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar alikon alikon - open - 13 Feb 2025
avatar alikon alikon - change - 13 Feb 2025
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 Feb 2025
Category Libraries
avatar QuyTon QuyTon - test_item - 15 Feb 2025 - Tested successfully
avatar QuyTon
QuyTon - comment - 15 Feb 2025

I have tested this item ✅ successfully on 0059c80


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44876.

avatar richard67
richard67 - comment - 15 Feb 2025

Hmm, I'm not sure if this PR is right. Currently without the PR, the trim is applied on the alias before the check if it is empty:

$this->alias = trim($this->alias);

if (empty($this->alias)) {
    $this->alias = $this->title;
}

So if someone enters spaces as alias in the form, that will not be used, and the title will be used.

Now with the PR you move trim to after the check, so if someone enters spaces as alias in the form, it will be used and not the title because the empty check for a string with spaces will return false:

if (empty($this->alias)) {
    $this->alias = $this->title;
}

$this->alias = trim($this->alias);

Maybe the following code would be better?

$this->alias = trim($this->alias ?? '');

if (empty($this->alias)) {
    $this->alias = $this->title;
}

I.e. leave order of processing like it is without this PR and use the null coalescing operator inside the trim call to not let it operate on a null value.

avatar joomdonation
joomdonation - comment - 16 Feb 2025

Agree with Richard. @alikon Could you please implement the change suggested by Richard?

avatar alikon alikon - change - 16 Feb 2025
Labels Added: PR-5.2-dev
avatar alikon
alikon - comment - 16 Feb 2025

done

avatar joomdonation joomdonation - test_item - 16 Feb 2025 - Tested successfully
avatar joomdonation
joomdonation - comment - 16 Feb 2025

I have tested this item ✅ successfully on 3ac3c7c


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44876.

avatar QuyTon QuyTon - alter_testresult - 16 Feb 2025 - Quy: Tested successfully
avatar QuyTon QuyTon - change - 16 Feb 2025
Status Pending Ready to Commit
avatar QuyTon
QuyTon - comment - 16 Feb 2025

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44876.

avatar QuyTon QuyTon - change - 20 Feb 2025
Labels Added: RTC bug
avatar pe7er pe7er - change - 20 Feb 2025
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2025-02-20 18:24:41
Closed_By pe7er
avatar pe7er pe7er - close - 20 Feb 2025
avatar pe7er pe7er - merge - 20 Feb 2025
avatar pe7er
pe7er - comment - 20 Feb 2025

Thanks @alikon !

Add a Comment

Login with GitHub to post a comment