Fix OutputPage::parseInternal() by stripping <div> wrapper
[lhc/web/wiklou.git] / includes / changes / ChangesList.php
index 57c4026..fea31b4 100644 (file)
@@ -44,7 +44,7 @@ class ChangesList extends ContextSource {
        /** @var callable */
        protected $changeLinePrefixer;
 
-       /** @var BagOStuff */
+       /** @var MapCacheLRU */
        protected $watchMsgCache;
 
        /**
@@ -72,7 +72,7 @@ class ChangesList extends ContextSource {
                        $this->skin = $obj;
                }
                $this->preCacheMessages();
-               $this->watchMsgCache = new HashBagOStuff( [ 'maxKeys' => 50 ] );
+               $this->watchMsgCache = new MapCacheLRU( 50 );
                $this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
                $this->filterGroups = $filterGroups;
        }
@@ -107,7 +107,7 @@ class ChangesList extends ContextSource {
         *
         * @param RecentChange &$rc Passed by reference
         * @param bool $watched (default false)
-        * @param int $linenumber (default null)
+        * @param int|null $linenumber (default null)
         *
         * @return string|bool
         */
@@ -249,7 +249,7 @@ class ChangesList extends ContextSource {
         * bot edit, or unpatrolled edit. In English it typically contains "N", "m", "b", or "!".
         *
         * @param string $flag One key of $wgRecentChangesFlags
-        * @param IContextSource $context
+        * @param IContextSource|null $context
         * @return string HTML
         */
        public static function flag( $flag, IContextSource $context = null ) {
@@ -310,7 +310,7 @@ class ChangesList extends ContextSource {
         *
         * @param int $old Number of bytes
         * @param int $new Number of bytes
-        * @param IContextSource $context
+        * @param IContextSource|null $context
         * @return string
         */
        public static function showCharacterDifference( $old, $new, IContextSource $context = null ) {
@@ -363,7 +363,7 @@ class ChangesList extends ContextSource {
         * Format the character difference of one or several changes.
         *
         * @param RecentChange $old
-        * @param RecentChange $new Last change to use, if not provided, $old will be used
+        * @param RecentChange|null $new Last change to use, if not provided, $old will be used
         * @return string HTML fragment
         */
        public function formatCharacterDifference( RecentChange $old, RecentChange $new = null ) {
@@ -531,10 +531,10 @@ class ChangesList extends ContextSource {
        public function getTimestamp( $rc ) {
                // @todo FIXME: Hard coded ". .". Is there a message for this? Should there be?
                return $this->message['semicolon-separator'] . '<span class="mw-changeslist-date">' .
-                       $this->getLanguage()->userTime(
+                       htmlspecialchars( $this->getLanguage()->userTime(
                                $rc->mAttribs['rc_timestamp'],
                                $this->getUser()
-                       ) . '</span> <span class="mw-changeslist-separator">. .</span> ';
+                       ) . '</span> <span class="mw-changeslist-separator">. .</span> ';
        }
 
        /**
@@ -602,10 +602,9 @@ class ChangesList extends ContextSource {
                if ( $count <= 0 ) {
                        return '';
                }
-               $cache = $this->watchMsgCache;
-               return $cache->getWithSetCallback(
-                       $cache->makeKey( 'watching-users-msg', $count ),
-                       $cache::TTL_INDEFINITE,
+
+               return $this->watchMsgCache->getWithSetCallback(
+                       "watching-users-msg:$count",
                        function () use ( $count ) {
                                return $this->msg( 'number_of_watching_users_RCview' )
                                        ->numParams( $count )->escaped();
@@ -628,7 +627,7 @@ class ChangesList extends ContextSource {
         * field of this revision, if it's marked as deleted.
         * @param RCCacheEntry|RecentChange $rc
         * @param int $field
-        * @param User $user User object to check, or null to use $wgUser
+        * @param User|null $user User object to check, or null to use $wgUser
         * @return bool
         */
        public static function userCan( $rc, $field, User $user = null ) {
@@ -652,7 +651,8 @@ class ChangesList extends ContextSource {
                }
        }
 
-       /** Inserts a rollback link
+       /**
+        * Insert a rollback link
         *
         * @param string &$s
         * @param RecentChange &$rc
@@ -661,15 +661,14 @@ class ChangesList extends ContextSource {
                if ( $rc->mAttribs['rc_type'] == RC_EDIT
                        && $rc->mAttribs['rc_this_oldid']
                        && $rc->mAttribs['rc_cur_id']
+                       && $rc->getAttribute( 'page_latest' ) == $rc->mAttribs['rc_this_oldid']
                ) {
-                       $page = $rc->getTitle();
-                       /** Check for rollback and edit permissions, disallow special pages, and only
+                       $title = $rc->getTitle();
+                       /** Check for rollback permissions, disallow special pages, and only
                         * show a link on the top-most revision */
-                       if ( $this->getUser()->isAllowed( 'rollback' )
-                               && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid']
-                       ) {
+                       if ( $title->quickUserCan( 'rollback', $this->getUser() ) ) {
                                $rev = new Revision( [
-                                       'title' => $page,
+                                       'title' => $title,
                                        'id' => $rc->mAttribs['rc_this_oldid'],
                                        'user' => $rc->mAttribs['rc_user'],
                                        'user_text' => $rc->mAttribs['rc_user_text'],