Split out getSlotParserOutputUncached() method for the sake of profiling
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 11 Oct 2018 17:39:05 +0000 (10:39 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 11 Oct 2018 19:55:55 +0000 (19:55 +0000)
Change-Id: I553dba13486982b4530d290c84dc1f53b4df6ff9

includes/Revision/RenderedRevision.php

index 9cb20e0..6eee3c4 100644 (file)
@@ -31,6 +31,7 @@ use Psr\Log\NullLogger;
 use Revision;
 use Title;
 use User;
+use Content;
 use Wikimedia\Assert\Assert;
 
 /**
@@ -207,12 +208,7 @@ class RenderedRevision implements SlotRenderingProvider {
                                        'Access to the content has been suppressed for this audience'
                                );
                        } else {
-                               $output = $content->getParserOutput(
-                                       $this->title,
-                                       $this->revision->getId(),
-                                       $this->options,
-                                       $withHtml
-                               );
+                               $output = $this->getSlotParserOutputUncached( $content, $withHtml );
 
                                if ( $withHtml && !$output->hasText() ) {
                                        throw new LogicException(
@@ -232,6 +228,21 @@ class RenderedRevision implements SlotRenderingProvider {
                return $this->slotsOutput[$role];
        }
 
+       /**
+        * @note This method exist to make duplicate parses easier to see during profiling
+        * @param Content $content
+        * @param bool $withHtml
+        * @return ParserOutput
+        */
+       private function getSlotParserOutputUncached( Content $content, $withHtml ) {
+               return $content->getParserOutput(
+                       $this->title,
+                       $this->revision->getId(),
+                       $this->options,
+                       $withHtml
+               );
+       }
+
        /**
         * Updates the RevisionRecord after the revision has been saved. This can be used to discard
         * and cached ParserOutput so parser functions like {{REVISIONTIMESTAMP}} or {{REVISIONID}}