jenkins-bot has submitted this change and it was merged.

Change subject: (bug 57746) Allow entity pages to use parser cache
......................................................................


(bug 57746) Allow entity pages to use parser cache

This fragments the parser cache by user language.

Change-Id: I1e68bace119a4adcf822e4c13ca8d5806bd27a51
---
M repo/includes/content/EntityContent.php
M repo/includes/content/EntityHandler.php
2 files changed, 22 insertions(+), 9 deletions(-)

Approvals:
  Tobias Gritschacher: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/content/EntityContent.php 
b/repo/includes/content/EntityContent.php
index 14a9cc1..1e8f57e 100644
--- a/repo/includes/content/EntityContent.php
+++ b/repo/includes/content/EntityContent.php
@@ -121,6 +121,13 @@
 
        /**
         * Returns a ParserOutput object containing the HTML.
+        * The actual work of generating a ParserOutput object is done by 
calling
+        * EntityView::getParserOutput().
+        *
+        * @note: this calls ParserOutput::recordOption( 'userlang' ) to split 
the cache
+        * by user language.
+        *
+        * @see Content::getParserOutput
         *
         * @since 0.1
         *
@@ -155,7 +162,14 @@
                        $entityInfoBuilder,
                        $entityContentFactory
                );
-               return $entityView->getParserOutput( 
$this->getEntityRevision(), $options, $generateHtml );
+
+               $output = $entityView->getParserOutput( 
$this->getEntityRevision(), $options, $generateHtml );
+
+               // Since the output depends on the user language, we must make 
sure
+               // ParserCache::getKey() includes it in the cache key.
+               $output->recordOption( 'userlang' );
+
+               return $output;
        }
 
        /**
diff --git a/repo/includes/content/EntityHandler.php 
b/repo/includes/content/EntityHandler.php
index 9c25746..3cbd918 100644
--- a/repo/includes/content/EntityHandler.php
+++ b/repo/includes/content/EntityHandler.php
@@ -165,20 +165,20 @@
        }
 
        /**
-        * Returns false to indicate that the parser cache should not be used 
for data items.
-        * The html representation of Items depends on the user language, 
splitting the parser
-        * cache by user language is currently problematic and would need some 
core changes.
+        * Returns true to indicate that the parser cache can be used for data 
items.
         *
-        * @note: see also note on getPageLanguage()
+        * @note: The html representation of entities depends on the user 
language, so
+        * EntityContent::getParserOutput needs to make sure 
ParserOutput::recordOption( 'userlang' )
+        * is called to split the cache by user language.
         *
         * @see ContentHandler::isParserCacheSupported
         *
         * @since 0.1
         *
-        * @return bool false
+        * @return bool true
         */
        public function isParserCacheSupported() {
-               return false;
+               return true;
        }
 
        /**
@@ -207,8 +207,7 @@
         * currently doesn't support that.
         *
         * @note: in several places in mediawiki, most importantly the parser 
cache, getPageLanguage
-        * is used in places where getPageViewLanguage would be more 
appropriate. This is the reason that
-        * isParserCacheSupported() is overridden to return false.
+        * is used in places where getPageViewLanguage would be more 
appropriate.
         *
         * @param Title        $title the page to determine the language for.
         * @param Content|null $content the page's content, if you have it 
handy, to avoid reloading it.

-- 
To view, visit https://gerrit.wikimedia.org/r/98511
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1e68bace119a4adcf822e4c13ca8d5806bd27a51
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Henning Snater <henning.sna...@wikimedia.de>
Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com>
Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to