/** * @return ChronologyProtector */ protected function getChronologyProtector() { if ($this->chronProt) { return $this->chronProt; } $this->chronProt = new ChronologyProtector($this->memCache, ['ip' => $this->requestInfo['IPAddress'], 'agent' => $this->requestInfo['UserAgent']], isset($_GET['cpPosTime']) ? $_GET['cpPosTime'] : null); $this->chronProt->setLogger($this->replLogger); if ($this->cliMode) { $this->chronProt->setEnabled(false); } elseif ($this->requestInfo['ChronologyProtection'] === 'false') { // Request opted out of using position wait logic. This is useful for requests // done by the job queue or background ETL that do not have a meaningful session. $this->chronProt->setWaitEnabled(false); } $this->replLogger->debug(__METHOD__ . ': using request info ' . json_encode($this->requestInfo, JSON_PRETTY_PRINT)); return $this->chronProt; }
/** * @return ChronologyProtector */ protected function newChronologyProtector() { $request = RequestContext::getMain()->getRequest(); $chronProt = new ChronologyProtector(ObjectCache::getMainStashInstance(), array('ip' => $request->getIP(), 'agent' => $request->getHeader('User-Agent'))); if (PHP_SAPI === 'cli') { $chronProt->setEnabled(false); } elseif ($request->getHeader('ChronologyProtection') === 'false') { // Request opted out of using position wait logic. This is useful for requests // done by the job queue or background ETL that do not have a meaningful session. $chronProt->setWaitEnabled(false); } return $chronProt; }