No Code Attached Yet
avatar jschmi102
jschmi102
28 Jul 2021

If I click "check for updates" on extensions I'm seeing 7 php-notices:

PHP Notice: Trying to get property 'id' of non-object in C:\\myjoomla4\\libraries\\src\\Updater\\Adapter\\ExtensionAdapter.php on line 333, referer: http://localhost/myjoomla4/administrator/index.php?option=com_installer&view=update

Could it be that check on ExtensionAdapter.php line 331 is wrong? ( e.g. notice is gone if check is changed to
if (isset($this->latest->client) && !\strlen($this->latest->client))

Or what else is the problem?

avatar jschmi102 jschmi102 - open - 28 Jul 2021
avatar joomla-cms-bot joomla-cms-bot - change - 28 Jul 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 28 Jul 2021
avatar jschmi102
jschmi102 - comment - 28 Jul 2021

hi,
forgot to mention situation happens with Joomla 4.0 RC5

avatar richard67
richard67 - comment - 28 Jul 2021

The proposed change is not right in my opinion from reading the original code here https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Updater/Adapter/ExtensionAdapter.php#L331 . But I can’t dig deeper right now.

avatar jschmi102
jschmi102 - comment - 29 Jul 2021

hi,
what I've found (what I get) sofar is (in my case):

$this->latest = Joomla\CMS\Table\Update
$this->latest->client = 0
so calling "getClientInfo($this->latest->client, true)" will query client by name ("true") and no id will be returned for client name ="0"

Is my conclusion correct?
so if I change line 331 to
if (isset($this->latest->client) && !is_numeric($this->latest->client))
php notices are gone...

avatar joomdonation
joomdonation - comment - 29 Jul 2021

@jschmi102 In Joomla4, the client in update server definition needs to be client name (site/administrator) instead of client id like in the past. I don't know when the decision was made but that makes sense because the tag is client, not client_id like in the past

So you should check the update sites of the extensions use on your site, if there is any update server use ID (0, 1) for client, please contact them and tell them to change it to site/administrator to have it compatible with Joomla 4

(I need to change it in my extensions, too, I still use client ID at the moment :( )

Take a look at Akeeba backup update server for example https://cdn.akeeba.com/updates/pkgakeebacore.xml , you will see that they use site instead of <client>0</client)

For more information, we have deprecated using Client ID for client in Joomla 3 already, see https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Updater/Adapter/ExtensionAdapter.php#L356-L365

avatar jschmi102
jschmi102 - comment - 29 Jul 2021

hi,
thanks for your Info - I dd not know how strict this requirement has to be implemented in Joomla4 update server's xml..

Nevertheless i think the code in ExtensionAdapter.php has to be changed. E..g. check that client is not numeric.
(php code should be clean and should hot produce notices or warnings)

avatar joomdonation
joomdonation - comment - 29 Jul 2021

@jschmi102 Agree that the code should be updated. Maybe show a warning if ID (0/1) is used instead of name (site/administrator)

avatar jschmi102
jschmi102 - comment - 29 Jul 2021

How about this (like in joomla3):

  1. define namespace for logs: use Joomla\CMS\Log\Log;
  2. add/change code at line 331
	if (isset($this->latest->client) && strlen($this->latest->client))
			{
				if (!is_numeric($this->latest->client))
				  $this->latest->client_id = ApplicationHelper::getClientInfo($this->latest->client, true)->id;
			        else
				  Log::add('Using numeric values for <client> in the updater xml is deprecated. Use \'administrator\' or \'site\' instead.',
						Log::WARNING, 'deprecated');	

				unset($this->latest->client);
			} 
avatar joomdonation
joomdonation - comment - 29 Jul 2021

@jschmi102 No, the purpose of deprecated in J3 and removed it in J4 is to force developer to use correct value for client tag on update server

So if it still use numeric value, we should show a warning show that they know about it and update. That's how I think/understand how it should work.

avatar Quy
Quy - comment - 28 Aug 2021

Closing as duplicate of #29778 #35376. Thanks for reporting.

avatar Quy Quy - close - 28 Aug 2021
avatar Quy Quy - change - 28 Aug 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-08-28 14:37:09
Closed_By Quy
Labels Added: No Code Attached Yet
Removed: ?

Add a Comment

Login with GitHub to post a comment