Skip to content
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

[4.3] Fix template manager errors on PHP 8.1 and later when having empty parameters #40544

Conversation

richard67
Copy link
Member

@richard67 richard67 commented May 5, 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

Fix PHP error "Deprecated explode(): Passing null to parameter 2 ($string) of type string is deprecated" in template manager
@richard67 richard67 added PHP 8.x PHP 8.x deprecated issues bug labels May 5, 2023
@richard67 richard67 changed the 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 May 5, 2023
@richard67 richard67 marked this pull request as draft May 5, 2023 12:32
@richard67 richard67 marked this pull request as ready for review May 5, 2023 12:40
@richard67 richard67 marked this pull request as draft May 5, 2023 12:48
@richard67 richard67 marked this pull request as ready for review May 5, 2023 13:09
@TheWhykiki
Copy link

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.

@degobbis
Copy link
Contributor

degobbis commented May 7, 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.

@richard67
Copy link
Member Author

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label May 7, 2023
@obuisard obuisard added this to the Joomla! 4.3.2 milestone May 7, 2023
@obuisard obuisard merged commit 42328f2 into joomla:4.3-dev May 7, 2023
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label May 7, 2023
@obuisard
Copy link
Contributor

obuisard commented May 7, 2023

Thank you Richard @richard67 for the PR!

@richard67 richard67 deleted the 4.3-dev-fix-template-manager-for-empty-parameters branch May 7, 2023 20:11
@richard67
Copy link
Member Author

Thanks all.

@richard67 richard67 mentioned this pull request May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug PHP 8.x PHP 8.x deprecated issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants