? PHP 8.x bug PR-4.3-dev Pending

User tests: Successful: Unsuccessful:

avatar richard67
richard67
5 May 2023

Pull Request for Issue # .

Summary of Changes

When using PHP 8.1 or later and the params value of com_templates is empty in the #__extensions table in database, you get a bunch of PHP errors "Deprecated explode(): Passing null to parameter 2 ($string) of type string is deprecated" in the template manager in backend, and the template manager can not be used, at least that’s the case when error reporting is set to Maximum in global configuration.

The reason is that there are several calls like explode(',', $params->get('image_formats') in the template manager code.

The parameters for which that happens are all of the type "comma-separated list of allowed file name extensions".

This PR here fixes that by using the same default value for each of these parameters which we use for new installation for that parameters.

It's worth a discussion if we should have these default values because it should also be possible to define an empty value for such a list of allowed file name extensions, which currently is not the case due to the default values specified for the fields in the configuration XML. But that should be fixed with a different PR if that's desired.

Testing Instructions

It might need to set error reporting to maximum in global configuration to get the issue.

  1. On a 4.3.1 or a current 4.3.2-dev, set the params value to an empty JSON in database, e.g. with phpMyAdmin:
UPDATE `#__extensions` SET `params` = '{}' WHERE `name` = 'com_templates';

You can also test with an empty string:

UPDATE `#__extensions` SET `params` = '' WHERE `name` = 'com_templates';
  1. Go to the template manager.
    Result: See section "Actual result BEFORE applying this Pull Request" below.

  2. Apply the patch and go again to the template manager or reload the page if still there.
    Result: See section "Expected result AFTER applying this Pull Request" below.

  3. Code review: Verify that the default values used in this PR here are the same as in the configuration XML https://github.com/joomla/joomla-cms/blob/4.3-dev/administrator/components/com_templates/config.xml and the installation SQL https://github.com/joomla/joomla-cms/blob/4.3-dev/installation/sql/mysql/base.sql#L174 .

Actual result BEFORE applying this Pull Request

A bunch of PHP errors "Deprecated explode(): Passing null to parameter 2 ($string) of type string is deprecated" in the template manager.

The template manager can not be used, and some quickicon checks in the system panel fail because the overrides check fails.

Expected result AFTER applying this Pull Request

No PHP errors "Deprecated explode(): Passing null to parameter 2 ($string) of type string is deprecated" in the template manager.

The template manager and the quickicon checks in the system panel are working.

Link to documentations

Please select:

  • No documentation changes for docs.joomla.org needed

  • No documentation changes for manual.joomla.org needed

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
3.00

avatar joomla-cms-bot joomla-cms-bot - change - 5 May 2023
Category Administration com_templates
avatar richard67 richard67 - open - 5 May 2023
avatar richard67 richard67 - change - 5 May 2023
Status New Pending
avatar richard67 richard67 - change - 5 May 2023
The description was changed
avatar richard67 richard67 - edited - 5 May 2023
avatar richard67 richard67 - change - 5 May 2023
The description was changed
avatar richard67 richard67 - edited - 5 May 2023
avatar richard67 richard67 - change - 5 May 2023
Title
[4.3] [WiP] Fix template manager errors on PHP 8.1 and later when having empty parameters
[4.3] Fix template manager errors on PHP 8.1 and later when having empty parameters
avatar richard67 richard67 - edited - 5 May 2023
avatar richard67 richard67 - change - 5 May 2023
The description was changed
avatar richard67 richard67 - edited - 5 May 2023
avatar richard67 richard67 - change - 5 May 2023
Labels Added: PHP 8.x bug PR-4.3-dev
avatar richard67 richard67 - change - 5 May 2023
The description was changed
avatar richard67 richard67 - edited - 5 May 2023
avatar richard67 richard67 - change - 5 May 2023
The description was changed
avatar richard67 richard67 - edited - 5 May 2023
avatar richard67 richard67 - change - 5 May 2023
The description was changed
avatar richard67 richard67 - edited - 5 May 2023
avatar richard67 richard67 - change - 6 May 2023
The description was changed
avatar richard67 richard67 - edited - 6 May 2023
avatar TheWhykiki TheWhykiki - test_item - 7 May 2023 - Tested successfully
avatar TheWhykiki
TheWhykiki - comment - 7 May 2023

I have tested this item successfully on 70e69da

After applying the Patch, error is fixed.


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

avatar degobbis degobbis - test_item - 7 May 2023 - Tested successfully
avatar degobbis
degobbis - comment - 7 May 2023

I have tested this item successfully on 70e69da

Works as expected


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

avatar richard67 richard67 - change - 7 May 2023
Status Pending Ready to Commit
avatar richard67
richard67 - comment - 7 May 2023

RTC


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

avatar obuisard obuisard - change - 7 May 2023
Labels Added: ?
avatar obuisard obuisard - close - 7 May 2023
avatar obuisard obuisard - merge - 7 May 2023
avatar obuisard obuisard - change - 7 May 2023
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2023-05-07 20:11:18
Closed_By obuisard
avatar obuisard
obuisard - comment - 7 May 2023

Thank you Richard @richard67 for the PR!

avatar richard67
richard67 - comment - 7 May 2023

Thanks all.

Add a Comment

Login with GitHub to post a comment