Opened 17 years ago
Closed 17 years ago
#5978 closed defect (bug) (fixed)
Plugin version checking not always detecting updated versions.
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | 2.5 |
Component: | Administration | Keywords: | plugin, update, notification has-patch commit |
Focuses: | Cc: |
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)
Change History (6)
#2
@
17 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.
#4
@
17 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.
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.