Page 1 of 1

Plugin version numbers?

Posted: Wed Mar 23, 2005 11:13 pm
by Tys
It seems that Spartacus checks version information just on a string comparision. Any chance of trying to convert the versions to numbers (and if it fails, then just do a string match), or splitting on the . and comparing per level (ie 1.1 < 1.3, 1.1.1 < 1.1.3, 1.1 < 1.1.1)?

Sidebar Hider Upgrade
Shrinks Sidebars to just their titles. Extra configuration in Entries -> Manage Sidebars in the Admin Suite.
Author: Tys von Gaza; version: 1.3; Upgrade to version 1.1

Re: Plugin version numbers?

Posted: Thu Mar 24, 2005 12:51 pm
by garvinhicking
Yes, you're right, we currently only use exact stringmatching in spartacus, line 222:

Code: Select all

                        if ($bag->get('version') == $pluginstack[$i]['version']) {
                            $installable = false;
                        } else {
                            $pluginstack[$i]['upgradable']      = true;
                            $pluginstack[$i]['upgrade_version'] = $pluginstack[$i]['version'];
                            $pluginstack[$i]['version']         = $bag->get('version');
                            $upgradeLink                        = '&serendipity[spartacus_upgrade]=true';
                        }
which may be patched to this:

Code: Select all

                        if ($bag->get('version') == $pluginstack[$i]['version']) {
                            $installable = false;
                        } elseif (version_compare($bag->get('version'), $pluginstack[$i]['version'], '<')) {
                            $pluginstack[$i]['upgradable']      = true;
                            $pluginstack[$i]['upgrade_version'] = $pluginstack[$i]['version'];
                            $pluginstack[$i]['version']         = $bag->get('version');
                            $upgradeLink                        = '&serendipity[spartacus_upgrade]=true';
                        }
We should be able to use version_compare logic there easily, but I'm afraid it might break some stuff.

As the problem only arises when you locally develop plugins and not have them in the repository yet, I'd like to postpone a bugfix until Serendipity 0.9 development begins (in 1-2 weeks)

Regards,
Garvin