X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2FChronologyProtector.php;h=8b1aabe3cd48399d42e8859c10719fe58babc860;hb=36395150104588f2afea866c330b683e4329fa48;hp=dfe950e405b92ce3842ff3a4121704532e20b01d;hpb=b929c0eb7f3a0954af5aca6d50995d87fa83945b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/rdbms/ChronologyProtector.php b/includes/libs/rdbms/ChronologyProtector.php index dfe950e405..8b1aabe3cd 100644 --- a/includes/libs/rdbms/ChronologyProtector.php +++ b/includes/libs/rdbms/ChronologyProtector.php @@ -28,8 +28,6 @@ use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; use Wikimedia\WaitConditionLoop; use BagOStuff; -use DBMasterPos; -use ILoadBalancer; /** * Class for ensuring a consistent ordering of events as seen by the user, despite replication. @@ -77,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(); } @@ -121,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 ); @@ -300,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; @@ -320,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; }