No Code Attached Yet
avatar PhilETaylor
PhilETaylor
25 Aug 2021

Steps to reproduce the issue

Install this fake "paid download" extension Null file. Thanks @nikosdion for the file.

In Joomla 4 admin check for updates for this extensions on /administrator/index.php?option=com_installer&view=update page

Expected result

No PHP warnings are logged in the php log

REGARDLESS that this is not a real plugin...
REGARDLESS that this php warning is never shown to the screen ...
REGARDLESS that the update to this non-real plugin is not valid...
... Joomla should still not be attempting to read properties on null objects.

Actual result

In logs, could not get it to show on the screen even with debug on and error reporting max

 PHP Warning:  Attempt to read property "id" on null in /application/libraries/src/Updater/Adapter/ExtensionAdapter.php on line 333

$this->latest->client_id = ApplicationHelper::getClientInfo($this->latest->client, true)->id;

Screenshot 2021-08-25 at 22 33 37

System information (as much as possible)

4.0-dev

Additional comments

avatar PhilETaylor PhilETaylor - open - 25 Aug 2021
avatar joomla-cms-bot joomla-cms-bot - change - 25 Aug 2021
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 25 Aug 2021
avatar nikosdion
nikosdion - comment - 26 Aug 2021

As far as I can tell the problem is that Joomla is trying to get the client information by name but the update XML needs to define it by numeric ID (at least if we want the update XML file to also work on Joomla 3).

Please also note that the official documentation also says the same:

client – Required for modules and templates as of 3.2.0. – The client ID of the extension, which can be found by looking inside the #_extensions table. To date, use 0 for "site" and 1 for "administrator". Warning! Plugins and front-end modules are automatically installed with a client of 0 (site), but you will need to specify the client in an update or it will default to 1 (administrator) and then found update would not be shown because it would not match any extension. Components are automatically installed with a client of 1, which is currently the default.

Warning: The tag name is for Joomla! 2.5 and <client_id> for 1.6 and 1.7. If you use <client_id> (rather than ) on a 2.5 site, it will be ignored.

So, this is a case of Joomla not following its own documentation.

The correct fix is to check if $this->latest->client is numeric (AS IT SHOULD, PER THE DOCUMENTATION AND BECAUSE THIS IS HOW JOOMLA 3 WORKS!). If it's numeric, assign $this->latest->client_id = $this->latest->client. Otherwise go through Application helper.

To make it clear, the offending line should read:

$this->latest->client_id = is_numeric($this->latest->client) ? $this->latest->client : ApplicationHelper::getClientInfo($this->latest->client, true)->id; 

DO NOT change the documentation to make a string again. This will break updates for extensions which are compatible with both Joomla 3 and 4. We already had this b/c break BS going from Joomla 1.7 to 2.5. We threw Joomla 1.6 and 1.7 users under the bus back then which was acceptable because 1.6 and 1.7 were STS and immediately EOL'ed when 2.5 came out. This is not an option with Joomla 3. If we have to choose between supporting our Joomla 3 or our Joomla 4 clients we will all support Joomla 3 clients and tell them to NOT upgrade to Joomla 4 before August 17th, 2023.

avatar richard67
richard67 - comment - 14 Oct 2021

Recently reported again for other 3rd party extensions: #35815 .

avatar nikosdion
nikosdion - comment - 14 Oct 2021

If the project is actually interested in solving this I can make the one line PR for the change I have already commented. I need either @wilsonge or @HLeithner to give me to go–ahead. Until this is fixed this problem will keep happening. It's not a matter of “whether”, it's just a matter of “how often”.

avatar richard67
richard67 - comment - 14 Oct 2021

@nikosdion Will it also solve #29778 ? Or is that a different thing?

avatar nikosdion
nikosdion - comment - 14 Oct 2021

@richard67 Correct. It is the exact same issue.

avatar HLeithner
HLeithner - comment - 14 Oct 2021

@nikosdion yes please go ahead and support the numeric id, can you may add a note to deprecated this for 5.0? or at least a "reconsider" comment?

avatar nikosdion
nikosdion - comment - 14 Oct 2021

Okey-dokey! On it.

avatar nikosdion
nikosdion - comment - 14 Oct 2021

Pull request created: #35822

avatar richard67
richard67 - comment - 14 Oct 2021

@nikosdion Could you mention the other issue #29778 too in the description of your PR? Thanks in advance.

avatar richard67 richard67 - close - 14 Oct 2021
avatar richard67
richard67 - comment - 14 Oct 2021

Closing as having a pull request. Please test #35822 . Thanks in advance.

avatar richard67 richard67 - change - 14 Oct 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-10-14 11:29:17
Closed_By richard67
avatar nikosdion
nikosdion - comment - 14 Oct 2021

Done!

Add a Comment

Login with GitHub to post a comment