summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmir Sarabadani <ladsgroup@gmail.com>2022-03-30 22:23:01 +0200
committerLadsgroup <Ladsgroup@gmail.com>2022-04-05 15:20:30 +0000
commit6ae0c8aff321848f07b720d99646a14dbe1c7f92 (patch)
treec2c03720fe4c7249d527ac3c6ac199fc1056b7be
parenta0ae4c05efb0072f5239d76687f5b6f605dc9e53 (diff)
ParserOutputAccess: Allow calling getPO with option of not saving in PCwmf/1.39.0-wmf.5
This is needed to make sure CirrusSearch doesn't overwhelm parsercache. Follows-up I23c053df4c (T302620). Bug: T285993 Change-Id: Ia5fc3b063c45cb43fdee16f44da2270847773945 (cherry picked from commit a087f79319043c5e20c1b25da89b79bba0f63a8b)
-rw-r--r--includes/content/ContentHandler.php8
-rw-r--r--includes/page/ParserOutputAccess.php12
-rw-r--r--includes/poolcounter/PoolWorkArticleViewCurrent.php6
3 files changed, 15 insertions, 11 deletions
diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php
index 7c6dcfa7d3a6..4d94473e42d1 100644
--- a/includes/content/ContentHandler.php
+++ b/includes/content/ContentHandler.php
@@ -33,6 +33,7 @@ use MediaWiki\Content\ValidationParams;
use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
+use MediaWiki\Page\ParserOutputAccess;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\Revision\SlotRenderingProvider;
@@ -1429,7 +1430,12 @@ abstract class ContentHandler {
// See T190066.
$parserOptions = $page->makeParserOptions( 'canonical' );
$parserOutputAccess = MediaWikiServices::getInstance()->getParserOutputAccess();
- return $parserOutputAccess->getParserOutput( $page, $parserOptions )->getValue();
+ return $parserOutputAccess->getParserOutput(
+ $page,
+ $parserOptions,
+ null,
+ ParserOutputAccess::OPT_NO_UPDATE_CACHE
+ )->getValue();
}
/**
diff --git a/includes/page/ParserOutputAccess.php b/includes/page/ParserOutputAccess.php
index 359357511545..9b0e4f001e44 100644
--- a/includes/page/ParserOutputAccess.php
+++ b/includes/page/ParserOutputAccess.php
@@ -57,9 +57,8 @@ class ParserOutputAccess {
/**
* @var int Do not update the cache after parsing.
- * Private because it does not make sense to be called separately.
*/
- private const OPT_NO_UPDATE_CACHE = 2;
+ public const OPT_NO_UPDATE_CACHE = 2;
/**
* @var int Bypass audience check for deleted/suppressed revisions.
@@ -397,11 +396,7 @@ class ParserOutputAccess {
RevisionRecord $revision,
int $options
): PoolWorkArticleView {
- if ( $options & self::OPT_NO_UPDATE_CACHE ) {
- $useCache = self::CACHE_NONE;
- } else {
- $useCache = $this->shouldUseCache( $page, $parserOptions, $revision );
- }
+ $useCache = $this->shouldUseCache( $page, $parserOptions, $revision );
switch ( $useCache ) {
case self::CACHE_PRIMARY:
@@ -422,7 +417,8 @@ class ParserOutputAccess {
$this->primaryCache,
$this->lbFactory,
$this->loggerSpi,
- $this->wikiPageFactory
+ $this->wikiPageFactory,
+ !( $options & self::OPT_NO_UPDATE_CACHE )
);
case self::CACHE_SECONDARY:
diff --git a/includes/poolcounter/PoolWorkArticleViewCurrent.php b/includes/poolcounter/PoolWorkArticleViewCurrent.php
index e567d3a49f61..95cb60130c87 100644
--- a/includes/poolcounter/PoolWorkArticleViewCurrent.php
+++ b/includes/poolcounter/PoolWorkArticleViewCurrent.php
@@ -57,6 +57,7 @@ class PoolWorkArticleViewCurrent extends PoolWorkArticleView {
* @param ILBFactory $lbFactory
* @param LoggerSpi $loggerSpi
* @param WikiPageFactory $wikiPageFactory
+ * @param bool $cacheable Whether it should store the result in cache or not
*/
public function __construct(
string $workKey,
@@ -67,7 +68,8 @@ class PoolWorkArticleViewCurrent extends PoolWorkArticleView {
ParserCache $parserCache,
ILBFactory $lbFactory,
LoggerSpi $loggerSpi,
- WikiPageFactory $wikiPageFactory
+ WikiPageFactory $wikiPageFactory,
+ bool $cacheable = true
) {
// TODO: Remove support for partially initialized RevisionRecord instances once
// Article no longer uses fake revisions.
@@ -82,7 +84,7 @@ class PoolWorkArticleViewCurrent extends PoolWorkArticleView {
$this->parserCache = $parserCache;
$this->lbFactory = $lbFactory;
$this->wikiPageFactory = $wikiPageFactory;
- $this->cacheable = true;
+ $this->cacheable = $cacheable;
}
/**