? Success

User tests: Successful: Unsuccessful:

avatar mbabker
mbabker
16 Jan 2014

Tracker: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33159

The CMS lacks a mechanism for checking PHP version support on updates. This allows extensions to erroneously present updates to users who are in unsupported server environments, such as the case with 2.5 to 3.x updates presently.

This patch introduces a <php_minimum> tag which should indicate the minimum supported PHP version of an extension. This is demonstrated with a sample update stream at https://github.com/mbabker/phpmindemo/blob/master/updates.xml#L49-L64.

To test this patch, please install the sample plugin from https://github.com/mbabker/phpmindemo/releases/download/1.0.0/plg_system_phpmindemo_1.0.0.zip. Once installed, go to the Extension Manager's Update view and search for updates. Depending on your system, you'll see one of the following versions:

  • 1.1.1 - No <php_minimum> defined, available to all users
  • 5.4.0 - <php_minimum> defined as PHP 5.4, PHP 5.3 users should not see this update
  • 5.5.0 - <php_minimum> defined as PHP 5.5, PHP 5.4 and 5.3 users should not see this update
avatar mbabker mbabker - open - 16 Jan 2014
avatar phproberto
phproberto - comment - 17 Jan 2014

I tried it but I cannot see new plugin versions available on update?

$ php --version
PHP 5.4.9-4ubuntu2.4 (cli) (built: Dec 12 2013 04:26:30) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
avatar mbabker
mbabker - comment - 17 Jan 2014

Oddly enough, I have issues with my local setup where the extension ID never gets set to extensions in the #__updates table. So, I'd suggest checking there to see if the data actually gets written (that's how I had to test this).

avatar mbabker mbabker - change - 17 Jan 2014
The description was changed
Description <p>The CMS lacks a mechanism for checking PHP version support on updates. This allows extensions to erroneously present updates to users who are in unsupported server environments, such as the case with 2.5 to 3.x updates presently.</p> <p>This patch introduces a <code>&lt;php_minimum&gt;</code> tag which should indicate the minimum supported PHP version of an extension. This is demonstrated with a sample update stream at <a href="https://github.com/mbabker/phpmindemo/blob/master/updates.xml#L49-L64">https://github.com/mbabker/phpmindemo/blob/master/updates.xml#L49-L64</a>.</p> <p>To test this patch, please install the sample plugin from <a href="https://github.com/mbabker/phpmindemo/releases/download/1.0.0/plg_system_phpmindemo_1.0.0.zip">https://github.com/mbabker/phpmindemo/releases/download/1.0.0/plg_system_phpmindemo_1.0.0.zip</a>. Once installed, go to the Extension Manager's Update view and search for updates. Depending on your system, you'll see one of the following versions:</p> <ul> <li>1.1.1 - No <code>&lt;php_minimum&gt;</code> defined, available to all users</li> <li>5.4.0 - <code>&lt;php_minimum&gt;</code> defined as PHP 5.4, PHP 5.3 users should not see this update</li> <li>5.5.0 - <code>&lt;php_minimum&gt;</code> defined as PHP 5.5, PHP 5.4 and 5.3 users should not see this update</li> </ul> <p>Tracker: <a href="http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&amp;tracker_item_id=33159">http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&amp;tracker_item_id=33159</a></p> <p>The CMS lacks a mechanism for checking PHP version support on updates. This allows extensions to erroneously present updates to users who are in unsupported server environments, such as the case with 2.5 to 3.x updates presently.</p> <p>This patch introduces a <code>&lt;php_minimum&gt;</code> tag which should indicate the minimum supported PHP version of an extension. This is demonstrated with a sample update stream at <a href="https://github.com/mbabker/phpmindemo/blob/master/updates.xml#L49-L64">https://github.com/mbabker/phpmindemo/blob/master/updates.xml#L49-L64</a>.</p> <p>To test this patch, please install the sample plugin from <a href="https://github.com/mbabker/phpmindemo/releases/download/1.0.0/plg_system_phpmindemo_1.0.0.zip">https://github.com/mbabker/phpmindemo/releases/download/1.0.0/plg_system_phpmindemo_1.0.0.zip</a>. Once installed, go to the Extension Manager's Update view and search for updates. Depending on your system, you'll see one of the following versions:</p> <ul> <li>1.1.1 - No <code>&lt;php_minimum&gt;</code> defined, available to all users</li> <li>5.4.0 - <code>&lt;php_minimum&gt;</code> defined as PHP 5.4, PHP 5.3 users should not see this update</li> <li>5.5.0 - <code>&lt;php_minimum&gt;</code> defined as PHP 5.5, PHP 5.4 and 5.3 users should not see this update</li> </ul>
Labels Added: ? ?
avatar phproberto
phproberto - comment - 17 Jan 2014

Ok I found the issue. On XML client_id should be 0 or extension_id is never found because in extensions client_id is 0:

<client_id>0</client_id>
avatar Bakual
Bakual - comment - 17 Jan 2014

Ok I found the issue. On XML client_id should be 0 or extension_id is never found because in extensions client_id is 0:

<client_id>0</client_id>

Actually, it should be <client>site</client>. Imho we don't use the <client_id> tag anymore. Not sure when it changed but I think it was before 2.5.

Update:
Found in http://docs.joomla.org/Deploying_an_Update_Server

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

avatar mbabker
mbabker - comment - 17 Jan 2014

Fixed the update stream, again. Have I mentioned lately how much I hate its inconsistent behavior? :-D

avatar Bakual
Bakual - comment - 17 Jan 2014

Works great now. I get the message

For the extension plg_system_phpmindemo version 5.5.0 is available, but it requires at least PHP version 5.5 while your system only has 5.4.20

and shows me the version 5.4.0 of the plugin.

avatar vdespa
vdespa - comment - 19 Jan 2014

I've tested with your extension and also with a plugin of mine.

The issue I've detected is that if you only have one update in the update manifest file (you have 4-5) OR the first one does not meet the php_minimum requirement, the $this->latest property does not get set the first time. So here

https://github.com/mbabker/joomla-cms/blob/16ba6f6d04b77eba5f5c875254677c64e4d165c8/libraries/joomla/updater/adapters/extension.php#L141

you forget to unset($this->currentUpdate->php_minimum); which will (1) later throw an SQL exception, as the column php_minimum does not exist.

(2) Moreover, the warning with the PHP version not meeting the requirement will not show. Test with your extension, leaving as update just the 5.5 (https://github.com/mbabker/phpmindemo/blob/master/updates.xml#L49-L64).

Let me know if this makes sense.

avatar phproberto
phproberto - comment - 21 Jan 2014

I can confirm issue commented by @vdespa . If you replace update_sites entry with:
https://raw.github.com/phproberto/phpmindemo/test/updates.xml

You get an SQL error:
update_error

avatar mbabker
mbabker - comment - 21 Jan 2014

I'll take a look tomorrow then. Getting some of these lines in the right spot is not easy with our updater.

avatar mbabker
mbabker - comment - 22 Jan 2014

I've restructured things a little bit, this should hopefully address all concerns.

avatar infograf768
infograf768 - comment - 22 Jan 2014

This is what I get now
minphp1

avatar dongilbert
dongilbert - comment - 22 Jan 2014

That looks like the correct message @infograf768

avatar betweenbrain
betweenbrain - comment - 22 Jan 2014

@tests good. I get similar results.
download

avatar dongilbert
dongilbert - comment - 22 Jan 2014

Will the message use the translated extension name if the translation exists?

avatar mbabker
mbabker - comment - 22 Jan 2014

No. $this->currentUpdate->name is generating the name, which equates to the <name> element of an <update> entry. The name isn't tied to an identifier in our database, so it won't always be possible to translate it. FWIW, the same untranslated string is displayed in the Name column of the update view.

avatar vdespa
vdespa - comment - 22 Jan 2014

Thanks for the updates.

The detection part seems to be working better now, the only thing I've noticed is a double identical message for your extension.

image

The issue that I have now is that when performing the actual update, an error message appears. (namely COM_INSTALLER_INVALID_EXTENSION_UPDATE="Invalid extension update").

image

avatar mbabker
mbabker - comment - 23 Jan 2014

I can't replicate either of those items myself either locally or on my production server.

avatar vdespa
vdespa - comment - 25 Jan 2014

@mbabker I will try to test this on another system next week and I will get back to you with a decent way replicate this.

avatar betweenbrain
betweenbrain - comment - 28 Jan 2014

Where does this PR stand? Is there any other scenario that needs testing?

avatar vdespa
vdespa - comment - 28 Jan 2014

I added here another test scenario.

https://drive.google.com/folderview?id=0B6baUOIJrCuec3RHNzNpQ3JQMkk&usp=sharing

You find there the zips and the manifest files for the updates. Note: I am using http://joomla-staging for testing. Update #__update_sites with a valid URL.

Install version 1.0.0. (without patch 2802).

Autoupdate to 1.0.1 (without patch 2802).

Apply patch 2802.

Try to update to 1.0.2. Invalid extension update appears.

Now, I don't understand if there is an issue with my code but installing an updating the component without php_minimum works flawlessly. With php_minimum, it works very well.

avatar vdespa
vdespa - comment - 28 Jan 2014

@mbabker Check this line of code: https://github.com/mbabker/joomla-cms/blob/phpUpdateLib/libraries/joomla/updater/update.php#L295

Just inside version_compare(), $this->currentUpdate->php_minimum is an object of type stdClass, not a String. It should be:

$this->currentUpdate->php_minimum->_data

avatar mbabker
mbabker - comment - 29 Jan 2014

Thanks, that's corrected.

avatar betweenbrain
betweenbrain - comment - 29 Jan 2014

Does this need retesting?

Best,

Matt Thomas
@betweenbrain
http://matt-thomas.me/
http://betweenbrain.com/
https://github.com/betweenbrain

Sent from mobile. Please pardon any typos or brevity.
On Jan 28, 2014 7:04 PM, "Michael Babker" notifications@github.com wrote:

Thanks, that's corrected.


Reply to this email directly or view it on GitHub#2802 (comment)
.

avatar mbabker
mbabker - comment - 29 Jan 2014

Another test is always good.

avatar infograf768 infograf768 - reference | - 29 Jan 14
avatar infograf768 infograf768 - merge - 29 Jan 2014
avatar infograf768 infograf768 - close - 29 Jan 2014
avatar infograf768 infograf768 - change - 29 Jan 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-01-29 08:00:04
avatar infograf768 infograf768 - close - 29 Jan 2014
avatar infograf768
infograf768 - comment - 29 Jan 2014

Merged to be able to freeze languages.
Can be tweaked in a new PR if needed

avatar vdespa
vdespa - comment - 29 Jan 2014

@mbabker You confused the files.

  • /libraries/joomla/updater/update.php#L295 uses $this->currentUpdate->php_minimum->_data

but

  • /libraries/joomla/updater/adapters/extension.php#L107 uses $this->currentUpdate->php_minimum

If anybody wants to do some testing, here is the plugin I am using for testing:

http://www.vdespa.de/_jbs/33159/zip/1.0.0.zip

After this, there is still another issue, present in your plugin in mine as well.

Do the following:

  1. Install https://raw.github.com/mbabker/phpmindemo/master/updates.xml

  2. Update to the latest possible version (as detected by the updater). In my case it's 5.4. Do the update.

  3. You extension will still be at version 1.0.0 (in your case) because the update will pick the first entry from the update manifest. I know that the plg_system_phpmindemo_5.4.0.zip manifest has not the right version, but it still won't be the archive that is downloaded.

This happens because in version_compare /libraries/joomla/updater/update.php#L308, both terms of the comparison are objects. You need to use $this->currentUpdate->version->_data and $this->latest->version->_data.

avatar infograf768 infograf768 - reference | - 29 Jan 14
avatar vdespa
vdespa - comment - 3 Feb 2014

I would like to draw attention on this item.

There is the risk that this will get into the 3.2.2 release without being properly fixed / tested. It may cause problems updating existing extensions and also the advertised new feature will not provide any benefits.

This has not been properly passed the testing requirements (from my point of view) and has anyway been merged.

avatar mbabker
mbabker - comment - 3 Feb 2014

I can't reproduce any of the issues you're reporting either on my local testing environment or my live site with this patched into it. I've tried with my code (knowing the packages got screwed up in building) and your's; consistent results all around.

avatar mbabker mbabker - head_ref_deleted - 3 Feb 2014
avatar mbabker mbabker - reference | - 3 Feb 14
avatar mbabker
mbabker - comment - 3 Feb 2014

OK, finally figured it out. It isn't the update fetching that was failing but rather the install that was (which wasn't where I was looking). A lot of code needs to be refactored in here, but that's a pull request for another day. I've fixed it in the staging branch now.

avatar vdespa
vdespa - comment - 3 Feb 2014

Thanks for your quick response. I've tested again on another system (which is not by no means under my control - thanks Joomla-Bugs.de - http://www.joomla-bugs.de/demo.html). The issue persists.

Install my extension using the link provided (http://www.vdespa.de/_jbs/33159/zip/1.0.0.zip). First update succeedes (to 1.0.1). Try updating to version 1.0.2. It will fail.

avatar vdespa
vdespa - comment - 3 Feb 2014

Yes. The fetch of new updates and the install itself are two separate processes, which share lots of almost identical code (especially the parsing of the XML).

avatar mbabker
mbabker - comment - 3 Feb 2014

I feel like I need a beer after reading through these classes LOL

avatar vdespa
vdespa - comment - 3 Feb 2014

I totally understand you :P

avatar vdespa
vdespa - comment - 4 Feb 2014

Thanks for your fixes. I've retested and I have not found any other issues.

Before refactoring it would be highly recommended to design some unit test with possible update scenarios.

The updater is such a complex piece of code that it makes 'manual' testing very hard.

avatar Bakual Bakual - reference | - 12 May 14
avatar Bakual Bakual - reference | - 12 May 14
avatar Bakual Bakual - reference | - 12 May 14

Add a Comment

Login with GitHub to post a comment