ContribsPager: Use one TemplateParser instance
authorKunal Mehta <legoktm@member.fsf.org>
Tue, 16 May 2017 22:49:03 +0000 (15:49 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Tue, 16 May 2017 22:49:51 +0000 (15:49 -0700)
TemplateParser has an instance cache to avoid reading from APC
repeatedly for the same template, but that only works if the code uses
the same TemplateParser object.

Change-Id: I59e37306c5a3216cf8ed3bfef9c80d50934a9146

includes/specials/pagers/ContribsPager.php

index 7d303de..ea93f1f 100644 (file)
@@ -45,6 +45,11 @@ class ContribsPager extends ReverseChronologicalPager {
         */
        protected $mParentLens;
 
+       /**
+        * @var TemplateParser
+        */
+       protected $templateParser;
+
        function __construct( IContextSource $context, array $options ) {
                parent::__construct( $context );
 
@@ -80,6 +85,7 @@ class ContribsPager extends ReverseChronologicalPager {
                // queries should use a regular replica DB since the lookup pattern is not all by user.
                $this->mDbSecondary = wfGetDB( DB_REPLICA ); // any random replica DB
                $this->mDb = wfGetDB( DB_REPLICA, 'contributions' );
+               $this->templateParser = new TemplateParser();
        }
 
        function getDefaultQuery() {
@@ -516,8 +522,7 @@ class ContribsPager extends ReverseChronologicalPager {
                                        $this->msg( 'rev-deleted-user-contribs' )->escaped();
                        }
 
-                       $templateParser = new TemplateParser();
-                       $ret = $templateParser->processTemplate(
+                       $ret = $this->templateParser->processTemplate(
                                'SpecialContributionsLine',
                                $templateParams
                        );