Ticket #5978 (closed defect: fixed)

Opened 4 months ago

Last modified 4 months ago

Plugin version checking not always detecting updated versions.

Reported by: cavemonkey50 Assigned to: mdawaffe
Priority: normal Milestone: 2.5
Component: Administration Version: 2.5
Severity: normal Keywords: plugin, update, notification has-patch commit
Cc: ron@cavemonkey50.com

Description

While testing a plugin of mine for 2.5 compatibility I ran into an issue with the plugin update notification. My latest version prior to updating was 2.02. After I performed some fixes I bumped the version to 2.1. Immediately after doing so the plugin page reported the following:

There is a new version of Google Analyticator available. Download version 2.02 here or upgrade automatically.

Obviously, I'm running a newer version then the latest, so I don't think this message should be displayed. I did some testing to see if I could get the message to go away. I changed the version to 2.10 to see if that would get the message to go away. No go. Then I set it to 2.03 and the message went away. So, the plugin update notification is not detecting that 2.1 is higher than 2.0x.

Attachments

5978.diff (399 bytes) - added by mdawaffe on 02/27/08 23:41:24.

Change History

02/24/08 03:33:55 changed by fitztrev

It looks like the current plugin version checking (lines 65 & 66) only looks to see if the local version differs from the stable version in SVN. It assumes that the SVN version is always the latest. I think that makes sense and is probably the desired behavior.

02/24/08 03:37:58 changed by cavemonkey50

It can't be checking just on that, as changing the version from 2.1 to 2.03 (.01 higher than stable) removed the message.

02/25/08 17:55:19 changed by lloydbudd

  • owner changed from anonymous to mdawaffe.

02/27/08 23:41:01 changed by mdawaffe

  • keywords changed from plugin, update, notification to plugin, update, notification has-patch commit.
  • status changed from new to assigned.
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.

02/27/08 23:41:24 changed by mdawaffe

  • attachment 5978.diff added.

02/27/08 23:43:22 changed by ryan

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [7076]) Fix plugin version compare. Props mdawaffe. fixes #5978