Remove obsolete RC_MOVE and RC_MOVE_OVER_REDIRECT rc types
[lhc/web/wiklou.git] / includes / changes / EnhancedChangesList.php
index 6c42601..0c073c6 100644 (file)
@@ -90,7 +90,6 @@ class EnhancedChangesList extends ChangesList {
        public function recentChangesLine( &$baseRC, $watched = false ) {
                wfProfileIn( __METHOD__ );
 
-               # If it's a new day, add the headline and flush the cache
                $date = $this->getLanguage()->userDate(
                        $baseRC->mAttribs['rc_timestamp'],
                        $this->getUser()
@@ -98,6 +97,7 @@ class EnhancedChangesList extends ChangesList {
 
                $ret = '';
 
+               # If it's a new day, add the headline and flush the cache
                if ( $date != $this->lastdate ) {
                        # Process current cache
                        $ret = $this->recentChangesBlock();
@@ -121,28 +121,37 @@ class EnhancedChangesList extends ChangesList {
         * @param RCCacheEntry $cacheEntry
         */
        protected function addCacheEntry( RCCacheEntry $cacheEntry ) {
+               $cacheGroupingKey = $this->makeCacheGroupingKey( $cacheEntry );
+
+               if ( !isset( $this->rc_cache[$cacheGroupingKey] ) ) {
+                       $this->rc_cache[$cacheGroupingKey] = array();
+               }
+
+               array_push( $this->rc_cache[$cacheGroupingKey], $cacheEntry );
+       }
+
+       /**
+        * @todo use rc_source to group, if set; fallback to rc_type
+        *
+        * @param RCCacheEntry $cacheEntry
+        *
+        * @return string
+        */
+       protected function makeCacheGroupingKey( RCCacheEntry $cacheEntry ) {
                $title = $cacheEntry->getTitle();
-               $secureName = $title->getPrefixedDBkey();
+               $cacheGroupingKey = $title->getPrefixedDBkey();
 
                $type = $cacheEntry->mAttribs['rc_type'];
 
-               if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
-                       # Use an @ character to prevent collision with page names
-                       $this->rc_cache['@@' . ( $this->rcMoveIndex++ )] = array( $cacheEntry );
-               } else {
-                       # Logs are grouped by type
-                       if ( $type == RC_LOG ) {
-                               $secureName = SpecialPage::getTitleFor(
-                                       'Log',
-                                       $cacheEntry->mAttribs['rc_log_type']
-                               )->getPrefixedDBkey();
-                       }
-                       if ( !isset( $this->rc_cache[$secureName] ) ) {
-                               $this->rc_cache[$secureName] = array();
-                       }
-
-                       array_push( $this->rc_cache[$secureName], $cacheEntry );
+               if ( $type == RC_LOG ) {
+                       // Group by log type
+                       $cacheGroupingKey = SpecialPage::getTitleFor(
+                               'Log',
+                               $cacheEntry->mAttribs['rc_log_type']
+                       )->getPrefixedDBkey();
                }
+
+               return $cacheGroupingKey;
        }
 
        /**
@@ -538,16 +547,12 @@ class EnhancedChangesList extends ChangesList {
 
                $r .= '<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
                # Flag and Timestamp
-               if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
-                       $r .= $this->recentChangesFlags( array() ); // no flags, but need the placeholders
-               } else {
-                       $r .= $this->recentChangesFlags( array(
-                               'newpage' => $type == RC_NEW,
-                               'minor' => $rcObj->mAttribs['rc_minor'],
-                               'unpatrolled' => $rcObj->unpatrolled,
-                               'bot' => $rcObj->mAttribs['rc_bot'],
-                       ) );
-               }
+               $r .= $this->recentChangesFlags( array(
+                       'newpage' => $type == RC_NEW,
+                       'minor' => $rcObj->mAttribs['rc_minor'],
+                       'unpatrolled' => $rcObj->unpatrolled,
+                       'bot' => $rcObj->mAttribs['rc_bot'],
+               ) );
                $r .= '&#160;' . $rcObj->timestamp . '&#160;</td><td>';
                # Article or log link
                if ( $logType ) {