X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2FChronologyProtector.php;h=8b1aabe3cd48399d42e8859c10719fe58babc860;hb=36395150104588f2afea866c330b683e4329fa48;hp=88af1dbdf8f49d51710c3ccb0ee071acdbb1e7de;hpb=57eaa2bf04ce1b48bd89c10defe4de5b7d31f047;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/rdbms/ChronologyProtector.php b/includes/libs/rdbms/ChronologyProtector.php index 88af1dbdf8..8b1aabe3cd 100644 --- a/includes/libs/rdbms/ChronologyProtector.php +++ b/includes/libs/rdbms/ChronologyProtector.php @@ -20,9 +20,14 @@ * @file * @ingroup Database */ + +namespace Wikimedia\Rdbms; + use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; use Wikimedia\WaitConditionLoop; +use BagOStuff; /** * Class for ensuring a consistent ordering of events as seen by the user, despite replication. @@ -70,9 +75,9 @@ 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 \Psr\Log\NullLogger(); + $this->logger = new NullLogger(); } public function setLogger( LoggerInterface $logger ) { @@ -114,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 ); @@ -293,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; @@ -313,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; }