WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#20416 closed defect (bug) (invalid)

Install plugins version checking not correct

Reported by: Workshopshed Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.4
Component: Administration Keywords:
Focuses: Cc:

Description

The version checking does not seem to be treating the numbers in the same way a person would, when I view the "details" the screen says:

Newer Version (1.63) Installed
FYI
Version: 1.7

Surely 1.7 is newer than 1.63.

Looking in the code I see that install_plugin_install_status is the function that manages this which is in wp-admin\includes\plugin-install.php

That in turn uses "version_compare" to check the versions. Experimenting with that function which is a php function it would seem that:

version_compare('1.7','1.63', '<')    = true
version_compare('1.7','1.6', '<')     = false
version_compare('1.70','1.60', '<')   = false
version_compare('1.70','1.63', '<')   = false

So a work around for this is to ensure that people use a standarised numbering convention. This behaviour has been there since 3.0.0.

Change History (3)

comment:1 dd322 years ago

The behavior of the install screen did change at one point to match the version comparisons used elsewhere, previously I believe this used a decimal comparison ( 1.7 > 1.63?) which broke on major.minor.patch (3.2.1) style version numbers.

Since we use version_compare() everywhere else in WordPress for the update notifications, it makes sense to keep that there. As a result, if you're using 1.63, you'll never get a update notification to 1.7, since that's 1.07 vs 1.63 when it comes to version comparisons.

So in the end, I think it's something that has to be left up to plugin authors to actually specify their versions right, although, some documentation to mention this gotcha might be advisable if it's not already around somewhere...

comment:2 nacin2 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

comment:3 Workshopshed2 years ago

Perhaps a one liner in the codex either http://codex.wordpress.org/Writing_a_Plugin or http://wordpress.org/extend/plugins/about/readme.txt explaining the necessary numbering format or that the format needs to be consistent?

"The version number needs to be consistently formatted between your plugin versions so that the upgrade mechanism can correctly read the numbers. For example, x.x or x.x.x or xx.xx.xxx"

Version 2, edited 2 years ago by Workshopshed (previous) (next) (diff)
Note: See TracTickets for help on using tickets.