No Code Attached Yet PHP 8.x bug
avatar conseilgouz
conseilgouz
7 Sep 2023

Steps to reproduce the issue

Load any extension that has an associated changelog file, for example https://extensions.joomla.org/extension/edition/editors/switch-editor-2/
Go to System/Extensions, search for switch editor in extensions list and click on underlined version number to display changelog content.

Expected result

changelog is displayed

Actual result

Error message : SyntaxError: Unexpected token '<', "
"... is not valid JSON
In errorlog,
[07-Sep-2023 13:06:09 UTC] PHP Deprecated: Creation of dynamic property Joomla\CMS\Changelog\Changelog::$changelogs is deprecated in D:\laragon6-------------\www\j5beta\libraries\src\Changelog\Changelog.php on line 275
[07-Sep-2023 13:06:09 UTC] PHP Deprecated: Creation of dynamic property Joomla\CMS\Changelog\Changelog::$changelog is deprecated in D:\laragon6-------------\www\j5beta\libraries\src\Changelog\Changelog.php on line 275
[07-Sep-2023 13:06:09 UTC] PHP Deprecated: Creation of dynamic property Joomla\CMS\Changelog\Changelog::$item is deprecated in D:\laragon6-------------\www\j5beta\libraries\src\Changelog\Changelog.php on line 275

System information (as much as possible)

PHP 8.2, Joomla 5.0 Beta 1

Additional comments

In Joomla 4, Changelog class extends CMSObject and, in Joomla 5, it's a class on its own.

avatar conseilgouz conseilgouz - open - 7 Sep 2023
avatar joomla-cms-bot joomla-cms-bot - change - 7 Sep 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 7 Sep 2023
avatar conseilgouz
conseilgouz - comment - 7 Sep 2023

I think adding #[\AllowDynamicProperties] in libraries/src/Changelog/Changelog.php should work

avatar HLeithner
HLeithner - comment - 7 Sep 2023

#[\AllowDynamicProperties] is not a longterm solution

avatar Fedik
Fedik - comment - 7 Sep 2023

I cannot reproduce it.
I have installed linked extension on Joomla 5 beta1, set error_reaporting to maximum,
But there no error when looking a change log for this extension.

avatar conseilgouz
conseilgouz - comment - 7 Sep 2023

@Fedik PHP 8.2 ?

avatar Fedik
Fedik - comment - 7 Sep 2023

ah, yeah, not 8.2 :)
Will try again later

avatar Fedik Fedik - change - 7 Sep 2023
Labels Added: PHP 8.x
avatar Fedik Fedik - labeled - 7 Sep 2023
avatar conseilgouz
conseilgouz - comment - 7 Sep 2023

If you set error reporting to none, you won't see deprecated lines and changelog display is OK.

Error reporting to maximum adds the deprecated lines at the beginning of $output in administrator\components\com_installer\src\Controller\ManagerController.php, line 176 causing then JSON Error.

avatar Fedik
Fedik - comment - 7 Sep 2023

The deprecation trigger comes from here

foreach (get_object_vars($this->latest) as $key => $val) {
$this->$key = $val;
}

This code looks strange.

It not 5.0 specific. But general.

There also an issue that the changelog does not display full list. which is already reaported #37774
I suspect these issue is connected.

Hovewer I have no idea what this startElement/endElement are doing here.

avatar Fedik Fedik - change - 7 Sep 2023
Title
[5.0 Beta1] Extensions ChangeLog display not working
[4.x][PHP 8.2] Extensions ChangeLog display not working due to deprecation warning
avatar Fedik Fedik - edited - 7 Sep 2023
avatar Fedik Fedik - change - 7 Sep 2023
Labels Added: bug
avatar Fedik Fedik - labeled - 7 Sep 2023
avatar conseilgouz
conseilgouz - comment - 7 Sep 2023

It not 5.0 specific. But general.

In Joomla 4, Changelog class extends CMSObject which contains #[\AllowDynamicProperties]

avatar Fedik Fedik - change - 7 Sep 2023
Title
[4.x][PHP 8.2] Extensions ChangeLog display not working due to deprecation warning
[5.x][PHP 8.2] Extensions ChangeLog display not working due to deprecation warning
avatar Fedik Fedik - edited - 7 Sep 2023
avatar conseilgouz
conseilgouz - comment - 7 Sep 2023

See #40999

avatar Fedik
Fedik - comment - 7 Sep 2023

You are right

avatar conseilgouz conseilgouz - change - 7 Sep 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-09-07 17:03:07
Closed_By conseilgouz
avatar conseilgouz conseilgouz - close - 7 Sep 2023
avatar conseilgouz
conseilgouz - comment - 7 Sep 2023

Add a Comment

Login with GitHub to post a comment