Merge "Drop index oi_name_archive_name on table oldimage"
[lhc/web/wiklou.git] / includes / libs / rdbms / ChronologyProtector.php
index 99e509c..8b1aabe 100644 (file)
@@ -75,7 +75,7 @@ class ChronologyProtector implements LoggerAwareInterface {
        public function __construct( BagOStuff $store, array $client, $posTime = null ) {
                $this->store = $store;
                $this->clientId = md5( $client['ip'] . "\n" . $client['agent'] );
-               $this->key = $store->makeGlobalKey( __CLASS__, $this->clientId );
+               $this->key = $store->makeGlobalKey( __CLASS__, $this->clientId, 'v1' );
                $this->waitForPosTime = $posTime;
                $this->logger = new NullLogger();
        }
@@ -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 );
@@ -298,8 +301,9 @@ class ChronologyProtector implements LoggerAwareInterface {
 
                $min = null;
                foreach ( $data['positions'] as $pos ) {
-                       /** @var DBMasterPos $pos */
-                       $min = $min ? min( $pos->asOfTime(), $min ) : $pos->asOfTime();
+                       if ( $pos instanceof DBMasterPos ) {
+                               $min = $min ? min( $pos->asOfTime(), $min ) : $pos->asOfTime();
+                       }
                }
 
                return $min;
@@ -318,8 +322,10 @@ class ChronologyProtector implements LoggerAwareInterface {
                        $curPositions = $curValue['positions'];
                        // Use the newest positions for each DB master
                        foreach ( $shutdownPositions as $db => $pos ) {
-                               if ( !isset( $curPositions[$db] )
-                                       || $pos->asOfTime() > $curPositions[$db]->asOfTime()
+                               if (
+                                       !isset( $curPositions[$db] ) ||
+                                       !( $curPositions[$db] instanceof DBMasterPos ) ||
+                                       $pos->asOfTime() > $curPositions[$db]->asOfTime()
                                ) {
                                        $curPositions[$db] = $pos;
                                }