[wp-hackers] Wordpress - Database persistent connection support
Rarylson Freitas
rarylson at gmail.com
Fri Aug 23 16:03:10 UTC 2013
Hi,
I see that Wordpress uses the mysql_connect funcion in wp-db.php file. So,
the db_connect() function always return a non persistent connection to the
database.
So, I propose a patch (to Wordpress v.3.5.1).
My Idea is a new config constant in wp-config.php.
So, to enable persistente connections, the administrator will set in the
wp-config.php file:
define("WP_PCONNECT", true);
What do you think about it?
The patch is:
--- wp-db.php.old 2013-08-23 15:44:09.897307644 +0000
+++ wp-db.php 2013-08-23 15:45:33.903027939 +0000
@@ -1140,7 +1140,12 @@
if ( WP_DEBUG ) {
$this->dbh = mysql_connect( $this->dbhost,
$this->dbuser, $this->dbpassword, $new_link, $client_flags );
} else {
- $this->dbh = @mysql_connect( $this->dbhost,
$this->dbuser, $this->dbpassword, $new_link, $client_flags );
+ // Rarylson's Patch - Using pconnect
+ if ( WP_PCONNECT ) {
+ $this->dbh = @mysql_pconnect(
$this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
+ } else {
+ $this->dbh = @mysql_connect( $this->dbhost,
$this->dbuser, $this->dbpassword, $new_link, $client_flags );
+ }
}
if ( !$this->dbh ) {
--
*Rarylson Freitas
*
Computer Engineer
More information about the wp-hackers
mailing list