dépôts
/
lhc
/
web
/
wiklou.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3e5f943
)
Capture PHP errors from mysql_connect(). Apparently this is the only place connection...
author
Tim Starling
<tstarling@users.mediawiki.org>
Wed, 4 Jun 2008 01:44:36 +0000
(
01:44
+0000)
committer
Tim Starling
<tstarling@users.mediawiki.org>
Wed, 4 Jun 2008 01:44:36 +0000
(
01:44
+0000)
includes/Database.php
patch
|
blob
|
history
diff --git
a/includes/Database.php
b/includes/Database.php
index
67858f0
..
b231265
100644
(file)
--- a/
includes/Database.php
+++ b/
includes/Database.php
@@
-26,6
+26,7
@@
class Database {
#------------------------------------------------------------------------------
protected $mLastQuery = '';
#------------------------------------------------------------------------------
protected $mLastQuery = '';
+ protected $mPHPError = false;
protected $mServer, $mUser, $mPassword, $mConn = null, $mDBname;
protected $mOut, $mOpened = false;
protected $mServer, $mUser, $mPassword, $mConn = null, $mDBname;
protected $mOut, $mOpened = false;
@@
-343,21
+344,23
@@
class Database {
# so we use a short timeout plus a manual retry.
$this->mConn = false;
$max = 3;
# so we use a short timeout plus a manual retry.
$this->mConn = false;
$max = 3;
+ $this->installErrorHandler();
for ( $i = 0; $i < $max && !$this->mConn; $i++ ) {
if ( $i > 1 ) {
usleep( 1000 );
}
if ( $this->mFlags & DBO_PERSISTENT ) {
for ( $i = 0; $i < $max && !$this->mConn; $i++ ) {
if ( $i > 1 ) {
usleep( 1000 );
}
if ( $this->mFlags & DBO_PERSISTENT ) {
-
@/**/
$this->mConn = mysql_pconnect( $realServer, $user, $password );
+ $this->mConn = mysql_pconnect( $realServer, $user, $password );
} else {
# Create a new connection...
} else {
# Create a new connection...
-
@/**/
$this->mConn = mysql_connect( $realServer, $user, $password, true );
+ $this->mConn = mysql_connect( $realServer, $user, $password, true );
}
if ($this->mConn === false) {
#$iplus = $i + 1;
#wfLogDBError("Connect loop error $iplus of $max ($server): " . mysql_errno() . " - " . mysql_error()."\n");
}
}
}
if ($this->mConn === false) {
#$iplus = $i + 1;
#wfLogDBError("Connect loop error $iplus of $max ($server): " . mysql_errno() . " - " . mysql_error()."\n");
}
}
+ $phpError = $this->restoreErrorHandler();
wfProfileOut("dbconnect-$server");
wfProfileOut("dbconnect-$server");
@@
-396,7
+399,7
@@
class Database {
// Turn off strict mode if it is on
} else {
// Turn off strict mode if it is on
} else {
- $this->reportConnectionError();
+ $this->reportConnectionError(
$phpError
);
}
$this->mOpened = $success;
}
$this->mOpened = $success;
@@
-405,6
+408,20
@@
class Database {
}
/**@}}*/
}
/**@}}*/
+ protected function installErrorHandler() {
+ $this->mPHPError = false;
+ set_error_handler( array( $this, 'connectionErrorHandler' ) );
+ }
+
+ protected function restoreErrorHandler() {
+ restore_error_handler();
+ return $this->mPHPError;
+ }
+
+ protected function connectionErrorHandler( $errno, $errstr ) {
+ $this->mPHPError = $errstr;
+ }
+
/**
* Closes a database connection.
* if it is open : commits any open transactions
/**
* Closes a database connection.
* if it is open : commits any open transactions