Hoo man has uploaded a new change for review.
https://gerrit.wikimedia.org/r/257864
Change subject: Make sure that we don't cache ParserOutputs without HTML
......................................................................
Make sure that we don't cache ParserOutputs without HTML
Otherwise the article body will be empty.
Change-Id: I1db1b451e44168fe5e92b05a0b2539fc77864c5d
---
M repo/includes/ParserOutput/EntityParserOutputGenerator.php
M repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorTest.php
2 files changed, 19 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/64/257864/1
diff --git a/repo/includes/ParserOutput/EntityParserOutputGenerator.php
b/repo/includes/ParserOutput/EntityParserOutputGenerator.php
index 91aa9d7..c2b9bd8 100644
--- a/repo/includes/ParserOutput/EntityParserOutputGenerator.php
+++ b/repo/includes/ParserOutput/EntityParserOutputGenerator.php
@@ -173,6 +173,10 @@
$this->getEntityInfo( $parserOutput ),
$options->getEditSection()
);
+ } else {
+ // If we don't have HTML, the ParserOutput in question
+ // shouldn't be cacheable.
+ $parserOutput->updateCacheExpiry( 0 );
}
//@todo: record sitelinks as iwlinks
diff --git
a/repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorTest.php
b/repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorTest.php
index e72d82e..aa96919 100644
---
a/repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorTest.php
+++
b/repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorTest.php
@@ -115,6 +115,21 @@
);
}
+
+ public function testGetParserOutput_dontGenerateHtml() {
+ $entityParserOutputGenerator =
$this->newEntityParserOutputGenerator();
+
+ $item = $this->newItem();
+ $timestamp = wfTimestamp( TS_MW );
+ $revision = new EntityRevision( $item, 13044, $timestamp );
+
+ $parserOutput = $entityParserOutputGenerator->getParserOutput(
$revision, $this->getParserOptions(), false );
+
+ $this->assertSame( '', $parserOutput->getText() );
+ // ParserOutput without HTML must not end up in the cache.
+ $this->assertFalse( $parserOutput->isCacheable() );
+ }
+
public function testTitleText_ItemHasNolabel() {
$entityParserOutputGenerator =
$this->newEntityParserOutputGenerator();
--
To view, visit https://gerrit.wikimedia.org/r/257864
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1db1b451e44168fe5e92b05a0b2539fc77864c5d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits