Make WordPress Core

Opened 15 years ago

Closed 14 years ago

#3792 closed enhancement (wontfix)

MySQL version checking

Reported by: ozh's profile Ozh Owned by: pishmishy's profile pishmishy
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)

#1 @foolswisdom
15 years ago

  • Milestone changed from 2.1.2 to 2.3

#2 @ryan
15 years ago

  • Owner changed from anonymous to ryan

#3 @darkfate
15 years ago

There's a php function that does this:

mysql_get_server_info()

#4 @markjaquith
15 years ago

mysql_get_server_info() may make a SQL query... it has to get that version number somehow.

#5 @darkfate
15 years ago

Yeah, but I think php cache's it after it's run. It puts it in the temp folder.

#7 @rob1n
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.

#8 @ryan
15 years ago

  • Milestone changed from 2.3 to 2.4 (next)

#9 @westi
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 @pishmishy
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 @darkdragon
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.

Note: See TracTickets for help on using tickets.