Encapsulate rc_params handling in RecentChange::parseParams
[lhc/web/wiklou.git] / includes / changes / ChangesList.php
index d3c44af..932006d 100644 (file)
@@ -36,6 +36,9 @@ class ChangesList extends ContextSource {
        protected $rclistOpen;
        protected $rcMoveIndex;
 
+       /** @var MapCacheLRU */
+       protected $watchingCache;
+
        /**
         * Changeslist constructor
         *
@@ -50,6 +53,7 @@ class ChangesList extends ContextSource {
                        $this->skin = $obj;
                }
                $this->preCacheMessages();
+               $this->watchingCache = new MapCacheLRU( 50 );
        }
 
        /**
@@ -63,7 +67,7 @@ class ChangesList extends ContextSource {
                $user = $context->getUser();
                $sk = $context->getSkin();
                $list = null;
-               if ( wfRunHooks( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) {
+               if ( Hooks::run( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) {
                        $new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
 
                        return $new ? new EnhancedChangesList( $context ) : new OldChangesList( $context );
@@ -176,7 +180,7 @@ class ChangesList extends ContextSource {
         * @param ResultWrapper|array $rows
         */
        public function initChangesListRows( $rows ) {
-               wfRunHooks( 'ChangesListInitRows', array( $this, $rows ) );
+               Hooks::run( 'ChangesListInitRows', array( $this, $rows ) );
        }
 
        /**
@@ -360,7 +364,7 @@ class ChangesList extends ContextSource {
                # RTL/LTR marker
                $articlelink .= $this->getLanguage()->getDirMark();
 
-               wfRunHooks( 'ChangesListInsertArticleLink',
+               Hooks::run( 'ChangesListInsertArticleLink',
                        array( &$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched ) );
 
                $s .= " $articlelink";
@@ -458,14 +462,14 @@ class ChangesList extends ContextSource {
         * @return string
         */
        protected function numberofWatchingusers( $count ) {
-               static $cache = array();
+               $cache = $this->watchingCache;
                if ( $count > 0 ) {
-                       if ( !isset( $cache[$count] ) ) {
-                               $cache[$count] = $this->msg( 'number_of_watching_users_RCview' )
-                                       ->numParams( $count )->escaped();
+                       if ( !$cache->has( $count ) ) {
+                               $cache->set( $count, $this->msg( 'number_of_watching_users_RCview' )
+                                       ->numParams( $count )->escaped() );
                        }
 
-                       return $cache[$count];
+                       return $cache->get( $count );
                } else {
                        return '';
                }