Merge "Disallow css attr() with url type"
[lhc/web/wiklou.git] / includes / specials / SpecialRecentchanges.php
index 8398989..cd3299c 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * A special page that lists last changes made to the wiki
  *
@@ -157,6 +159,9 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        if ( preg_match( '/^namespace=(\d+)$/', $bit, $m ) ) {
                                $opts['namespace'] = $m[1];
                        }
+                       if ( preg_match( '/^tagfilter=(.*)$/', $bit, $m ) ) {
+                               $opts['tagfilter'] = $m[1];
+                       }
                }
        }
 
@@ -279,7 +284,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
        }
 
        protected function getDB() {
-               return wfGetDB( DB_SLAVE, 'recentchanges' );
+               return wfGetDB( DB_REPLICA, 'recentchanges' );
        }
 
        public function outputFeedLinks() {
@@ -308,7 +313,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
        /**
         * Build and output the actual changes list.
         *
-        * @param array $rows Database rows
+        * @param ResultWrapper $rows Database rows
         * @param FormOptions $opts
         */
        public function outputChangesList( $rows, $opts ) {
@@ -324,12 +329,23 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                $list = ChangesList::newFromContext( $this->getContext() );
                $list->initChangesListRows( $rows );
 
+               $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
                $rclistOutput = $list->beginRecentChangesList();
                foreach ( $rows as $obj ) {
                        if ( $limit == 0 ) {
                                break;
                        }
                        $rc = RecentChange::newFromRow( $obj );
+
+                       # Skip CatWatch entries for hidden cats based on user preference
+                       if (
+                               $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE &&
+                               !$userShowHiddenCats &&
+                               $rc->getParam( 'hidden-cat' )
+                       ) {
+                               continue;
+                       }
+
                        $rc->counter = $counter++;
                        # Check if the page has been updated since the last visit
                        if ( $this->getConfig()->get( 'ShowUpdatedMarker' )
@@ -344,7 +360,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        if ( $showWatcherCount && $obj->rc_namespace >= 0 ) {
                                if ( !isset( $watcherCache[$obj->rc_namespace][$obj->rc_title] ) ) {
                                        $watcherCache[$obj->rc_namespace][$obj->rc_title] =
-                                               WatchedItemStore::getDefaultInstance()->countWatchers(
+                                               MediaWikiServices::getInstance()->getWatchedItemStore()->countWatchers(
                                                        new TitleValue( (int)$obj->rc_namespace, $obj->rc_title )
                                                );
                                }
@@ -781,4 +797,9 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
        public function isIncludable() {
                return true;
        }
+
+       protected function getCacheTTL() {
+               return 60 * 5;
+       }
+
 }