Merge "parserTest: Remove mention of non-existent 'noxml' option"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 24 Mar 2016 19:59:56 +0000 (19:59 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 24 Mar 2016 19:59:56 +0000 (19:59 +0000)
39 files changed:
includes/Html.php
includes/MergeHistory.php
includes/MimeMagic.php
includes/OutputPage.php
includes/TemplateParser.php
includes/Title.php
includes/WatchedItemStore.php
includes/api/ApiBase.php
includes/api/ApiMain.php
includes/api/ApiResult.php
includes/filerepo/FileRepo.php
includes/htmlform/VFormHTMLForm.php
includes/libs/MWMessagePack.php
includes/media/DjVu.php
includes/media/WebP.php
includes/page/Article.php
includes/poolcounter/PoolCounter.php
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderRawFileModule.php
includes/resourceloader/ResourceLoaderUserTokensModule.php
includes/site/HashSiteStore.php
includes/specials/SpecialActiveusers.php
includes/specials/SpecialEditWatchlist.php
includes/specials/SpecialWatchlist.php
includes/utils/BatchRowIterator.php
includes/utils/MWCryptHash.php
includes/utils/ZipDirectoryReader.php
resources/src/jquery/jquery.suggestions.js
resources/src/mediawiki.special/mediawiki.special.userlogin.common.css
resources/src/mediawiki.special/mediawiki.special.userlogin.login.css
resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
tests/parser/parserTests.txt
tests/phpunit/MediaWikiTestCase.php
tests/phpunit/includes/HtmlTest.php
tests/phpunit/includes/OutputPageTest.php
tests/phpunit/includes/WatchedItemStoreUnitTest.php
tests/phpunit/includes/XmlTest.php
tests/phpunit/includes/specials/SpecialEditWatchlistTest.php [new file with mode: 0644]
tests/phpunit/includes/specials/SpecialWatchlistTest.php [new file with mode: 0644]

index 3b36039..890beb0 100644 (file)
@@ -216,7 +216,7 @@ class Html {
                if ( in_array( $element, self::$voidElements ) ) {
                        if ( $wgWellFormedXml ) {
                                // Silly XML.
-                               return substr( $start, 0, -1 ) . ' />';
+                               return substr( $start, 0, -1 ) . '/>';
                        }
                        return $start;
                } else {
index a92056d..441fe9e 100644 (file)
@@ -51,7 +51,7 @@ class MergeHistory {
        /** @var string SQL WHERE condition that selects source revisions to insert into destination */
        protected $timeWhere;
 
-       /** @var MWTimestamp|boolean Timestamp upto which history from the source will be merged */
+       /** @var MWTimestamp|bool Timestamp upto which history from the source will be merged */
        protected $timestampLimit;
 
        /** @var integer Number of revisions merged (for Special:MergeHistory success message) */
@@ -61,7 +61,7 @@ class MergeHistory {
         * MergeHistory constructor.
         * @param Title $source Page from which history will be merged
         * @param Title $dest Page to which history will be merged
-        * @param string|boolean $timestamp Timestamp up to which history from the source will be merged
+        * @param string|bool $timestamp Timestamp up to which history from the source will be merged
         */
        public function __construct( Title $source, Title $dest, $timestamp = false ) {
                // Save the parameters
index aedfd8f..a432d44 100644 (file)
@@ -645,7 +645,7 @@ class MimeMagic {
                        throw new MWException(
                                "Seeking $tailLength bytes from EOF failed in " . __METHOD__ );
                }
-               $tail = fread( $f, $tailLength );
+               $tail = $tailLength ? fread( $f, $tailLength ) : '';
                fclose( $f );
 
                wfDebug( __METHOD__ . ": analyzing head and tail of $file for magic numbers.\n" );
index 6949f8b..0c3d609 100644 (file)
@@ -460,7 +460,7 @@ class OutputPage extends ContextSource {
         * @param string $script Raw HTML
         */
        function addScript( $script ) {
-               $this->mScripts .= $script . "\n";
+               $this->mScripts .= $script;
        }
 
        /**
@@ -516,7 +516,7 @@ class OutputPage extends ContextSource {
         * @param string $script JavaScript text, no "<script>" tags
         */
        public function addInlineScript( $script ) {
-               $this->mScripts .= Html::inlineScript( "\n$script\n" ) . "\n";
+               $this->mScripts .= Html::inlineScript( $script );
        }
 
        /**
@@ -2942,7 +2942,7 @@ class OutputPage extends ContextSource {
         * @return string HTML fragment
         */
        function getHeadScripts() {
-               return $this->getInlineHeadScripts() . "\n" . $this->getExternalHeadScripts();
+               return $this->getInlineHeadScripts() . $this->getExternalHeadScripts();
        }
 
        /**
@@ -3624,7 +3624,7 @@ class OutputPage extends ContextSource {
                        # If wanted, and the interface is right-to-left, flip the CSS
                        $style_css = CSSJanus::transform( $style_css, true, false );
                }
-               $this->mInlineStyles .= Html::inlineStyle( $style_css ) . "\n";
+               $this->mInlineStyles .= Html::inlineStyle( $style_css );
        }
 
        /**
@@ -3676,7 +3676,7 @@ class OutputPage extends ContextSource {
                        if ( $this->getLanguage()->getDir() !== $wgContLang->getDir() ) {
                                $previewedCSS = CSSJanus::transform( $previewedCSS, true, false );
                        }
-                       $otherTags[] = Html::inlineStyle( $previewedCSS ) . "\n";
+                       $otherTags[] = Html::inlineStyle( $previewedCSS );
                } else {
                        // Load the user styles normally
                        $moduleStyles[] = 'user';
@@ -3715,7 +3715,7 @@ class OutputPage extends ContextSource {
                        ResourceLoaderModule::TYPE_STYLES
                );
                // Add normal styles added through addStyle()/addInlineStyle() here
-               $links[] = implode( "\n", $this->buildCssLinksArray() ) . $this->mInlineStyles;
+               $links[] = implode( '', $this->buildCssLinksArray() ) . $this->mInlineStyles;
                // Add marker tag to mark the place where the client-side
                // loader should inject dynamic styles
                // We use a <meta> tag with a made-up name for this because that's valid HTML
index 6420dc7..20142a7 100644 (file)
@@ -38,7 +38,7 @@ class TemplateParser {
 
        /**
         * @param string $templateDir
-        * @param boolean $forceRecompile
+        * @param bool $forceRecompile
         */
        public function __construct( $templateDir = null, $forceRecompile = false ) {
                $this->templateDir = $templateDir ?: __DIR__ . '/templates';
index 1a9ee39..8bafe26 100644 (file)
@@ -145,7 +145,7 @@ class Title implements LinkTarget {
        /** @var bool The (string) language code of the page's language and content code. */
        private $mPageLanguage = false;
 
-       /** @var string|boolean|null The page language code from the database, null if not saved in
+       /** @var string|bool|null The page language code from the database, null if not saved in
         * the database or false if not loaded, yet. */
        private $mDbPageLanguage = false;
 
@@ -2452,8 +2452,8 @@ class Title implements LinkTarget {
 
        /**
         * Can $user perform $action on this page? This is an internal function,
-        * which checks ONLY that previously checked by userCan (i.e. it leaves out
-        * checks on wfReadOnly() and blocks)
+        * with multiple levels of checks depending on performance needs; see $rigor below.
+        * It does not check wfReadOnly().
         *
         * @param string $action Action that permission needs to be checked for
         * @param User $user User to check
@@ -4627,7 +4627,7 @@ class Title implements LinkTarget {
         * to true in LocalSettings.php, otherwise returns false. If there is no language saved in
         * the db, it will return NULL.
         *
-        * @return string|null|boolean
+        * @return string|null|bool
         */
        private function getDbPageLanguageCode() {
                global $wgPageLanguageUseDB;
index 20ec592..4eea54d 100644 (file)
@@ -12,6 +12,9 @@ use Wikimedia\Assert\Assert;
  */
 class WatchedItemStore {
 
+       const SORT_DESC = 'DESC';
+       const SORT_ASC = 'ASC';
+
        /**
         * @var LoadBalancer
         */
@@ -494,18 +497,34 @@ class WatchedItemStore {
         * @param User $user
         * @param array $options Allowed keys:
         *        'forWrite' => bool defaults to false
+        *        'sort' => string optional sorting by namespace ID and title
+        *                     one of the self::SORT_* constants
         *
         * @return WatchedItem[]
         */
        public function getWatchedItemsForUser( User $user, array $options = [] ) {
                $options += [ 'forWrite' => false ];
 
+               $dbOptions = [];
+               if ( array_key_exists( 'sort', $options ) ) {
+                       Assert::parameter(
+                               ( in_array( $options['sort'], [ self::SORT_ASC, self::SORT_DESC ] ) ),
+                               '$options[\'sort\']',
+                               'must be SORT_ASC or SORT_DESC'
+                       );
+                       $dbOptions['ORDER BY'] = [
+                               "wl_namespace {$options['sort']}",
+                               "wl_title {$options['sort']}"
+                       ];
+               }
                $db = $this->getConnection( $options['forWrite'] ? DB_MASTER : DB_SLAVE );
+
                $res = $db->select(
                        'watchlist',
                        [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
                        [ 'wl_user' => $user->getId() ],
-                       __METHOD__
+                       __METHOD__,
+                       $dbOptions
                );
                $this->reuseConnection( $db );
 
index 7944167..1c20229 100644 (file)
@@ -437,7 +437,7 @@ abstract class ApiBase extends ContextSource {
         *    RFC 7232 § 2.2 for semantics.
         *  - etag: Return an entity-tag representing the state of all resources involved
         *    in the request. Quotes must be included. See RFC 7232 § 2.3 for semantics.
-        * @return string|boolean|null As described above, or null if no value is available.
+        * @return string|bool|null As described above, or null if no value is available.
         */
        public function getConditionalRequestData( $condition ) {
                return null;
index df3f516..63b79ac 100644 (file)
@@ -711,7 +711,7 @@ class ApiMain extends ApiBase {
 
        /**
         * Send caching headers
-        * @param boolean $isError Whether an error response is being output
+        * @param bool $isError Whether an error response is being output
         * @since 1.26 added $isError parameter
         */
        protected function sendCacheHeaders( $isError ) {
index 3436320..5d5c829 100644 (file)
@@ -1150,7 +1150,7 @@ class ApiResult implements ApiSerializable {
         * the API.
         *
         * @param array $vars
-        * @param boolean $forceHash
+        * @param bool $forceHash
         * @return array
         */
        public static function addMetadataToResultVars( $vars, $forceHash = true ) {
index 1565b49..15821ea 100644 (file)
@@ -1906,7 +1906,7 @@ class FileRepo {
 
        /**
         * Returns whether or not storage is SHA-1 based
-        * @return boolean
+        * @return bool
         */
        public function hasSha1Storage() {
                return $this->hasSha1Storage;
@@ -1914,7 +1914,7 @@ class FileRepo {
 
        /**
         * Returns whether or not repo supports having originals SHA-1s in the thumb URLs
-        * @return boolean
+        * @return bool
         */
        public function supportsSha1URLs() {
                return $this->supportsSha1URLs;
index f0f961e..c446615 100644 (file)
@@ -27,7 +27,7 @@
 class VFormHTMLForm extends HTMLForm {
        /**
         * Wrapper and its legend are never generated in VForm mode.
-        * @var boolean
+        * @var bool
         */
        protected $mWrapperLegend = false;
 
index cd9aad8..a9da366 100644 (file)
@@ -33,7 +33,7 @@
  * @file
  */
 class MWMessagePack {
-       /** @var boolean|null Whether current system is bigendian. **/
+       /** @var bool|null Whether current system is bigendian. **/
        public static $bigendian = null;
 
        /**
index d4ef8a8..cd249a8 100644 (file)
@@ -419,7 +419,8 @@ class DjVuHandler extends ImageHandler {
                                }
 
                                return [ 'pageCount' => $count, 'dimensionsByPage' => $dimsByPage ];
-                       }
+                       },
+                       [ 'pcTTL' => WANObjectCache::TTL_INDEFINITE ]
                );
        }
 
index 8fda751..6a01e87 100644 (file)
@@ -154,7 +154,7 @@ class WebPHandler extends BitmapHandler {
        /**
         * Decodes a lossy chunk header
         * @param string $header Header string
-        * @return boolean|array See WebPHandler::decodeHeader
+        * @return bool|array See WebPHandler::decodeHeader
         */
        protected static function decodeLossyChunkHeader( $header ) {
                // Bytes 0-3 are 'VP8 '
@@ -180,7 +180,7 @@ class WebPHandler extends BitmapHandler {
        /**
         * Decodes a lossless chunk header
         * @param string $header Header string
-        * @return boolean|array See WebPHandler::decodeHeader
+        * @return bool|array See WebPHandler::decodeHeader
         */
        public static function decodeLosslessChunkHeader( $header ) {
                // Bytes 0-3 are 'VP8L'
@@ -205,7 +205,7 @@ class WebPHandler extends BitmapHandler {
        /**
         * Decodes an extended chunk header
         * @param string $header Header string
-        * @return boolean|array See WebPHandler::decodeHeader
+        * @return bool|array See WebPHandler::decodeHeader
         */
        public static function decodeExtendedChunkHeader( $header ) {
                // Bytes 0-3 are 'VP8X'
index b561407..d57d3fd 100644 (file)
@@ -1574,7 +1574,7 @@ class Article implements Page {
                                [],
                                // Automatically append redirect=no to each link, since most of them are
                                // redirect pages themselves.
-                               [ 'redirect' => 'no' ],
+                               $title->isRedirect() ? [ 'redirect' => 'no' ] : [],
                                ( $forceKnown ? [ 'known', 'noclasses' ] : [] )
                        ) . '</li>';
                }
index 1ec14aa..acdbd81 100644 (file)
@@ -71,11 +71,11 @@ abstract class PoolCounter {
        protected $timeout;
 
        /**
-        * @var boolean Whether the key is a "might wait" key
+        * @var bool Whether the key is a "might wait" key
         */
        private $isMightWaitKey;
        /**
-        * @var boolean Whether this process holds a "might wait" lock key
+        * @var bool Whether this process holds a "might wait" lock key
         */
        private static $acquiredMightWaitKey = 0;
 
index c689979..0aa08be 100644 (file)
@@ -88,7 +88,7 @@ class ResourceLoader implements LoggerAwareInterface {
        private $logger;
 
        /** @var string JavaScript / CSS pragma to disable minification. **/
-       const FILTER_NOMIN = ' /* @nomin */ ';
+       const FILTER_NOMIN = '/*@nomin*/';
 
        /**
         * Load information stored in the database about modules.
@@ -1362,8 +1362,8 @@ MESSAGE;
         * @return string
         */
        public static function makeLoaderConditionalScript( $script ) {
-               return "(window.RLQ = window.RLQ || []).push(function () {\n" .
-                       trim( $script ) . "\n} );";
+               return '(window.RLQ=window.RLQ||[]).push(function(){' .
+                       trim( $script ) . '});';
        }
 
        /**
@@ -1379,8 +1379,8 @@ MESSAGE;
                $js = self::makeLoaderConditionalScript( $script );
                return new WrappedString(
                        Html::inlineScript( $js ),
-                       "<script>(window.RLQ = window.RLQ || []).push(function () {\n",
-                       "\n} );</script>"
+                       '<script>(window.RLQ=window.RLQ||[]).push(function(){',
+                       '});</script>'
                );
        }
 
@@ -1396,7 +1396,7 @@ MESSAGE;
                        'mw.config.set',
                        [ $configuration ],
                        ResourceLoader::inDebugMode()
-               ) . ResourceLoader::FILTER_NOMIN;
+               );
        }
 
        /**
index d9005fa..beab53e 100644 (file)
@@ -31,7 +31,7 @@ class ResourceLoaderRawFileModule extends ResourceLoaderFileModule {
        /**
         * Enable raw mode to omit mw.loader.state() call as mw.loader
         * does not yet exist when these modules execute.
-        * @var boolean
+        * @var bool
         */
        protected $raw = true;
 
index bf4e8a7..cea1f39 100644 (file)
@@ -54,8 +54,7 @@ class ResourceLoaderUserTokensModule extends ResourceLoaderModule {
        /**
         * Generate the JavaScript content of this module.
         *
-        * Add '@nomin' annotation to prevent the module's contents from getting
-        * cached (T84960).
+        * Add FILTER_NOMIN annotation to prevent needless minification and caching (T84960).
         *
         * @param ResourceLoaderContext $context
         * @return string
index 0d0e448..198d331 100644 (file)
@@ -50,7 +50,7 @@ class HashSiteStore implements SiteStore {
         *
         * @param Site $site
         *
-        * @return boolean Success indicator
+        * @return bool Success indicator
         */
        public function saveSite( Site $site ) {
                $this->sites[$site->getGlobalId()] = $site;
@@ -65,7 +65,7 @@ class HashSiteStore implements SiteStore {
         *
         * @param Site[] $sites
         *
-        * @return boolean Success indicator
+        * @return bool Success indicator
         */
        public function saveSites( array $sites ) {
                foreach ( $sites as $site ) {
index 9c5fc2f..9198c1e 100644 (file)
@@ -103,6 +103,7 @@ class ActiveUsersPager extends UsersPager {
                        'user_name = qcc_title',
                        'rc_user_text = qcc_title',
                        'rc_type != ' . $dbr->addQuotes( RC_EXTERNAL ), // Don't count wikidata.
+                       'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE ), // Don't count categorization changes.
                        'rc_log_type IS NULL OR rc_log_type != ' . $dbr->addQuotes( 'newusers' ),
                        'rc_timestamp >= ' . $dbr->addQuotes( $timestamp ),
                ];
index 9c1f224..a9753ae 100644 (file)
@@ -347,22 +347,18 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
         */
        protected function getWatchlistInfo() {
                $titles = [];
-               $dbr = wfGetDB( DB_SLAVE );
 
-               $res = $dbr->select(
-                       [ 'watchlist' ],
-                       [ 'wl_namespace', 'wl_title' ],
-                       [ 'wl_user' => $this->getUser()->getId() ],
-                       __METHOD__,
-                       [ 'ORDER BY' => [ 'wl_namespace', 'wl_title' ] ]
-               );
+               $watchedItems = WatchedItemStore::getDefaultInstance()
+                       ->getWatchedItemsForUser( $this->getUser(), [ 'sort' => WatchedItemStore::SORT_ASC ] );
 
                $lb = new LinkBatch();
 
-               foreach ( $res as $row ) {
-                       $lb->add( $row->wl_namespace, $row->wl_title );
-                       if ( !MWNamespace::isTalk( $row->wl_namespace ) ) {
-                               $titles[$row->wl_namespace][$row->wl_title] = 1;
+               foreach ( $watchedItems as $watchedItem ) {
+                       $namespace = $watchedItem->getLinkTarget()->getNamespace();
+                       $dbKey = $watchedItem->getLinkTarget()->getDBkey();
+                       $lb->add( $namespace, $dbKey );
+                       if ( !MWNamespace::isTalk( $namespace ) ) {
+                               $titles[$namespace][$dbKey] = 1;
                        }
                }
 
index 2dda093..27e5829 100644 (file)
@@ -382,7 +382,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        }
 
                        if ( isset( $watchedItemStore ) ) {
-                               $rcTitleValue = new TitleValue( $obj->rc_namespace, $obj->rc_title );
+                               $rcTitleValue = new TitleValue( (int)$obj->rc_namespace, $obj->rc_title );
                                $rc->numberofWatchingusers = $watchedItemStore->countWatchers( $rcTitleValue );
                        } else {
                                $rc->numberofWatchingusers = 0;
index 002fd06..3bd3a4c 100644 (file)
@@ -166,14 +166,14 @@ class BatchRowIterator implements RecursiveIterator {
        }
 
        /**
-        * @return boolean True when the iterator is in a valid state
+        * @return bool True when the iterator is in a valid state
         */
        public function valid() {
                return (bool)$this->current;
        }
 
        /**
-        * @return boolean True when this result set has rows
+        * @return bool True when this result set has rows
         */
        public function hasChildren() {
                return $this->current && count( $this->current );
index 75eaede..72c620e 100644 (file)
@@ -70,7 +70,7 @@ class MWCryptHash {
         * Return the byte-length output of the hash algorithm we are
         * using in self::hash and self::hmac.
         *
-        * @param boolean $raw True to return the length for binary data, false to
+        * @param bool $raw True to return the length for binary data, false to
         *   return for hex-encoded
         * @return int Number of bytes the hash outputs
         */
@@ -88,7 +88,7 @@ class MWCryptHash {
         * making use of the best hash algorithm that we have available.
         *
         * @param string $data
-        * @param boolean $raw True to return binary data, false to return it hex-encoded
+        * @param bool $raw True to return binary data, false to return it hex-encoded
         * @return string A hash of the data
         */
        public static function hash( $data, $raw = true ) {
@@ -101,7 +101,7 @@ class MWCryptHash {
         *
         * @param string $data
         * @param string $key
-        * @param boolean $raw True to return binary data, false to return it hex-encoded
+        * @param bool $raw True to return binary data, false to return it hex-encoded
         * @return string An hmac hash of the data + key
         */
        public static function hmac( $data, $key, $raw = true ) {
index 44815b4..516e9ae 100644 (file)
@@ -215,6 +215,10 @@ class ZipDirectoryReader {
                        $startPos = 0;
                }
 
+               if ( $this->getFileLength() === 0 ) {
+                       $this->error( 'zip-wrong-format', "The file is empty." );
+               }
+
                $block = $this->getBlock( $startPos );
                $sigPos = strrpos( $block, "PK\x05\x06" );
                if ( $sigPos === false ) {
index 1f977bf..38e5a1f 100644 (file)
@@ -14,7 +14,7 @@
  *
  *             $( '#textbox' ).suggestions();
  *
- * Uses jQuery.suggestions singleteon internally.
+ * Uses jQuery.suggestions singleton internally.
  *
  * @class jQuery.plugin.suggestions
  */
index fd907ac..9da6c83 100644 (file)
@@ -1,5 +1,5 @@
-/* Styles for user login and signup forms */
-.mw-form-related-link-container {
+/* User login and signup forms */
+.mw-ui-vform .mw-form-related-link-container {
        margin-bottom: 0.5em;
        text-align: center;
 }
index 42d5693..620c83a 100644 (file)
@@ -5,4 +5,29 @@
        background: url( images/glyph-people-large.png ) no-repeat 50%;
        margin: 0 auto;
        padding-top: 7.8em;
+       font-weight: bold;
+}
+
+/* Login Button, following `ButtonWidget (progressive)‎` from OOjs UI */
+#mw-createaccount-join {
+       color: #347bff;
+}
+#mw-createaccount-join:hover {
+       background-color: #ebf2ff; /* rgba(52, 123, 255, 0.1); */
+       border-color: #859ecc;
+       box-shadow: none;
+}
+#mw-createaccount-join:active {
+       background-color: #ebf2ff;
+       color: #1f4999;
+       border-color: #1f4999;
+}
+#mw-createaccount-join:focus {
+       background-color: #fff;
+       color: #1f4999;
+       border-color: #1f4999;
+       box-shadow: inset 0 0 0 1px #1f4999;
+}
+#mw-createaccount-join:active:focus {
+       background-color: #ebf2ff;
 }
index b805e65..8b02443 100644 (file)
@@ -6,6 +6,17 @@
  */
 ( function ( $, mw ) {
 
+       var interwikiPrefixes = [],
+               interwikiPrefixesPromise = new mw.Api().get( {
+                       action: 'query',
+                       meta: 'siteinfo',
+                       siprop: 'interwikimap'
+               } ).done( function ( data ) {
+                       $.each( data.query.interwikimap, function ( index, interwiki ) {
+                               interwikiPrefixes.push( interwiki.prefix );
+                       } );
+               } );
+
        /**
         * Mixin for title widgets
         *
@@ -28,8 +39,6 @@
         * @cfg {Object} [cache] Result cache which implements a 'set' method, taking keyed values as an argument
         */
        mw.widgets.TitleWidget = function MwWidgetsTitleWidget( config ) {
-               var widget = this;
-
                // Config initialization
                config = $.extend( {
                        maxLength: 255,
 
                // Initialization
                this.$element.addClass( 'mw-widget-titleWidget' );
-               this.interwikiPrefixes = [];
-               this.interwikiPrefixesPromise = new mw.Api().get( {
-                       action: 'query',
-                       meta: 'siteinfo',
-                       siprop: 'interwikimap'
-               } ).done( function ( data ) {
-                       $.each( data.query.interwikimap, function ( index, interwiki ) {
-                               widget.interwikiPrefixes.push( interwiki.prefix );
-                       } );
-               } );
        };
 
        /* Setup */
                        } };
 
                if ( mw.Title.newFromText( query ) ) {
-                       return this.interwikiPrefixesPromise.then( function () {
+                       return interwikiPrefixesPromise.then( function () {
                                var params,
                                        interwiki = query.substring( 0, query.indexOf( ':' ) );
                                if (
                                        interwiki && interwiki !== '' &&
-                                       widget.interwikiPrefixes.indexOf( interwiki ) !== -1
+                                       interwikiPrefixes.indexOf( interwiki ) !== -1
                                ) {
                                        return $.Deferred().resolve( { query: {
                                                pages: [ {
index b22cfd8..c6eebe4 100644 (file)
@@ -4772,7 +4772,7 @@ External image
 !! wikitext
 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
 !! html
-<p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
+<p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
 </p>
 !! end
 
@@ -4781,7 +4781,7 @@ External image from https
 !! wikitext
 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
 !! html
-<p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
+<p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
 </p>
 !! end
 
@@ -4855,7 +4855,7 @@ External links: Clickable images
 !! wikitext
 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
 !! html/php
-<p>ja-style clickable images: <a rel="nofollow" class="external text" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" /></a>
+<p>ja-style clickable images: <a rel="nofollow" class="external text" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/></a>
 </p>
 !! html/parsoid
 <p>ja-style clickable images: <a rel="mw:ExtLink" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" data-parsoid='{"type":"extlink"}'/></a></p>
@@ -6566,6 +6566,8 @@ Table with empty line following the start tag
 
 !! test
 Table attributes with empty value
+!! options
+parsoid=wt2html,html2html
 !! wikitext
 {|
 | style=| hello
@@ -6578,11 +6580,8 @@ Table attributes with empty value
 
 !! html/parsoid
 <table>
-<tbody>
-<tr>
-<td style=""> hello
-</td></tr></tbody></table>
-
+<tbody><tr><td style=""> hello</td></tr>
+</tbody></table>
 !! end
 
 !! test
@@ -10508,6 +10507,7 @@ Abort table cell attribute parsing on wikilink
 {|
 | testing [[one|two]] | three || four
 | testing one two | three || four
+| testing="[[one|two]]" | three || four
 |}
 !! html/php
 <table>
@@ -10517,12 +10517,16 @@ Abort table cell attribute parsing on wikilink
 </td>
 <td> three </td>
 <td> four
+</td>
+<td> testing="<a href="/index.php?title=One&amp;action=edit&amp;redlink=1" class="new" title="One (page does not exist)">two</a>" | three </td>
+<td> four
 </td></tr></table>
 
 !! html/parsoid
 <table>
 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> testing <a rel="mw:WikiLink" href="./One" title="One" data-parsoid='{"stx":"piped","a":{"href":"./One"},"sa":{"href":"one"}}'>two</a> | three </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> four</td>
-<td data-parsoid='{"a":{"testing":null,"one":null,"two":null},"sa":{"testing":"","one":"","two":""},"autoInsertedEnd":true}'> three </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> four</td></tr>
+<td data-parsoid='{"a":{"testing":null,"one":null,"two":null},"sa":{"testing":"","one":"","two":""},"autoInsertedEnd":true}'> three </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> four</td>
+<td> testing="<a rel="mw:WikiLink" href="./One" title="One" data-parsoid='{"stx":"piped","a":{"href":"./One"},"sa":{"href":"one"}}'>two</a>" | three </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> four</td></tr>
 </tbody></table>
 !! end
 
@@ -15470,14 +15474,17 @@ div with illegal double attributes
 
 !! test
 div with empty attribute value, space before equals
+!! options
+parsoid=wt2html,html2html
 !! wikitext
 <div class =>HTML rocks</div>
-!! html
+!! html/php
 <div class="">HTML rocks</div>
 
+!! html/parsoid
+<div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
 !! end
 
-# FIXME: Parsoid doesn't match the html5 spec
 !! test
 div with multiple empty attribute values
 !! options
@@ -15488,10 +15495,9 @@ parsoid=wt2html,html2html
 <div id="title.3D">HTML rocks</div>
 
 !! html/parsoid
-<div id="" title="">HTML rocks</div>
+<div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
 !! end
 
-# FIXME: Parsoid doesn't match the html5 spec
 !! test
 table with multiple empty attribute values
 !! options
@@ -15507,7 +15513,7 @@ parsoid=wt2html,html2html
 </td></tr></table>
 
 !! html/parsoid
-<table title="" id="">
+<table title="id=">
 <tbody><tr><td> hi</td></tr>
 </tbody></table>
 !! end
@@ -15849,20 +15855,28 @@ Empty attribute crash test single-quotes (bug 2067)
 
 !! test
 Attribute test: equals, then nothing
+!! options
+parsoid=wt2html,html2html
 !! wikitext
 <font color=>foo</font>
-!! html
+!! html/php
 <p><font color="">foo</font>
 </p>
+!! html/parsoid
+<p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
 !! end
 
 !! test
 Attribute test: unquoted value
+!! options
+parsoid=wt2html,html2html
 !! wikitext
 <font color=x>foo</font>
-!! html
+!! html/php
 <p><font color="x">foo</font>
 </p>
+!! html/parsoid
+<p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
 !! end
 
 !! test
@@ -17046,6 +17060,8 @@ http://<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
 
 !! test
 Fuzz testing: Parser14-table
+!! options
+parsoid=wt2html,html2html
 !! wikitext
 ==a==
 {| STYLE=__TOC__
@@ -17062,6 +17078,9 @@ Fuzz testing: Parser14-table
 <td></td>
 </tr>
 </table>
+!! html/parsoid
+<h2>a</h2>
+<table style="__TOC__"></table>
 !! end
 
 # Known to produce bogus xml (extra </td>)
@@ -20855,7 +20874,7 @@ Bug 19052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
 !! wikitext
 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
 !! html
-<p><img src="http://www.example.org/pic.png" alt="pic.png" /> &lt;-- U+3000 (vim: ^Vu3000)
+<p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
 </p>
 !! end
 
index dc69902..4d0e39c 100644 (file)
@@ -161,7 +161,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
        }
 
        /**
-        * @return boolean
+        * @return bool
         */
        private function oncePerClass() {
                // Remember current test class in the database connection,
index a90295a..98eb0c5 100644 (file)
@@ -64,7 +64,7 @@ class HtmlTest extends MediaWikiTestCase {
                $this->setMwGlobals( 'wgWellFormedXml', true );
 
                $this->assertEquals(
-                       '<img />',
+                       '<img/>',
                        Html::element( 'img', null, '' ),
                        'Self-closing tag for short-tag elements (wgWellFormedXml = true)'
                );
index d404ab8..9bef038 100644 (file)
@@ -142,9 +142,9 @@ class OutputPageTest extends MediaWikiTestCase {
                        // Load module script only
                        array(
                                array( 'test.foo', ResourceLoaderModule::TYPE_SCRIPTS ),
-                               "<script>(window.RLQ = window.RLQ || []).push(function () {\n"
+                               "<script>(window.RLQ=window.RLQ||[]).push(function(){"
                                        . 'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.foo\u0026only=scripts\u0026skin=fallback");'
-                                       . "\n} );</script>"
+                                       . "});</script>"
                        ),
                        array(
                                // Don't condition wrap raw modules (like the startup module)
@@ -161,17 +161,17 @@ class OutputPageTest extends MediaWikiTestCase {
                        // Load private module (only=scripts)
                        array(
                                array( 'test.quux', ResourceLoaderModule::TYPE_SCRIPTS ),
-                               "<script>(window.RLQ = window.RLQ || []).push(function () {\n"
-                                       . "mw.test.baz({token:123});mw.loader.state({\"test.quux\":\"ready\"});\n"
-                                       . "} );</script>"
+                               "<script>(window.RLQ=window.RLQ||[]).push(function(){"
+                                       . "mw.test.baz({token:123});mw.loader.state({\"test.quux\":\"ready\"});"
+                                       . "});</script>"
                        ),
                        // Load private module (combined)
                        array(
                                array( 'test.quux', ResourceLoaderModule::TYPE_COMBINED ),
-                               "<script>(window.RLQ = window.RLQ || []).push(function () {\n"
+                               "<script>(window.RLQ=window.RLQ||[]).push(function(){"
                                        . "mw.loader.implement(\"test.quux\",function($,jQuery){"
                                        . "mw.test.baz({token:123});},{\"css\":[\".mw-icon{transition:none}"
-                                       . "\"]});\n} );</script>"
+                                       . "\"]});});</script>"
                        ),
                        // Load no modules
                        array(
@@ -186,12 +186,12 @@ class OutputPageTest extends MediaWikiTestCase {
                        // Load two modules in separate groups
                        array(
                                array( array( 'test.group.foo', 'test.group.bar' ), ResourceLoaderModule::TYPE_COMBINED ),
-                               "<script>(window.RLQ = window.RLQ || []).push(function () {\n"
+                               "<script>(window.RLQ=window.RLQ||[]).push(function(){"
                                        . 'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.group.bar\u0026skin=fallback");'
-                                       . "\n} );</script>\n"
-                                       . "<script>(window.RLQ = window.RLQ || []).push(function () {\n"
+                                       . "});</script>\n"
+                                       . "<script>(window.RLQ=window.RLQ||[]).push(function(){"
                                        . 'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.group.foo\u0026skin=fallback");'
-                                       . "\n} );</script>"
+                                       . "});</script>"
                        ),
                );
                // @codingStandardsIgnoreEnd
index 1354b1c..afde88c 100644 (file)
@@ -1458,7 +1458,9 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                        ->with(
                                'watchlist',
                                [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
-                               [ 'wl_user' => 1 ]
+                               [ 'wl_user' => 1 ],
+                               $this->isType( 'string' ),
+                               [ 'ORDER BY' => [ 'wl_namespace ASC', 'wl_title ASC' ] ]
                        )
                        ->will( $this->returnValue( [] ) );
 
@@ -1469,11 +1471,24 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
 
                $watchedItems = $store->getWatchedItemsForUser(
                        $user,
-                       [ 'forWrite' => $forWrite ]
+                       [ 'forWrite' => $forWrite, 'sort' => WatchedItemStore::SORT_ASC ]
                );
                $this->assertEquals( [], $watchedItems );
        }
 
+       public function testGetWatchedItemsForUser_badSortOptionThrowsException() {
+               $store = new WatchedItemStore(
+                       $this->getMockLoadBalancer( $this->getMockDb() ),
+                       $this->getMockCache()
+               );
+
+               $this->setExpectedException( 'InvalidArgumentException' );
+               $store->getWatchedItemsForUser(
+                       $this->getMockNonAnonUserWithId( 1 ),
+                       [ 'sort' => 'foo' ]
+               );
+       }
+
        public function testIsWatchedItem_existingItem() {
                $mockDb = $this->getMockDb();
                $mockDb->expects( $this->once() )
index c5314cb..7b82d68 100644 (file)
@@ -152,7 +152,7 @@ class XmlTest extends MediaWikiTestCase {
 
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> ' .
-                               '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year" /> ' .
+                               '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year"/> ' .
                                '<label for="month">From month (and earlier):</label> ' .
                                '<select name="month" id="month" class="mw-month-selector">' .
                                '<option value="-1">all</option>' . "\n" .
@@ -173,7 +173,7 @@ class XmlTest extends MediaWikiTestCase {
                );
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> ' .
-                               '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year" /> ' .
+                               '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year"/> ' .
                                '<label for="month">From month (and earlier):</label> ' .
                                '<select name="month" id="month" class="mw-month-selector">' .
                                '<option value="-1">all</option>' . "\n" .
@@ -207,7 +207,7 @@ class XmlTest extends MediaWikiTestCase {
 
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> ' .
-                               '<input id="year" maxlength="4" size="7" type="number" name="year" /> ' .
+                               '<input id="year" maxlength="4" size="7" type="number" name="year"/> ' .
                                '<label for="month">From month (and earlier):</label> ' .
                                '<select name="month" id="month" class="mw-month-selector">' .
                                '<option value="-1">all</option>' . "\n" .
diff --git a/tests/phpunit/includes/specials/SpecialEditWatchlistTest.php b/tests/phpunit/includes/specials/SpecialEditWatchlistTest.php
new file mode 100644 (file)
index 0000000..cd84d79
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * @author Addshore
+ *
+ * @group Database
+ *
+ * @covers SpecialEditWatchlist
+ */
+class SpecialEditWatchlistTest extends SpecialPageTestBase {
+
+       /**
+        * Returns a new instance of the special page under test.
+        *
+        * @return SpecialPage
+        */
+       protected function newSpecialPage() {
+               return new SpecialEditWatchlist();
+       }
+
+       public function testNotLoggedIn_throwsException() {
+               $this->setExpectedException( 'UserNotLoggedIn' );
+               $this->executeSpecialPage();
+       }
+
+       public function testRootPage_displaysExplanationMessage() {
+               $user = new TestUser( __METHOD__ );
+               list( $html, ) = $this->executeSpecialPage( '', null, 'qqx', $user->getUser() );
+               $this->assertContains( '(watchlistedit-normal-explain)', $html );
+       }
+
+       public function testClearPage_hasClearButtonForm() {
+               $user = new TestUser( __METHOD__ );
+               list( $html, ) = $this->executeSpecialPage( 'clear', null, 'qqx', $user->getUser() );
+               $this->assertRegExp(
+                       '/<form action=".*?Special:EditWatchlist\/clear" method="post" class="visualClear">/',
+                       $html
+               );
+       }
+
+       public function testEditRawPage_hasTitlesBox() {
+               $user = new TestUser( __METHOD__ );
+               list( $html, ) = $this->executeSpecialPage( 'raw', null, 'qqx', $user->getUser() );
+               $this->assertContains(
+                       '<textarea id="mw-input-wpTitles"',
+                       $html
+               );
+       }
+
+}
diff --git a/tests/phpunit/includes/specials/SpecialWatchlistTest.php b/tests/phpunit/includes/specials/SpecialWatchlistTest.php
new file mode 100644 (file)
index 0000000..6e702b6
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * @author Addshore
+ *
+ * @group Database
+ *
+ * @covers SpecialWatchlist
+ */
+class SpecialWatchlistTest extends SpecialPageTestBase {
+
+       /**
+        * Returns a new instance of the special page under test.
+        *
+        * @return SpecialPage
+        */
+       protected function newSpecialPage() {
+               return new SpecialWatchlist();
+       }
+
+       public function testNotLoggedIn_throwsException() {
+               $this->setExpectedException( 'UserNotLoggedIn' );
+               $this->executeSpecialPage();
+       }
+
+       public function testUserWithNoWatchedItems_displaysNoWatchlistMessage() {
+               $user = new TestUser( __METHOD__ );
+               list( $html, ) = $this->executeSpecialPage( '', null, 'qqx', $user->getUser() );
+               $this->assertContains( '(nowatchlist)', $html );
+       }
+
+}