[wp-trac] Re: [WordPress Trac] #5978: Plugin version checking not
always detecting updated versions.
WordPress Trac
wp-trac at lists.automattic.com
Wed Feb 27 23:41:01 GMT 2008
#5978: Plugin version checking not always detecting updated versions.
-----------------------------------------------------------+----------------
Reporter: cavemonkey50 | Owner: mdawaffe
Type: defect | Status: assigned
Priority: normal | Milestone: 2.5
Component: Administration | Version: 2.5
Severity: normal | Resolution:
Keywords: plugin, update, notification has-patch commit |
-----------------------------------------------------------+----------------
Changes (by mdawaffe):
* keywords: plugin, update, notification => plugin, update, notification
has-patch commit
* status: new => assigned
Comment:
{{{
var_dump( version_compare( "2.02", "2.2", "=" ) ); // 2 is equal to 2
# bool(true)
var_dump( version_compare( "2.2", "2.1", ">" ) ); // 2 is bigger than 1
# bool(true)
var_dump( version_compare( "2.02", "2.1", ">" ) ); // 2 is still bigger
than 1
# bool(true)
var_dump( version_compare( "2.02", "2.03", ">" ) ); // 2 is smaller than 3
# bool(false)
var_dump( version_compare( "2.02", "2.10", ">" ) ); // 2 is smaller than
10
# bool(false)
}}}
The only inconsistency between the above {{{version_compare()}}} output
and the bug report is the comparison between 2.02 and 2.10. This is not
the fault of api.wordpress.org (which is doing the right thing), but is
the fault of WordPress core's {{{wp_update_plugins()}}}. The comparison
in lines 65-66 is not to see if your plugin is out of date, but checks to
see if the current version of the plugin is the same as the version it
checked last time.
The problem is that "2.1" == "2.10" (when comparing two numeric strings in
PHP, the strings are first converted to numbers and 2.1 == 2.1). Since
WordPress thought that the "old" version of your plugin (2.1) was the same
as the "new" version of your pluign (2.10), it didn't bother to check with
api.wordpress.org to see if "2.10" was out of date or not, and so stuck
with what it already knew: that "2.1" was out of date (1 < 2).
Attached fixes.
--
Ticket URL: <http://trac.wordpress.org/ticket/5978#comment:4>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list