Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/229981

Change subject: Avoid update.php suggestion on DB connection errors
......................................................................

Avoid update.php suggestion on DB connection errors

Bug: T98788
Change-Id: I21974d6b775f13c33055f76c30142e937eb0e965
---
M includes/db/Database.php
M includes/db/DatabaseError.php
M includes/db/DatabaseMysqlBase.php
3 files changed, 28 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/81/229981/1

diff --git a/includes/db/Database.php b/includes/db/Database.php
index 2ee4545..619d4ae 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -3190,6 +3190,17 @@
        }
 
        /**
+        * Determines if the given query error was a connection drop
+        * STUB
+        *
+        * @param integer|string $ernno
+        * @return bool
+        */
+       public function wasConnectionError( $ernno ) {
+               return false;
+       }
+
+       /**
         * Perform a deadlock-prone transaction.
         *
         * This function invokes a callback function to perform a set of write
diff --git a/includes/db/DatabaseError.php b/includes/db/DatabaseError.php
index 86950a8..928de61 100644
--- a/includes/db/DatabaseError.php
+++ b/includes/db/DatabaseError.php
@@ -329,12 +329,19 @@
         * @param string $fname
         */
        function __construct( DatabaseBase $db, $error, $errno, $sql, $fname ) {
-               $message = "A database error has occurred. Did you forget to 
run " .
-                       "maintenance/update.php after upgrading?  See: " .
-                       
"https://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n"; .
-                       "Query: $sql\n" .
-                       "Function: $fname\n" .
-                       "Error: $errno $error\n";
+               if ( $db->wasConnectionError( $errno ) ) {
+                       $message = "A connection error occured. \n" .
+                               "Query: $sql\n" .
+                               "Function: $fname\n" .
+                               "Error: $errno $error\n";
+               } else {
+                       $message = "A database error has occurred. Did you 
forget to run " .
+                               "maintenance/update.php after upgrading?  See: 
" .
+                               
"https://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n"; .
+                               "Query: $sql\n" .
+                               "Function: $fname\n" .
+                               "Error: $errno $error\n";
+               }
                parent::__construct( $db, $message );
 
                $this->error = $error;
diff --git a/includes/db/DatabaseMysqlBase.php 
b/includes/db/DatabaseMysqlBase.php
index 846da1c..048d435 100644
--- a/includes/db/DatabaseMysqlBase.php
+++ b/includes/db/DatabaseMysqlBase.php
@@ -1055,6 +1055,10 @@
                        ( $this->lastErrno() == 1290 && strpos( 
$this->lastError(), '--read-only' ) !== false );
        }
 
+       function wasConnectionError( $ernno ) {
+               return $ernno == 2013 || $ernno == 2006;
+       }
+
        /**
         * Get the underlying binding handle, mConn
         *

-- 
To view, visit https://gerrit.wikimedia.org/r/229981
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I21974d6b775f13c33055f76c30142e937eb0e965
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to