Make ChronologyProtector::init() use instanceof instead of empty()
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 14 Feb 2017 22:21:19 +0000 (14:21 -0800)
committerThcipriani <tcipriani@wikimedia.org>
Tue, 14 Feb 2017 22:27:55 +0000 (22:27 +0000)
This is more robust and handles old root namespaced DBMasterPos values

Bug: T158127
Change-Id: Iba775fc808ac3e73d360f1adbe45ad222351c2d9

includes/libs/rdbms/ChronologyProtector.php

index 99e509c..1c28188 100644 (file)
@@ -119,7 +119,10 @@ class ChronologyProtector implements LoggerAwareInterface {
                $this->initPositions();
 
                $masterName = $lb->getServerName( $lb->getWriterIndex() );
-               if ( !empty( $this->startupPositions[$masterName] ) ) {
+               if (
+                       isset( $this->startupPositions[$masterName] ) &&
+                       $this->startupPositions[$masterName] instanceof DBMasterPos
+               ) {
                        $pos = $this->startupPositions[$masterName];
                        $this->logger->info( __METHOD__ . ": LB for '$masterName' set to pos $pos\n" );
                        $lb->waitFor( $pos );