Merge "Allow extensions to indicate a username doesn't exist"
[lhc/web/wiklou.git] / includes / db / Database.php
index 85f0420..9584e46 100644 (file)
@@ -679,8 +679,6 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
         *   - DBO_DEBUG: output some debug info (same as debug())
         *   - DBO_NOBUFFER: don't buffer results (inverse of bufferResults())
         *   - DBO_TRX: automatically start transactions
-        *   - DBO_DEFAULT: automatically sets DBO_TRX if not in command line mode
-        *       and removes it in command line mode
         *   - DBO_PERSISTENT: use persistant database connection
         * @return bool
         */
@@ -710,19 +708,42 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
        }
 
        /**
-        * Return a path to the DBMS-specific schema file, otherwise default to tables.sql
+        * Return a path to the DBMS-specific SQL file if it exists,
+        * otherwise default SQL file
         *
+        * @param string $filename
         * @return string
         */
-       public function getSchemaPath() {
+       private function getSqlFilePath( $filename ) {
                global $IP;
-               if ( file_exists( "$IP/maintenance/" . $this->getType() . "/tables.sql" ) ) {
-                       return "$IP/maintenance/" . $this->getType() . "/tables.sql";
+               $dbmsSpecificFilePath = "$IP/maintenance/" . $this->getType() . "/$filename";
+               if ( file_exists( $dbmsSpecificFilePath ) ) {
+                       return $dbmsSpecificFilePath;
                } else {
-                       return "$IP/maintenance/tables.sql";
+                       return "$IP/maintenance/$filename";
                }
        }
 
+       /**
+        * Return a path to the DBMS-specific schema file,
+        * otherwise default to tables.sql
+        *
+        * @return string
+        */
+       public function getSchemaPath() {
+               return $this->getSqlFilePath( 'tables.sql' );
+       }
+
+       /**
+        * Return a path to the DBMS-specific update key file,
+        * otherwise default to update-keys.sql
+        *
+        * @return string
+        */
+       public function getUpdateKeysPath() {
+               return $this->getSqlFilePath( 'update-keys.sql' );
+       }
+
 # ------------------------------------------------------------------------------
 # Other functions
 # ------------------------------------------------------------------------------
@@ -1130,7 +1151,9 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                        $this->mTrxIdleCallbacks = array(); // bug 65263
                        $this->mTrxPreCommitCallbacks = array(); // bug 65263
                        wfDebug( "Connection lost, reconnecting...\n" );
-
+                       # Stash the last error values since ping() might clear them
+                       $lastError = $this->lastError();
+                       $lastErrno = $this->lastErrno();
                        if ( $this->ping() ) {
                                global $wgRequestTime;
                                wfDebug( "Reconnected\n" );
@@ -1145,6 +1168,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                                if ( $hadTrx ) {
                                        # Leave $ret as false and let an error be reported.
                                        # Callers may catch the exception and continue to use the DB.
+                                       $this->reportQueryError( $lastError, $lastErrno, $sql, $fname, $tempIgnore );
                                } else {
                                        # Should be safe to silently retry (no trx and thus no callbacks)
                                        $ret = $this->doQuery( $commentedSql );
@@ -1490,6 +1514,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
         * @param array $options Query options
         * @param array $join_conds Join conditions
         *
+        *
         * @param string|array $table
         *
         * May be either an array of table names, or a single string holding a table
@@ -3211,7 +3236,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
         * @param DBMasterPos $pos
         * @param int $timeout The maximum number of seconds to wait for
         *   synchronisation
-        * @return int Zzero if the slave was past that position already,
+        * @return int Zero if the slave was past that position already,
         *   greater than zero if we waited for some period of time, less than
         *   zero if we timed out.
         */
@@ -4197,6 +4222,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
 
        /**
         * @since 1.19
+        * @return string
         */
        public function __toString() {
                return (string)$this->mConn;