RTC PHP 8.x bug PR-4.4-dev Pending

User tests: Successful: Unsuccessful:

avatar Denitz
Denitz
3 May 2023

Summary of Changes

Prevent calling json_decode on NULL.

Possible behavior on language pack update:

Joomla\CMS\Installer\InstallerScript->getItemArray( $element = 'manifest_cache', $table = '#__extensions', $column = 'element', $identifier = 'German (Germany) Language Pack' )

Testing Instructions

PHP 8.1, set error reporting to maximum, update de-DE language.

Actual result BEFORE applying this Pull Request

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in \libraries\src\Installer\InstallerScript.php on line 304

Expected result AFTER applying this Pull Request

No warnings.

Link to documentations

Please select:

  • No documentation changes for docs.joomla.org needed
  • No documentation changes for manual.joomla.org needed
avatar joomla-cms-bot joomla-cms-bot - change - 3 May 2023
Category Libraries
avatar Denitz Denitz - open - 3 May 2023
avatar Denitz Denitz - change - 3 May 2023
Status New Pending
avatar richard67
richard67 - comment - 3 May 2023

@Denitz How dod you get that error? I'm asking because in the extension table, the manifest_cache column has a not null constraint, so the result of that query should never be null. See https://github.com/joomla/joomla-cms/blob/4.3-dev/installation/sql/mysql/base.sql#L137 .

avatar Denitz
Denitz - comment - 4 May 2023

@richard67 I updated core German language pack, see pkg_de-DE.xml:

<?xml version="1.0" encoding="UTF-8"?>
<extension type="package" method="upgrade">
	<name>German (Germany) Language Pack</name>
	<packagename>de-DE</packagename>
	<version>4.3.1.1</version>
...

The installer tries to find the element via Joomla\CMS\Installer\InstallerScript->getItemArray( $element = 'manifest_cache', $table = '#__extensions', $column = 'element', $identifier = 'German (Germany) Language Pack' ) which results in

SELECT * FROM `#__extensions` WHERE `element` = 'German (Germany) Language Pack'

See the code in \libraries\src\Installer\InstallerScript.php:144

// Abort if the extension being installed is not newer than the currently installed version
        if (!$this->allowDowngrades && strtolower($type) === 'update') {
            $manifest = $this->getItemArray('manifest_cache', '#__extensions', 'element', $this->extension);

            // Check whether we have an old release installed and skip this check when this here is the initial install.
            if (!isset($manifest['version'])) {
                return true;
            }

            $oldRelease = $manifest['version'];

            if (version_compare($this->release, $oldRelease, '<')) {
                Factory::getApplication()->enqueueMessage(Text::sprintf('JLIB_INSTALLER_INCORRECT_SEQUENCE', $oldRelease, $this->release), 'error');

                return false;
            }
        }

There are no extensions with this element, German language pack has element = "pkg_de-DE" and name = "German (Germany) Language Pack"

avatar richard67
richard67 - comment - 4 May 2023

@Denitz So this PR seems to be the wrong fix, and the right fix would be to change the parameters in the call to the getItemArray method so that the $column and $identifier fit together. It would work with $column = 'name' instead of 'element', or when using $column = 'element' the $identifier should be 'pkg_' . <the packagename from the XML>, e.g. 'pkg_de-DE'.

avatar Denitz Denitz - change - 5 May 2023
Labels Added: PR-4.3-dev
avatar Denitz
Denitz - comment - 5 May 2023

@richard67 Yes, agree, I've updated the call to getItemArray(). And still it's better to leave initial update of getItemArray() method because we can potentially load NULL on missed record.

avatar HLeithner
HLeithner - comment - 30 Sep 2023

This pull request has been automatically rebased to 4.4-dev.

avatar Denitz Denitz - change - 3 Oct 2023
Title
json_decode of NULL in InstallerScript::getItemArray()
[4.4] json_decode of NULL in InstallerScript::getItemArray()
avatar Denitz Denitz - edited - 3 Oct 2023
avatar laoneo laoneo - change - 16 Nov 2023
Labels Added: PHP 8.x bug PR-4.4-dev
Removed: PR-4.3-dev
avatar zwiastunsw zwiastunsw - test_item - 18 Nov 2023 - Tested successfully
avatar zwiastunsw
zwiastunsw - comment - 18 Nov 2023

I have tested this item ✅ successfully on 11517ee


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

avatar wojsmol wojsmol - test_item - 18 Nov 2023 - Tested successfully
avatar wojsmol
wojsmol - comment - 18 Nov 2023

I have tested this item ✅ successfully on 11517ee


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

avatar richard67 richard67 - change - 18 Nov 2023
Status Pending Ready to Commit
avatar richard67
richard67 - comment - 18 Nov 2023

RTC


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

avatar laoneo
laoneo - comment - 30 Nov 2023

Thanks for the fix...Currently checking with @tecpromotion about impacts for translation packs. Assigning it to the milestone 4.4.2.

avatar tecpromotion tecpromotion - test_item - 6 Dec 2023 - Tested successfully
avatar tecpromotion
tecpromotion - comment - 6 Dec 2023

I have tested this item ✅ successfully on 11517ee


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

avatar Quy Quy - change - 6 Dec 2023
Labels Added: RTC
avatar laoneo laoneo - change - 7 Dec 2023
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2023-12-07 15:05:07
Closed_By laoneo
avatar laoneo laoneo - close - 7 Dec 2023
avatar laoneo laoneo - merge - 7 Dec 2023
avatar laoneo
laoneo - comment - 7 Dec 2023

Thanks!

avatar alikon
alikon - comment - 7 Dec 2023

i guess related to #23219

Add a Comment

Login with GitHub to post a comment