User tests: Successful: Unsuccessful:
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' )
PHP 8.1, set error reporting to maximum, update de-DE language.
Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in \libraries\src\Installer\InstallerScript.php on line 304
No warnings.
Please select:
Category | ⇒ | Libraries |
Status | New | ⇒ | Pending |
@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"
@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'
.
Labels |
Added:
PR-4.3-dev
|
@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.
This pull request has been automatically rebased to 4.4-dev.
Title |
|
Labels |
Added:
PHP 8.x
bug
PR-4.4-dev
Removed: PR-4.3-dev |
I have tested this item ✅ successfully on 11517ee
I have tested this item ✅ successfully on 11517ee
Status | Pending | ⇒ | Ready to Commit |
RTC
Thanks for the fix...Currently checking with @tecpromotion about impacts for translation packs. Assigning it to the milestone 4.4.2.
I have tested this item ✅ successfully on 11517ee
Labels |
Added:
RTC
|
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 |
Thanks!
@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 .