#25228 closed defect (bug) (wontfix)
wpdb::db_version() not permissive enough
Reported by: | ozh | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.6 |
Component: | Upgrade/Install | Keywords: | has-patch |
Focuses: | Cc: |
Description
I ran into a MySQL server which was returning a unusual "mysql-5.5"
as a version number.
Current wpdb::db_version() returns ""
(empty string) with this version number
Patch returns the expected "5.5"
and works the same with traditional version numbers
Attachments (2)
Change History (9)
#3
@
11 years ago
I think 5.5
would be preferred, and it's why the regex does what it does.
We could strip of mysql-
from the start of a string, but I'd want to A) question what server would ever do this, B) wonder what else we'd need to strip off, and C) wonder if this is worth accounting for?
#4
@
11 years ago
The server I ran into was using http://www.continuent.com/ and, words from user, "they use a lot of non-standard settings".
I don't think the idea would be just to check for "mysql-" at the start, but rather for anything that's not a number. Regex '/(^[^0-9]*)|[^0-9.].*/'
does the job I think
$vers = array( 'omgmysql-5.5-ubuntu-4.20', 'mysql5.5-ubuntu-4.20', '5.5-ubuntu-4.20', '5.5-beta2', '5.5', ); foreach( $vers as $ver ) { var_dump( preg_replace( '/(^[^0-9]*)|[^0-9.].*/', '', $ver ) ); } /* string '5.5' (length=3) string '5.5' (length=3) string '5.5' (length=3) string '5.5' (length=3) string '5.5' (length=3) */
Now, as for C), I'll let you judge :)
Obviously this is dealing with marginal edge case, I would tend to think we can fix marginal stuff as long as it doesn't hurt, but you be the boss, boss.
This would break things like
5.5-ubuntu-4.20
.