Made updateSpecialPages.php more robust to database problems
[lhc/web/wiklou.git] / includes / Database.php
index 348f18e..51104db 100644 (file)
@@ -44,6 +44,7 @@ class Database {
        var $mTablePrefix;
        var $mFlags;
        var $mTrxLevel = 0;
+       var $mErrorCount = 0;
        /**#@-*/
 
 #------------------------------------------------------------------------------
@@ -105,6 +106,13 @@ class Database {
                return wfSetVar( $this->mTrxLevel, $level );
        }
 
+       /** 
+        * Number of errors logged, only useful when errors are ignored
+        */
+       function errorCount( $count = NULL ) {
+               return wfSetVar( $this->mErrorCount, $count );
+       }
+
        /**#@+
         * Get function
         */
@@ -308,7 +316,7 @@ class Database {
                $ret = $this->doQuery( $commentedSql );
 
                # Try reconnecting if the connection was lost
-               if ( false === $ret && $this->lastErrno() == 2013 ) {
+               if ( false === $ret && ( $this->lastErrno() == 2013 || $this->lastErrno() == 2006 ) ) {
                        # Transaction is gone, like it or not
                        $this->mTrxLevel = 0;
                        wfDebug( "Connection lost, reconnecting...\n" );
@@ -321,7 +329,6 @@ class Database {
                }
 
                if ( false === $ret ) {
-                       # Automatic reconnect
                        $this->reportQueryError( $this->lastError(), $this->lastErrno(), $sql, $fname, $tempIgnore );
                }
                                
@@ -355,6 +362,7 @@ class Database {
                global $wgCommandLineMode, $wgFullyInitialised;
                # Ignore errors during error handling to avoid infinite recursion
                $ignore = $this->ignoreErrors( true );
+               $this->mErrorCount ++;
 
                if( $ignore || $tempIgnore ) {
                        wfDebug("SQL ERROR (ignored): " . $error . "\n");