X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fchanges%2FChangesList.php;h=9567700914b62065debeda07f61ab9b986111faf;hb=de8f8c8248341c007ab6a9365a3c40614bcf04dc;hp=9ac6c326a98234a0cba89509b3406807917723ea;hpb=f5772f54126d489e31781d34db3db989992fa108;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php index 9ac6c326a9..9567700914 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -36,8 +36,8 @@ class ChangesList extends ContextSource { protected $rclistOpen; protected $rcMoveIndex; - /** @var MapCacheLRU */ - protected $watchingCache; + /** @var BagOStuff */ + protected $watchMsgCache; /** * Changeslist constructor @@ -53,7 +53,7 @@ class ChangesList extends ContextSource { $this->skin = $obj; } $this->preCacheMessages(); - $this->watchingCache = new MapCacheLRU( 50 ); + $this->watchMsgCache = new HashBagOStuff( array( 'maxKeys' => 50 ) ); } /** @@ -364,12 +364,24 @@ class ChangesList extends ContextSource { } /** - * @param string $s HTML to update + * @param string $s Article link will be appended to this string, in place. * @param RecentChange $rc * @param bool $unpatrolled * @param bool $watched + * @deprecated since 1.27, use getArticleLink instead. */ - public function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) { + public function insertArticleLink( &$s, RecentChange $rc, $unpatrolled, $watched ) { + $s .= $this->getArticleLink( $rc, $unpatrolled, $watched ); + } + + /** + * @param RecentChange $rc + * @param bool $unpatrolled + * @param bool $watched + * @return string HTML + * @since 1.26 + */ + public function getArticleLink( &$rc, $unpatrolled, $watched ) { $params = array(); if ( $rc->getTitle()->isRedirect() ) { $params = array( 'redirect' => 'no' ); @@ -389,23 +401,12 @@ class ChangesList extends ContextSource { # RTL/LTR marker $articlelink .= $this->getLanguage()->getDirMark(); + # TODO: Deprecate the $s argument, it seems happily unused. + $s = ''; Hooks::run( 'ChangesListInsertArticleLink', array( &$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched ) ); - $s .= " $articlelink"; - } - - /** - * @param RecentChange $rc - * @param bool $unpatrolled - * @param bool $watched - * @return string - * @since 1.26 - */ - public function getArticleLink( RecentChange $rc, $unpatrolled, $watched ) { - $s = ''; - $this->insertArticleLink( $s, $rc, $unpatrolled, $watched ); - return $s; + return "{$s} {$articlelink}"; } /** @@ -500,17 +501,17 @@ class ChangesList extends ContextSource { * @return string */ protected function numberofWatchingusers( $count ) { - $cache = $this->watchingCache; - if ( $count > 0 ) { - if ( !$cache->has( $count ) ) { - $cache->set( $count, $this->msg( 'number_of_watching_users_RCview' ) - ->numParams( $count )->escaped() ); - } - - return $cache->get( $count ); - } else { + if ( $count <= 0 ) { return ''; } + $cache = $this->watchMsgCache; + $that = $this; + return $cache->getWithSetCallback( $count, $cache::TTL_INDEFINITE, + function () use ( $that, $count ) { + return $that->msg( 'number_of_watching_users_RCview' ) + ->numParams( $count )->escaped(); + } + ); } /**