User tests: Successful: Unsuccessful:
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:
<php_minimum>
defined, available to all users<php_minimum>
defined as PHP 5.4, PHP 5.3 users should not see this update<php_minimum>
defined as PHP 5.5, PHP 5.4 and 5.3 users should not see this updateOddly 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).
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><php_minimum></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><php_minimum></code> defined, available to all users</li> <li>5.4.0 - <code><php_minimum></code> defined as PHP 5.4, PHP 5.3 users should not see this update</li> <li>5.5.0 - <code><php_minimum></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&tracker_item_id=33159">http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&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><php_minimum></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><php_minimum></code> defined, available to all users</li> <li>5.4.0 - <code><php_minimum></code> defined as PHP 5.4, PHP 5.3 users should not see this update</li> <li>5.5.0 - <code><php_minimum></code> defined as PHP 5.5, PHP 5.4 and 5.3 users should not see this update</li> </ul> |
Labels |
Added:
?
?
|
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>
Ok I found the issue. On XML
client_id
should be 0 orextension_id
is never found because in extensionsclient_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.
Fixed the update stream, again. Have I mentioned lately how much I hate its inconsistent behavior? :-D
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.
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
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.
I can confirm issue commented by @vdespa . If you replace update_sites entry with:
https://raw.github.com/phproberto/phpmindemo/test/updates.xml
I'll take a look tomorrow then. Getting some of these lines in the right spot is not easy with our updater.
I've restructured things a little bit, this should hopefully address all concerns.
That looks like the correct message @infograf768
Will the message use the translated extension name if the translation exists?
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.
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.
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").
I can't replicate either of those items myself either locally or on my production server.
Where does this PR stand? Is there any other scenario that needs testing?
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.
@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
Thanks, that's corrected.
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)
.
Another test is always good.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-01-29 08:00:04 |
Merged to be able to freeze languages.
Can be tweaked in a new PR if needed
@mbabker You confused the files.
$this->currentUpdate->php_minimum->_data
but
$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:
Install https://raw.github.com/mbabker/phpmindemo/master/updates.xml
Update to the latest possible version (as detected by the updater). In my case it's 5.4. Do the update.
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
.
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.
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.
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.
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.
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).
I feel like I need a beer after reading through these classes LOL
I totally understand you :P
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.
I tried it but I cannot see new plugin versions available on update?