Add a message to localize strings like "2×" and use it in enhanced RC
[lhc/web/wiklou.git] / includes / changes / EnhancedChangesList.php
index 3aad60e..534e360 100644 (file)
@@ -32,11 +32,17 @@ class EnhancedChangesList extends ChangesList {
         */
        protected $rc_cache;
 
+       /**
+        * @var TemplateParser
+        */
+       protected $templateParser;
+
        /**
         * @param IContextSource|Skin $obj
+        * @param array $filterGroups Array of ChangesListFilterGroup objects (currently optional)
         * @throws MWException
         */
-       public function __construct( $obj ) {
+       public function __construct( $obj, array $filterGroups = [] ) {
                if ( $obj instanceof Skin ) {
                        // @todo: deprecate constructing with Skin
                        $context = $obj->getContext();
@@ -49,7 +55,7 @@ class EnhancedChangesList extends ChangesList {
                        $context = $obj;
                }
 
-               parent::__construct( $context );
+               parent::__construct( $context, $filterGroups );
 
                // message is set by the parent ChangesList class
                $this->cacheEntryFactory = new RCCacheEntryFactory(
@@ -57,6 +63,7 @@ class EnhancedChangesList extends ChangesList {
                        $this->message,
                        $this->linkRenderer
                );
+               $this->templateParser = new TemplateParser();
        }
 
        /**
@@ -236,8 +243,7 @@ class EnhancedChangesList extends ChangesList {
                        $text = $userlink;
                        $text .= $this->getLanguage()->getDirMark();
                        if ( $count > 1 ) {
-                               // @todo FIXME: Hardcoded '×'. Should be a message.
-                               $formattedCount = $this->getLanguage()->formatNum( $count ) . '×';
+                               $formattedCount = $this->msg( 'ntimes' )->numParams( $count )->escaped();
                                $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $formattedCount )->escaped();
                        }
                        array_push( $users, $text );
@@ -339,8 +345,7 @@ class EnhancedChangesList extends ChangesList {
 
                $this->rcCacheIndex++;
 
-               $templateParser = new TemplateParser();
-               return $templateParser->processTemplate(
+               return $this->templateParser->processTemplate(
                        'EnhancedChangesListGroup',
                        $templateParams
                );
@@ -711,6 +716,11 @@ class EnhancedChangesList extends ChangesList {
                if ( $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE ) {
                        // For categorizations we must swap the category title with the page title!
                        $pageTitle = Title::newFromID( $rc->getAttribute( 'rc_cur_id' ) );
+                       if ( !$pageTitle ) {
+                               // The page has been deleted, but the RC entry
+                               // deletion job has not run yet. Just skip.
+                               return '';
+                       }
                }
 
                $retVal = ' ' . $this->msg( 'parentheses' )