Merge "RCFilters: Style the Saved Links placeholder and add a title"
[lhc/web/wiklou.git] / includes / changes / EnhancedChangesList.php
index 3c76f32..b34a33f 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();
        }
 
        /**
@@ -177,7 +184,6 @@ class EnhancedChangesList extends ChangesList {
                        && $block[0]->mAttribs['rc_timestamp'] >= $block[0]->watched
                ) {
                        $tableClasses[] = 'mw-changeslist-line-watched';
-                       $tableClasses = array_merge( $tableClasses, $this->getHTMLClassesForFilters( $block[0] ) );
                } else {
                        $tableClasses[] = 'mw-changeslist-line-not-watched';
                }
@@ -340,8 +346,7 @@ class EnhancedChangesList extends ChangesList {
 
                $this->rcCacheIndex++;
 
-               $templateParser = new TemplateParser();
-               return $templateParser->processTemplate(
+               return $this->templateParser->processTemplate(
                        'EnhancedChangesListGroup',
                        $templateParams
                );
@@ -367,7 +372,7 @@ class EnhancedChangesList extends ChangesList {
                if ( $rcObj->watched
                        && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
                ) {
-                       $classes[] = [ 'mw-enhanced-watched' ];
+                       $classes[] = 'mw-enhanced-watched';
                }
                $classes = array_merge( $classes, $this->getHTMLClassesForFilters( $rcObj ) );
 
@@ -532,7 +537,7 @@ class EnhancedChangesList extends ChangesList {
                                $links['total-changes'] = $this->linkRenderer->makeKnownLink(
                                        $block0->getTitle(),
                                        new HtmlArmor( $nchanges[$n] ),
-                                       [],
+                                       [ 'class' => 'mw-changeslist-groupdiff' ],
                                        $queryParams + [
                                                'diff' => $currentRevision,
                                                'oldid' => $last->mAttribs['rc_last_oldid'],
@@ -542,7 +547,7 @@ class EnhancedChangesList extends ChangesList {
                                        $links['total-changes-since-last'] = $this->linkRenderer->makeKnownLink(
                                                        $block0->getTitle(),
                                                        new HtmlArmor( $sinceLastVisitMsg[$sinceLast] ),
-                                                       [],
+                                                       [ 'class' => 'mw-changeslist-groupdiff' ],
                                                        $queryParams + [
                                                                'diff' => $currentRevision,
                                                                'oldid' => $unvisitedOldid,
@@ -564,7 +569,7 @@ class EnhancedChangesList extends ChangesList {
                        $links['history'] = $this->linkRenderer->makeKnownLink(
                                        $block0->getTitle(),
                                        new HtmlArmor( $this->message['enhancedrc-history'] ),
-                                       [],
+                                       [ 'class' => 'mw-changeslist-history' ],
                                        $params
                                );
                }
@@ -712,6 +717,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' )
@@ -719,7 +729,7 @@ class EnhancedChangesList extends ChangesList {
                                        . $this->linkRenderer->makeKnownLink(
                                                $pageTitle,
                                                new HtmlArmor( $this->message['hist'] ),
-                                               [],
+                                               [ 'class' => 'mw-changeslist-history' ],
                                                $query
                                        ) )->escaped();
                return $retVal;