Plugin Author
wpseek
(@alphawolf)
Oh, I thought I had posted here after releasing the plugin update.
The issue you (read: everyone) are experiencing seems to be a PHP bug. In short, it indicates 3.8.0 to be a higher version than 3.8.
I asked for it here http://stackoverflow.com/questions/22510810/version-compare-indicating-x-y-0-is-higher-than-x-y but didn’t get any replies yet.
The issue still persists in the latest PHP version 5.5.x. It might be intended behaviour, but I wouldn’t understand why. 🙂
That is strange indeed. But thanks for explaining. Maybe someone will still come back with an answer to your question there.
I guess the middle number given in this function is the installed WP version, right?
version_compare('3.8.0', '3.8', '>')
Is it possible then, to give the middle number a zero too? Like ‘3.8.0’ – so that it matches the first number? In other words, you could force the WP version to always use three digits like that, even when the last digit is zero. Would that work?
In any case, I guess this is only an issue (for me personally) for just a little while longer, because once WP 3.9.0 is released, in a few weeks, then the Simple History plugin will no longer produce this strange behaviour, right? Because its “Requires at least” field will still say 3.8.0 which will then be the previous version of WP, not the current version anymore, and therefore it will show in green not red. Right? And this is the only plugin I’m using that has this problem. I think 99% of plugins would use a “Requires at least” field that has an older version like 3.5 or 3.0 or something.
Okay I just did some further digging, and I believe I found the answer to your question about version_compare. The answer is given here.
So the problem is that “3.8” is not a PHP-standardized version number string. Apparently the numbers must use the same versioning format that PHP itself uses for its own versions, and I guess that means three digits, not just two digits, are required.
So it might still be that the solution is to convert the middle number (the current WP version) into three digits, by adding a zero when it’s only 3.8. If that’s possible to do. 🙂
Plugin Author
wpseek
(@alphawolf)
Hi GermanKiwi, thought about adding a zero too, but that would still result in the same issue… vice versa, though. 🙂
So, let’s say I’m adding a third digit to the installed WP version number, and plugin authors indicate their plugins to be compatible up to version 3.8. Result: The comparison would tell that the current WP version (3.8.0) is higher than the max plugin compatibility version (3.8), and it would be in red.
If you’re on WP 3.9.x, it will be in green, yes… unless the plugin author doesn’t set the “Requires at least” field to 3.9.0 🙂
Then again, if the plugin author of “Simple History” would change the “Requires at least” field to 3.8 (without a trailing zero; like 99% of plugin authors do), the issue would be gone right away.
True, I see your point there, about it giving the same problem in reverse!
What about this idea: can you make BPCC check to see how many digits are given in the readme.txt file, and then use the same number of digits in the WP version number?
Eg. if the plugin readme says “Requires at least: 3.8.0”, then BPCC will make sure the WP version also uses three digits (so it will add a zero if the WP version is 3.8).
But if the readme says “Requires at least: 3.8”, then BPCC will not use a zero at the end of the WP version – it will leave the WP version as “3.8”.
And if the WP version is actually 3.8.1 or 3.8.2 (ie. already three digits), then BPCC should leave it as three digits, and if necessary, it can add a zero to the plugin version number so that it matches the number of digits. So in other words, it adds or removes the zero whenever necessary, to make sure the number of digits matches.
But I don’t know how easy it would be to achieve this of course. 🙂
One other question: right now I have WP 3.8.1 installed, not 3.8.0. So why is your plugin using version_compare('3.8.0', '3.8', '>')
for the query? Shouldn’t it be using version_compare('3.8.0', '3.8.1', '>')
instead?
Plugin Author
wpseek
(@alphawolf)
As for your last question: That’s the result of this topic. 🙂
In order to display “Tested up to” for 3.8 in green, even though you’re running on 3.8.1, I’m stripping the current WP version to only two digits for comparison reasons.