X-Git-Url: https://git.cyclocoop.org/admin/?a=blobdiff_plain;f=includes%2Fpoolcounter%2FPoolWorkArticleView.php;h=0abe1a5dde12c90cd27ec376ef2470c24730d10f;hb=956ffb9cd77bb9748cf7bc425d50f0eea7e3abdd;hp=286494efa450ae3ffb1b46bf99f80e74fd1293b0;hpb=62c6f40d73637c777a6bf14eaa4d1512e6663170;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/poolcounter/PoolWorkArticleView.php b/includes/poolcounter/PoolWorkArticleView.php index 286494efa4..0abe1a5dde 100644 --- a/includes/poolcounter/PoolWorkArticleView.php +++ b/includes/poolcounter/PoolWorkArticleView.php @@ -19,10 +19,11 @@ */ use MediaWiki\MediaWikiServices; +use MediaWiki\Revision\MutableRevisionRecord; +use MediaWiki\Revision\RevisionRecord; use MediaWiki\Revision\RevisionRenderer; -use MediaWiki\Storage\MutableRevisionRecord; -use MediaWiki\Storage\RevisionRecord; -use MediaWiki\Storage\RevisionStore; +use MediaWiki\Revision\RevisionStore; +use MediaWiki\Revision\SlotRecord; class PoolWorkArticleView extends PoolCounterWork { /** @var WikiPage */ @@ -43,6 +44,9 @@ class PoolWorkArticleView extends PoolCounterWork { /** @var RevisionRecord|null */ private $revision = null; + /** @var int */ + private $audience; + /** @var RevisionStore */ private $revisionStore = null; @@ -66,9 +70,10 @@ class PoolWorkArticleView extends PoolCounterWork { * operation. * @param RevisionRecord|Content|string|null $revision Revision to render, or null to load it; * may also be given as a wikitext string, or a Content object, for BC. + * @param int $audience One of the RevisionRecord audience constants */ public function __construct( WikiPage $page, ParserOptions $parserOptions, - $revid, $useParserCache, $revision = null + $revid, $useParserCache, $revision = null, $audience = RevisionRecord::FOR_PUBLIC ) { if ( is_string( $revision ) ) { // BC: very old style call $modelId = $page->getRevision()->getContentModel(); @@ -81,7 +86,7 @@ class PoolWorkArticleView extends PoolCounterWork { $revision = new MutableRevisionRecord( $page->getTitle() ); $revision->setId( $revid ); $revision->setPageId( $page->getId() ); - $revision->setContent( 'main', $content ); + $revision->setContent( SlotRecord::MAIN, $content ); } if ( $revision ) { @@ -107,8 +112,11 @@ class PoolWorkArticleView extends PoolCounterWork { $this->cacheable = $useParserCache; $this->parserOptions = $parserOptions; $this->revision = $revision; + $this->audience = $audience; $this->cacheKey = $this->parserCache->getKey( $page, $parserOptions ); - $keyPrefix = $this->cacheKey ?: wfMemcKey( 'articleview', 'missingcachekey' ); + $keyPrefix = $this->cacheKey ?: ObjectCache::getLocalClusterInstance()->makeKey( + 'articleview', 'missingcachekey' + ); parent::__construct( 'ArticleView', $keyPrefix . ':revid:' . $revid ); } @@ -151,8 +159,8 @@ class PoolWorkArticleView extends PoolCounterWork { $isCurrent = $this->revid === $this->page->getLatest(); - // Bypass audience check for current revision - $audience = $isCurrent ? RevisionRecord::RAW : RevisionRecord::FOR_PUBLIC; + // The current revision cannot be hidden so we can skip some checks. + $audience = $isCurrent ? RevisionRecord::RAW : $this->audience; if ( $this->revision !== null ) { $rev = $this->revision;