Opened 15 years ago
Closed 14 years ago
#3792 closed enhancement (wontfix)
MySQL version checking
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | low | |
Severity: | normal | Version: | |
Component: | Optimization | Keywords: | mysql version needs-patch |
Focuses: | Cc: |
Description
WP has pretty loose requirements (which I think is cool). Plugin coders can easily check what PHP version is running to make stuff compatible with both cutting edge PHP5 and old PHP4, but it's "harder" to check MySQL version since it requires a SELECT VERSION() i.e. one sql query cost. So if 3 plugins need to check MySQL version, that's 3 query cost ?
I thought : it might be a good idea to test this and store it into wp_options, so that the info is available to all without adding an extra SQL query.
Ideally this would be tested once every {lots of queries} and on /wp-admin/upgrade.php loading, since it's unlikely to change.
Change History (11)
#4
@
15 years ago
mysql_get_server_info()
may make a SQL query... it has to get that version number somehow.
#6
@
15 years ago
It does no such thing.
http://lxr.php.net/source/php-src/ext/mysql/php_mysql.c#924
#7
@
15 years ago
- Keywords dev-feedback 2nd-opinion added
An option that doesn't use wp_options (which isn't too great, IMO) is to have a get_mysql_version() function that does mysql_get_server_info() and such, but caches it if it's already stored.
#9
@
15 years ago
- Keywords needs-patch added; dev-feedback 2nd-opinion removed
If implemented this needs to be a function on the wpdb class so as to keep all the mysql calls in one centralised replacable location.
#10
@
15 years ago
- Owner changed from ryan to pishmishy
- Status changed from new to assigned
I'm not sure that caching the result is such a great idea, there's good way to determine when we should refresh the value stored in the cache. Refreshing in upgrade.php seems an odd idea as I've never upgraded MySQL at the same time as I do WordPress upgrades.
Do many plugins really need to check the version of MySQL being used? Authors should really expect to be as conservative as WordPress is when it comes to SQL queries. I appreciate that's a rather ideal view, but it should result in better plugins.
Do those plugins need to check the version of MySQL every time a part of the plugin is invoked? That's the only scenario in which I can see the number of queries being a problem.
Recommend that the ticket is resolved as wontfix, or mysql_get_server_info() is used without caching, or the same function is wrapped into the wpdb class.
#11
@
14 years ago
- Milestone 2.5 deleted
- Resolution set to wontfix
- Status changed from assigned to closed
Plugin authors should limit their query features to MySQL 4.0
as WordPress does or inform users of which MySQL
version is required. If checks need to be done, they may do so during the activation process to inform users that they have a wrong version.
However, since their is no pre-activation hook (#4048) currently in WordPress Plugin authors can not prevent their activation based on their check. However, there are only a few features in MySQL 5.0+
and most plugins can go without.
There's a php function that does this:
mysql_get_server_info()