Made wfReadOnlyReason catch DB connection errors
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 24 Apr 2015 20:52:32 +0000 (13:52 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 24 Apr 2015 20:52:32 +0000 (13:52 -0700)
Change-Id: I4e960d9bd751b2a6f95f08861fc8ed360af4a04a

includes/GlobalFunctions.php

index 0287798..cefa375 100644 (file)
@@ -1346,9 +1346,14 @@ function wfReadOnlyReason() {
                }
                // Callers use this method to be aware that data presented to a user
                // may be very stale and thus allowing submissions can be problematic.
-               if ( $wgReadOnly === false && wfGetLB()->getLaggedSlaveMode() ) {
+               try {
+                       if ( $wgReadOnly === false && wfGetLB()->getLaggedSlaveMode() ) {
+                               $wgReadOnly = 'The database has been automatically locked ' .
+                                       'while the slave database servers catch up to the master';
+                       }
+               } catch ( DBConnectionError $e ) {
                        $wgReadOnly = 'The database has been automatically locked ' .
-                               'while the slave database servers catch up to the master';
+                               'until the slave database servers become available';
                }
        }