X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FDatabase.php;h=eaecc1a0ef9d1d50bf8105370ca7a5a7ae2889c8;hb=f509270254cba380a092168d236cd529f3e8e10e;hp=fc2d67d77ef42041dc60af0c6041bb6f0c69039e;hpb=a07dac02fdb3a03added6fdbbadca667f5f39065;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Database.php b/includes/Database.php index fc2d67d77e..eaecc1a0ef 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -5,11 +5,6 @@ * @package MediaWiki */ -/** - * Depends on the CacheManager - */ -require_once( 'CacheManager.php' ); - /** See Database::makeList() */ define( 'LIST_COMMA', 0 ); define( 'LIST_AND', 1 ); @@ -91,6 +86,11 @@ class DBConnectionError extends DBError { return $this->getMessage() . "\n"; } + function getLogMessage() { + # Don't send to the exception log + return false; + } + function getPageTitle() { global $wgSitename; return "$wgSitename has a problem"; @@ -210,6 +210,11 @@ class DBQueryError extends DBError { } } + function getLogMessage() { + # Don't send to the exception log + return false; + } + function getPageTitle() { return $this->msg( 'databaseerror', 'Database error' ); } @@ -249,6 +254,9 @@ class Database { protected $mTrxLevel = 0; protected $mErrorCount = 0; protected $mLBInfo = array(); + protected $mCascadingDeletes = false; + protected $mCleanupTriggers = false; + protected $mStrictIPs = false; #------------------------------------------------------------------------------ # Accessors @@ -267,8 +275,8 @@ class Database { * Output page, used for reporting errors * FALSE means discard output */ - function &setOutputPage( &$out ) { - $this->mOut =& $out; + function setOutputPage( $out ) { + $this->mOut = $out; } /** @@ -339,6 +347,28 @@ class Database { } } + /** + * Returns true if this database supports (and uses) cascading deletes + */ + function cascadingDeletes() { + return $this->mCascadingDeletes; + } + + /** + * Returns true if this database supports (and uses) triggers (e.g. on the page table) + */ + function cleanupTriggers() { + return $this->mCleanupTriggers; + } + + /** + * Returns true if this database is strict about what can be put into an IP field. + * Specifically, it uses a NULL value instead of an empty string. + */ + function strictIPs() { + return $this->mStrictIPs; + } + /**#@+ * Get function */ @@ -438,6 +468,7 @@ class Database { */ function open( $server, $user, $password, $dbName ) { global $wguname; + wfProfileIn( __METHOD__ ); # Test for missing mysql.so # First try to load it @@ -485,18 +516,19 @@ class Database { $success = (bool)$this->mConn; } - if ( !$success ) { + if ( $success ) { + global $wgDBmysql5; + if( $wgDBmysql5 ) { + // Tell the server we're communicating with it in UTF-8. + // This may engage various charset conversions. + $this->query( 'SET NAMES utf8' ); + } + } else { $this->reportConnectionError(); } - global $wgDBmysql5; - if( $wgDBmysql5 ) { - // Tell the server we're communicating with it in UTF-8. - // This may engage various charset conversions. - $this->query( 'SET NAMES utf8' ); - } - $this->mOpened = $success; + wfProfileOut( __METHOD__ ); return $success; } /**@}}*/ @@ -765,8 +797,8 @@ class Database { */ function fetchObject( $res ) { @/**/$row = mysql_fetch_object( $res ); - if( mysql_errno() ) { - throw new DBUnexpectedError( $this, 'Error in fetchObject(): ' . htmlspecialchars( mysql_error() ) ); + if( $this->lastErrno() ) { + throw new DBUnexpectedError( $this, 'Error in fetchObject(): ' . htmlspecialchars( $this->lastError() ) ); } return $row; } @@ -777,8 +809,8 @@ class Database { */ function fetchRow( $res ) { @/**/$row = mysql_fetch_array( $res ); - if (mysql_errno() ) { - throw new DBUnexpectedError( $this, 'Error in fetchRow(): ' . htmlspecialchars( mysql_error() ) ); + if ( $this->lastErrno() ) { + throw new DBUnexpectedError( $this, 'Error in fetchRow(): ' . htmlspecialchars( $this->lastError() ) ); } return $row; } @@ -788,8 +820,8 @@ class Database { */ function numRows( $res ) { @/**/$n = mysql_num_rows( $res ); - if( mysql_errno() ) { - throw new DBUnexpectedError( $this, 'Error in numRows(): ' . htmlspecialchars( mysql_error() ) ); + if( $this->lastErrno() ) { + throw new DBUnexpectedError( $this, 'Error in numRows(): ' . htmlspecialchars( $this->lastError() ) ); } return $n; } @@ -1367,7 +1399,7 @@ class Database { * @return string slashed string. */ function strencode( $s ) { - return addslashes( $s ); + return mysql_real_escape_string( $s, $this->mConn ); } /** @@ -1859,6 +1891,10 @@ class Database { return $b; } + function decodeBlob($b) { + return $b; + } + /** * Read and execute SQL commands from a file. * Returns true on success, error string on failure @@ -1866,7 +1902,7 @@ class Database { function sourceFile( $filename ) { $fp = fopen( $filename, 'r' ); if ( false === $fp ) { - return "Could not open \"{$fname}\".\n"; + return "Could not open \"{$filename}\".\n"; } $cmd = ""; @@ -1931,7 +1967,7 @@ class Database { // Ordinary variables foreach ( $varnames as $var ) { if( isset( $GLOBALS[$var] ) ) { - $val = addslashes( $GLOBALS[$var] ); + $val = addslashes( $GLOBALS[$var] ); // FIXME: safety check? $ins = str_replace( '{$' . $var . '}', $val, $ins ); $ins = str_replace( '/*$' . $var . '*/`', '`' . $val, $ins ); $ins = str_replace( '/*$' . $var . '*/', $val, $ins );