WordPress.org

Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#5978 closed defect (bug) (fixed)

Plugin version checking not always detecting updated versions.

Reported by: cavemonkey50 Owned by: mdawaffe
Milestone: 2.5 Priority: normal
Severity: normal Version: 2.5
Component: Administration Keywords: plugin, update, notification has-patch commit
Focuses: Cc:
PR Number:

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 (1)

5978.diff (399 bytes) - added by mdawaffe 12 years ago.

Download all attachments as: .zip

Change History (6)

#1 @fitztrev
12 years ago

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.

#2 @cavemonkey50
12 years ago

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.

#3 @lloydbudd
12 years ago

  • Owner changed from anonymous to mdawaffe

#4 @mdawaffe
12 years ago

  • Keywords has-patch commit added
  • 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.

@mdawaffe
12 years ago

#5 @ryan
12 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

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

Note: See TracTickets for help on using tickets.