Merge "resourceloader: Clean up UserModule to be more like UserGroupsModule"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 3 Mar 2015 17:11:59 +0000 (17:11 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 3 Mar 2015 17:11:59 +0000 (17:11 +0000)
includes/MessageBlobStore.php
includes/api/ApiFeedWatchlist.php
languages/Language.php
resources/src/mediawiki.less/mediawiki.ui/mixins.less
resources/src/mediawiki/mediawiki.user.js

index 8de9cc9..c384188 100644 (file)
@@ -93,7 +93,6 @@ class MessageBlobStore {
 
                try {
                        $dbw = wfGetDB( DB_MASTER );
-                       $dbw->startAtomic( __METHOD__ );
                        $success = $dbw->insert( 'msg_resource', array(
                                        'mr_lang' => $lang,
                                        'mr_resource' => $name,
@@ -128,7 +127,6 @@ class MessageBlobStore {
                                        );
                                }
                        }
-                       $dbw->endAtomic( __METHOD__ );
                } catch ( DBError $e ) {
                        wfDebug( __METHOD__ . " failed to update DB: $e\n" );
                }
index 561ff3b..bfa750b 100644 (file)
@@ -117,7 +117,10 @@ class ApiFeedWatchlist extends ApiBase {
 
                        $feedItems = array();
                        foreach ( (array)$data['query']['watchlist'] as $info ) {
-                               $feedItems[] = $this->createFeedItem( $info );
+                               $feedItem = $this->createFeedItem( $info );
+                               if ( $feedItem ) {
+                                       $feedItems[] = $feedItem;
+                               }
                        }
 
                        $msg = wfMessage( 'watchlist' )->inContentLanguage()->text();
@@ -166,10 +169,22 @@ class ApiFeedWatchlist extends ApiBase {
        private function createFeedItem( $info ) {
                $titleStr = $info['title'];
                $title = Title::newFromText( $titleStr );
+               $curidParam = array();
+               if ( !$title || $title->isExternal() ) {
+                       // Probably a formerly-valid title that's now conflicting with an
+                       // interwiki prefix or the like.
+                       if ( isset( $info['pageid'] ) ) {
+                               $title = Title::newFromId( $info['pageid'] );
+                               $curidParam = array( 'curid' => $info['pageid'] );
+                       }
+                       if ( !$title || $title->isExternal() ) {
+                               return null;
+                       }
+               }
                if ( isset( $info['revid'] ) ) {
                        $titleUrl = $title->getFullURL( array( 'diff' => $info['revid'] ) );
                } else {
-                       $titleUrl = $title->getFullURL();
+                       $titleUrl = $title->getFullURL( $curidParam );
                }
                $comment = isset( $info['comment'] ) ? $info['comment'] : null;
 
index d203c0f..0d4eb13 100644 (file)
@@ -587,7 +587,7 @@ class Language {
                global $wgExtraGenderNamespaces;
 
                $ns = $wgExtraGenderNamespaces +
-                       self::$dataCache->getItem( $this->mCode, 'namespaceGenderAliases' );
+                       (array)self::$dataCache->getItem( $this->mCode, 'namespaceGenderAliases' );
 
                return isset( $ns[$index][$gender] ) ? $ns[$index][$gender] : $this->getNsText( $index );
        }
index a51fe9c..92d0a76 100644 (file)
 
        &:hover,
        &:focus {
-               // lessphp doesn't implement tint, see above
-               // color: tint(@textColor, 20%);
-               color: mix(#fff, @textColor, 20%);
+               color: @textColor;
        }
 
        &:active,
index 04d9ec6..b777cd3 100644 (file)
@@ -3,13 +3,9 @@
  * @singleton
  */
 ( function ( mw, $ ) {
-       var user, i,
+       var i,
                deferreds = {},
-               byteToHex = [],
-               // Extend the skeleton mw.user from mediawiki.js
-               // This is kind of ugly but we're stuck with this for b/c reasons
-               options = mw.user.options || new mw.Map(),
-               tokens = mw.user.tokens || new mw.Map();
+               byteToHex = [];
 
        /**
         * Get the current user's groups or rights
@@ -51,9 +47,8 @@
                byteToHex[i] = ( i + 256 ).toString( 16 ).slice( 1 );
        }
 
-       mw.user = user = {
-               options: options,
-               tokens: tokens,
+       // mw.user with the properties options and tokens gets defined in mediawiki.js.
+       $.extend( mw.user, {
 
                /**
                 * Generate a random user session ID.
                 */
                getRegistration: function () {
                        var registration = mw.config.get( 'wgUserRegistration' );
-                       if ( user.isAnon() ) {
+                       if ( mw.user.isAnon() ) {
                                return false;
                        }
                        if ( registration === null ) {
                 * @return {boolean}
                 */
                isAnon: function () {
-                       return user.getName() === null;
+                       return mw.user.getName() === null;
                },
 
                /**
                sessionId: function () {
                        var sessionId = $.cookie( 'mediaWiki.user.sessionId' );
                        if ( sessionId === undefined || sessionId === null ) {
-                               sessionId = user.generateRandomSessionId();
+                               sessionId = mw.user.generateRandomSessionId();
                                $.cookie( 'mediaWiki.user.sessionId', sessionId, { expires: null, path: '/' } );
                        }
                        return sessionId;
                 * @return {string} User name or random session ID
                 */
                id: function () {
-                       return user.getName() || user.sessionId();
+                       return mw.user.getName() || mw.user.sessionId();
                },
 
                /**
                getRights: function ( callback ) {
                        return getUserInfo( 'rights' ).done( callback );
                }
-       };
+       } );
 
 }( mediaWiki, jQuery ) );