Merge "Rename WikiMap DB domain ID methods to reduce confusion with web domains"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 7 Feb 2019 01:42:09 +0000 (01:42 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 7 Feb 2019 01:42:09 +0000 (01:42 +0000)
20 files changed:
.phpcs.xml
RELEASE-NOTES-1.33
autoload.php
includes/jobqueue/JobQueue.php
includes/jobqueue/exception/JobQueueConnectionError.php [new file with mode: 0644]
includes/jobqueue/exception/JobQueueError.php [new file with mode: 0644]
includes/jobqueue/exception/JobQueueReadOnlyError.php [new file with mode: 0644]
includes/specials/SpecialBlock.php
maintenance/populateArchiveRevId.php
maintenance/resources/foreign-resources.yaml
resources/Resources.php
resources/lib/oojs-router/AUTHORS.txt
resources/lib/oojs-router/History.md [new file with mode: 0644]
resources/lib/oojs-router/LICENSE [new file with mode: 0644]
resources/lib/oojs-router/LICENSE-MIT [deleted file]
resources/lib/oojs-router/oojs-router.js
tests/phpunit/includes/api/ApiComparePagesTest.php
tests/phpunit/includes/api/ApiMoveTest.php
tests/phpunit/includes/block/Restriction/PageRestrictionTest.php
tests/phpunit/includes/specials/pagers/BlockListPagerTest.php

index 21dbe81..b8e35d4 100644 (file)
        <rule ref="MediaWiki.NamingConventions.PrefixedGlobalFunctions">
                <properties>
                        <!--
-                       includes/compat/normal/UtfNormalUtil.php
-                       * codepointToUtf8
-                       * escapeSingleString
-                       * hexSequenceToUtf8
-                       * utf8ToCodepoint
-                       * utf8ToHexSequence
                        includes/GlobalFunctions.php
                        * mimeTypeMatch
-                       maintenance/benchmarks/bench_strtr_str_replace.php
-                       * bfNormalizeTitleStrReplace
-                       * bfNormalizeTitleStrTr
                        maintenance/cdb.php
                        * cdbShowHelp
                        maintenance/language/transstat.php
@@ -54,7 +45,7 @@
                        tests/qunit/data/styleTest.css.php
                        * cssfilter
                        -->
-                       <property name="ignoreList" type="array" value="bfNormalizeTitleStrReplace,bfNormalizeTitleStrTr,cdbShowHelp,codepointToUtf8,compare_point,cssfilter,escapeSingleString,getEscapedProfileUrl,hexSequenceToUtf8,mccGetHelp,mccShowUsage,mimeTypeMatch,moveToExternal,NothingFunction,NothingFunctionData,resolveStub,resolveStubs,showUsage,utf8ToCodepoint,utf8ToHexSequence" />
+                       <property name="ignoreList" type="array" value="cdbShowHelp,compare_point,cssfilter,getEscapedProfileUrl,mccGetHelp,mccShowUsage,mimeTypeMatch,moveToExternal,NothingFunction,NothingFunctionData,resolveStub,resolveStubs,showUsage" />
                </properties>
        </rule>
        <rule ref="MediaWiki.NamingConventions.ValidGlobalName">
                <exclude-pattern>*/maintenance/benchmarks/bench_Wikimedia_base_convert\.php</exclude-pattern>
                <exclude-pattern>*/maintenance/benchmarks/bench_delete_truncate\.php</exclude-pattern>
                <exclude-pattern>*/maintenance/benchmarks/bench_if_switch\.php</exclude-pattern>
-               <exclude-pattern>*/maintenance/benchmarks/bench_strtr_str_replace\.php</exclude-pattern>
                <exclude-pattern>*/maintenance/benchmarks/bench_utf8_title_check\.php</exclude-pattern>
                <exclude-pattern>*/maintenance/benchmarks/bench_wfIsWindows\.php</exclude-pattern>
                <exclude-pattern>*/maintenance/cleanupTable.inc</exclude-pattern>
                <exclude-pattern>*/includes/HistoryBlob\.php</exclude-pattern>
                <exclude-pattern>*/includes/htmlform/HTMLFormElement\.php</exclude-pattern>
                <exclude-pattern>*/includes/jobqueue/aggregator/JobQueueAggregator\.php</exclude-pattern>
-               <exclude-pattern>*/includes/jobqueue/JobQueue\.php</exclude-pattern>
                <exclude-pattern>*/includes/libs/filebackend/FileBackendStore\.php</exclude-pattern>
                <exclude-pattern>*/includes/libs/filebackend/FSFileBackend\.php</exclude-pattern>
                <exclude-pattern>*/includes/libs/filebackend/SwiftFileBackend\.php</exclude-pattern>
index 0ce2380..69ab560 100644 (file)
@@ -53,6 +53,7 @@ production.
 
 ==== Changed external libraries ====
 * Updated OOUI from v0.29.2 to v0.30.2.
+* Updated OOjs Router from pre-release to v0.2.0.
 * Updated wikimedia/xmp-reader from 0.6.0 to 0.6.1.
 * Updated wikimedia/scoped-callback from 2.0.0 to 3.0.0.
 * Updated wikimedia/ip-set from 1.2.0 to 2.0.0.
@@ -228,6 +229,8 @@ because of Phabricator reports.
 * (T126091) The 'ResourceLoaderTestModules' hook, which lets you declare QUnit
   testing code for your JavaScript modules, is deprecated. Instead, you can now
   use the new extension registration key 'QUnitTestModule'.
+* (T213426) The jquery.throttle-debounce module has been deprecated. JavaScript
+  code that needs this behaviour should use OO.ui.debounce/throttle.
 
 === Other changes in 1.33 ===
 * (T208871) The hard-coded Google search form on the database error page was
index 22f9737..3b04dfc 100644 (file)
@@ -708,14 +708,14 @@ $wgAutoloadLocalClasses = [
        'JobQueueAggregator' => __DIR__ . '/includes/jobqueue/aggregator/JobQueueAggregator.php',
        'JobQueueAggregatorNull' => __DIR__ . '/includes/jobqueue/aggregator/JobQueueAggregator.php',
        'JobQueueAggregatorRedis' => __DIR__ . '/includes/jobqueue/aggregator/JobQueueAggregatorRedis.php',
-       'JobQueueConnectionError' => __DIR__ . '/includes/jobqueue/JobQueue.php',
+       'JobQueueConnectionError' => __DIR__ . '/includes/jobqueue/exception/JobQueueConnectionError.php',
        'JobQueueDB' => __DIR__ . '/includes/jobqueue/JobQueueDB.php',
        'JobQueueEnqueueUpdate' => __DIR__ . '/includes/deferred/JobQueueEnqueueUpdate.php',
-       'JobQueueError' => __DIR__ . '/includes/jobqueue/JobQueue.php',
+       'JobQueueError' => __DIR__ . '/includes/jobqueue/exception/JobQueueError.php',
        'JobQueueFederated' => __DIR__ . '/includes/jobqueue/JobQueueFederated.php',
        'JobQueueGroup' => __DIR__ . '/includes/jobqueue/JobQueueGroup.php',
        'JobQueueMemory' => __DIR__ . '/includes/jobqueue/JobQueueMemory.php',
-       'JobQueueReadOnlyError' => __DIR__ . '/includes/jobqueue/JobQueue.php',
+       'JobQueueReadOnlyError' => __DIR__ . '/includes/jobqueue/exception/JobQueueReadOnlyError.php',
        'JobQueueRedis' => __DIR__ . '/includes/jobqueue/JobQueueRedis.php',
        'JobRunner' => __DIR__ . '/includes/jobqueue/JobRunner.php',
        'JobSpecification' => __DIR__ . '/includes/jobqueue/JobSpecification.php',
index 0ca272c..660352a 100644 (file)
@@ -724,17 +724,3 @@ abstract class JobQueue {
                $stats->updateCount( "jobqueue.{$key}.{$type}", $delta );
        }
 }
-
-/**
- * @ingroup JobQueue
- * @since 1.22
- */
-class JobQueueError extends MWException {
-}
-
-class JobQueueConnectionError extends JobQueueError {
-}
-
-class JobQueueReadOnlyError extends JobQueueError {
-
-}
diff --git a/includes/jobqueue/exception/JobQueueConnectionError.php b/includes/jobqueue/exception/JobQueueConnectionError.php
new file mode 100644 (file)
index 0000000..7f32f23
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Job queue base code.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @defgroup JobQueue JobQueue
+ */
+
+/**
+ * @ingroup JobQueue
+ * @since 1.22
+ */
+class JobQueueConnectionError extends JobQueueError {
+}
diff --git a/includes/jobqueue/exception/JobQueueError.php b/includes/jobqueue/exception/JobQueueError.php
new file mode 100644 (file)
index 0000000..19cb555
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Job queue base code.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @defgroup JobQueue JobQueue
+ */
+
+/**
+ * @ingroup JobQueue
+ * @since 1.22
+ */
+class JobQueueError extends MWException {
+}
diff --git a/includes/jobqueue/exception/JobQueueReadOnlyError.php b/includes/jobqueue/exception/JobQueueReadOnlyError.php
new file mode 100644 (file)
index 0000000..b5c20ce
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Job queue base code.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @defgroup JobQueue JobQueue
+ */
+
+/**
+ * @ingroup JobQueue
+ * @since 1.22
+ */
+class JobQueueReadOnlyError extends JobQueueError {
+
+}
index 4321cde..9c8882b 100644 (file)
@@ -871,7 +871,7 @@ class SpecialBlock extends FormSpecialPage {
                                        $title = Title::newFromText( $text );
                                        // Use the link cache since the title has already been loaded when
                                        // the field was validated.
-                                       $restriction = new PageRestriction( 0, $title->getArticleId() );
+                                       $restriction = new PageRestriction( 0, $title->getArticleID() );
                                        $restriction->setTitle( $title );
                                        return $restriction;
                                }, explode( "\n", $data['PageRestrictions'] ) );
index 6eb2d6d..ec2eff4 100644 (file)
@@ -198,7 +198,7 @@ class PopulateArchiveRevId extends LoggedUpdateMaintenance {
                $rev = null;
 
                $mainPage = Title::newMainPage();
-               $pageId = $mainPage ? $mainPage->getArticleId() : null;
+               $pageId = $mainPage ? $mainPage->getArticleID() : null;
                if ( $pageId ) {
                        $rev = $dbw->selectRow(
                                'revision',
index 7760f1d..ee74bb3 100644 (file)
@@ -110,6 +110,16 @@ oojs:
     package/LICENSE-MIT:
     package/README.md:
 
+oojs-router:
+  type: tar
+  src: https://registry.npmjs.org/oojs-router/-/oojs-router-0.2.0.tgz
+  integrity: sha384-VngYqdQ3vTDMXbm4e4FUZCCGos7fB0Jkr9V+kBL5MElprK1h0yQZOzBNnMHtSJS/
+  dest:
+    package/dist/oojs-router.js:
+    package/LICENSE:
+    package/AUTHORS.txt:
+    package/History.md:
+
 ooui:
   type: tar
   src: https://registry.npmjs.org/oojs-ui/-/oojs-ui-0.30.2.tgz
index 83f11f8..f807228 100644 (file)
@@ -337,6 +337,8 @@ return [
                'targets' => [ 'mobile', 'desktop' ],
        ],
        'jquery.throttle-debounce' => [
+               'deprecated' => 'Please use OO.ui.throttle/debounce instead. See '
+                       . 'https://phabricator.wikimedia.org/T213426',
                'scripts' => 'resources/lib/jquery.ba-throttle-debounce.js',
                'targets' => [ 'desktop', 'mobile' ],
        ],
index 5390c84..a406b57 100644 (file)
@@ -1 +1,7 @@
+Ed Sanders <esanders@wikimedia.org>
+James D. Forrester <jforrester@wikimedia.org>
 Jon Robson <jdlrobson@gmail.com>
+Kunal Mehta <legoktm@member.fsf.org>
+MarcoAurelio <maurelio@tools.wmflabs.org>
+Prateek Saxena <prtksxna@gmail.com>
+Timo Tijhof <krinklemail@gmail.com>
diff --git a/resources/lib/oojs-router/History.md b/resources/lib/oojs-router/History.md
new file mode 100644 (file)
index 0000000..c3889cf
--- /dev/null
@@ -0,0 +1,23 @@
+# OOjs Router Release History
+## v0.2.0 / 2019-02-06
+* build: Misc clean up (Timo Tijhof)
+* Code style fixes and refactoring (Ed Sanders)
+* build: Switch to ESLint (Timo Tijhof)
+* Unit tests (Jon Robson)
+* Add .gitreview (Christian Aistleitner)
+* Remove .arcconfig & .arclint (MarcoAurelio)
+* Add jsduck config (Prateek Saxena)
+* build: Update devDependencies (Ed Sanders)
+* Use standard coverage reporting configuration (Kunal Mehta)
+* Update eslint-config-wikimedia to 0.9.0 (Ed Sanders)
+* build: Update devDependencies (Ed Sanders)
+* build: Structure updates (Timo Tijhof)
+* OOjs Router method to provide access to replaceState (Jon Robson)
+* build: Switch from prepublish to prepare for modern npm (James D. Forrester)
+* build: Bump package-lock.json for npm audit (James D. Forrester)
+* build: Add AUTHORS.txt to package manifest (James D. Forrester)
+* AUTHORS.txt: Add everyone from `git shortlog` (James D. Forrester)
+
+## v0.1.0 / 2016-05-05
+* Initial commit (Jon Robson)
+* Add build, CI infrastructure (James D. Forrester)
diff --git a/resources/lib/oojs-router/LICENSE b/resources/lib/oojs-router/LICENSE
new file mode 100644 (file)
index 0000000..acbe708
--- /dev/null
@@ -0,0 +1,20 @@
+Copyright 2011-2016 OOjs Team and other contributors.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/resources/lib/oojs-router/LICENSE-MIT b/resources/lib/oojs-router/LICENSE-MIT
deleted file mode 100644 (file)
index acbe708..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright 2011-2016 OOjs Team and other contributors.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
index b136923..111d0e8 100644 (file)
 /*!
- * OOjs Router v0.1.0
- * https://www.mediawiki.org/wiki/OOjs
+ * OOjs Router v0.2.0
+ * https://www.mediawiki.org/wiki/OOjs_Router
  *
- * Copyright 2011-2016 OOjs Team and other contributors.
+ * Copyright 2011-2019 OOjs Team and other contributors.
  * Released under the MIT license
- * http://oojs-router.mit-license.org
+ * http://oojs.mit-license.org
  *
- * Date: 2016-05-05T19:27:58Z
+ * Date: 2019-02-06T21:26:01Z
  */
 ( function ( $ ) {
 
 'use strict';
 
-/**
- * Does hash match entry.path? If it does apply the
- * callback for the Entry object.
- *
- * @method
- * @private
- * @ignore
- * @param {string} hash string to match
- * @param {Object} entry Entry object
- * @return {boolean} Whether hash matches entry.path
- */
-function matchRoute( hash, entry ) {
-       var match = hash.match( entry.path );
-       if ( match ) {
-               entry.callback.apply( this, match.slice( 1 ) );
-               return true;
-       }
-       return false;
-}
-
 /**
  * Provides navigation routing and location information
  *
- * @class Router
- * @mixins OO.EventEmitter
+ * @class OO.Router
+ * @extends OO.Registry
  */
-function Router() {
-       var self = this;
-       OO.EventEmitter.call( this );
-       // use an object instead of an array for routes so that we don't
-       // duplicate entries that already exist
-       this.routes = {};
+OO.Router = function OoRouter() {
+       var router = this;
+
+       // Parent constructor
+       OO.Router.parent.call( this );
+
        this.enabled = true;
        this.oldHash = this.getPath();
 
        $( window ).on( 'popstate', function () {
-               self.emit( 'popstate' );
+               router.emit( 'popstate' );
        } );
 
        $( window ).on( 'hashchange', function () {
-               self.emit( 'hashchange' );
+               router.emit( 'hashchange' );
        } );
 
        this.on( 'hashchange', function () {
-               // ev.originalEvent.newURL is undefined on Android 2.x
-               var routeEv;
+               // event.originalEvent.newURL is undefined on Android 2.x
+               var routeEvent;
 
-               if ( self.enabled ) {
-                       routeEv = $.Event( 'route', {
-                               path: self.getPath()
+               if ( router.enabled ) {
+                       routeEvent = $.Event( 'route', {
+                               path: router.getPath()
                        } );
-                       self.emit( 'route', routeEv );
+                       router.emit( 'route', routeEvent );
 
-                       if ( !routeEv.isDefaultPrevented() ) {
-                               self.checkRoute();
+                       if ( !routeEvent.isDefaultPrevented() ) {
+                               router.checkRoute();
                        } else {
                                // if route was prevented, ignore the next hash change and revert the
                                // hash to its old value
-                               self.enabled = false;
-                               self.navigate( self.oldHash );
+                               router.enabled = false;
+                               router.navigate( router.oldHash );
                        }
                } else {
-                       self.enabled = true;
+                       router.enabled = true;
                }
 
-               self.oldHash = self.getPath();
+               router.oldHash = router.getPath();
        } );
-}
-OO.mixinClass( Router, OO.EventEmitter );
+};
+
+/* Inheritance */
+
+OO.inheritClass( OO.Router, OO.Registry );
+
+/* Events */
 
 /**
- * Check the current route and run appropriate callback if it matches.
+ * @event popstate
+ */
+
+/**
+ * @event hashchange
+ */
+
+/**
+ * @event route
+ * @param {jQuery.Event} routeEvent
+ */
+
+/* Static Methods */
+
+/**
+ * Determine if current browser supports this router
  *
- * @method
+ * @return {boolean} The browser is supported
  */
-Router.prototype.checkRoute = function () {
-       var hash = this.getPath();
+OO.Router.static.isSupported = function () {
+       return 'onhashchange' in window;
+};
 
-       $.each( this.routes, function ( id, entry ) {
-               return !matchRoute( hash, entry );
-       } );
+/* Methods */
+
+/**
+ * Check the current route and run appropriate callback if it matches.
+ */
+OO.Router.prototype.checkRoute = function () {
+       var id, entry, match,
+               hash = this.getPath();
+
+       for ( id in this.registry ) {
+               entry = this.registry[ id ];
+               match = hash.match( entry.path );
+               if ( match ) {
+                       entry.callback.apply( this, match.slice( 1 ) );
+                       return;
+               }
+       }
 };
 
 /**
  * Bind a specific callback to a hash-based route, e.g.
  *
  *     @example
- *     route( 'alert', function () { alert( 'something' ); } );
- *     route( /hi-(.*)/, function ( name ) { alert( 'Hi ' + name ) } );
+ *     addRoute( 'alert', function () { alert( 'something' ); } );
+ *     addRoute( /hi-(.*)/, function ( name ) { alert( 'Hi ' + name ) } );
+ *
  * Note that after defining all available routes it is up to the caller
  * to check the existing route via the checkRoute method.
  *
- * @method
- * @param {Object} path string or RegExp to match.
+ * @param {string|RegExp} path Path to match, string or regular expression
  * @param {Function} callback Callback to be run when hash changes to one
  * that matches.
  */
-Router.prototype.route = function ( path, callback ) {
+OO.Router.prototype.addRoute = function ( path, callback ) {
        var entry = {
                path: typeof path === 'string' ?
-                       new RegExp( '^' + path.replace( /[\\^$*+?.()|[\]{}]/g, '\\$&' ) + '$' )
-                       path,
+                       new RegExp( '^' + path.replace( /[\\^$*+?.()|[\]{}]/g, '\\$&' ) + '$' ) :
+                       path,
                callback: callback
        };
-       this.routes[ entry.path ] = entry;
+       this.register( entry.path.toString(), entry );
 };
 
+/**
+ * @deprecated Use #addRoute
+ */
+OO.Router.prototype.route = OO.Router.prototype.addRoute;
+
 /**
  * Navigate to a specific route.
  *
- * @method
- * @param {string} path string with a route (hash without #).
+ * @param {string} title of new page
+ * @param {Object} options
+ * @param {string} options.path e.g. '/path/' or '/path/#foo'
+ * @param {boolean} options.useReplaceState Set replaceStateState to use pushState when you want to
+ *   avoid long history queues.
  */
-Router.prototype.navigate = function ( path ) {
-       var history = window.history;
+OO.Router.prototype.navigateTo = function ( title, options ) {
+       if ( options.useReplaceState ) {
+               history.replaceState( null, title, options.path );
+       } else {
+               history.pushState( null, title, options.path );
+       }
+};
+
+/**
+ * Navigate to a specific ''hash fragment'' route.
+ *
+ * @param {string} path String with a route (hash without #).
+ * @deprecated use navigateTo instead
+ */
+OO.Router.prototype.navigate = function ( path ) {
        // Take advantage of `pushState` when available, to clear the hash and
        // not leave `#` in the history. An entry with `#` in the history has
        // the side-effect of resetting the scroll position when navigating the
        // history.
-       if ( path === '' && history && history.pushState ) {
+       if ( path === '' ) {
                // To clear the hash we need to cut the hash from the URL.
                path = window.location.href.replace( /#.*$/, '' );
                history.pushState( null, document.title, path );
@@ -141,30 +177,22 @@ Router.prototype.navigate = function ( path ) {
        }
 };
 
-/**
- * Triggers back on the window
- */
-Router.prototype.goBack = function () {
-       window.history.back();
-};
-
 /**
  * Navigate to the previous route. This is a wrapper for window.history.back
  *
- * @method
- * @return {jQuery.Deferred}
+ * @return {jQuery.Promise} Promise which resolves when the back navigation is complete
  */
-Router.prototype.back = function () {
-       var deferredRequest = $.Deferred(),
-               self = this,
-               timeoutID;
+OO.Router.prototype.back = function () {
+       var timeoutID,
+               router = this,
+               deferred = $.Deferred();
 
        this.once( 'popstate', function () {
                clearTimeout( timeoutID );
-               deferredRequest.resolve();
+               deferred.resolve();
        } );
 
-       this.goBack();
+       window.history.back();
 
        // If for some reason (old browser, bug in IE/windows 8.1, etc) popstate doesn't fire,
        // resolve manually. Since we don't know for sure which browsers besides IE10/11 have
@@ -173,33 +201,29 @@ Router.prototype.back = function () {
        // See https://connect.microsoft.com/IE/feedback/details/793618/history-back-popstate-not-working-as-expected-in-webview-control
        // Give browser a few ms to update its history.
        timeoutID = setTimeout( function () {
-               self.off( 'popstate' );
-               deferredRequest.resolve();
+               router.off( 'popstate' );
+               deferred.resolve();
        }, 50 );
 
-       return deferredRequest;
+       return deferred.promise();
 };
 
 /**
  * Get current path (hash).
  *
- * @method
  * @return {string} Current path.
  */
-Router.prototype.getPath = function () {
+OO.Router.prototype.getPath = function () {
        return window.location.hash.slice( 1 );
 };
 
 /**
- * Determine if current browser supports onhashchange event
- *
- * @method
- * @return {boolean}
+ * @deprecated Use static method
  */
-Router.prototype.isSupported = function () {
-       return 'onhashchange' in window;
-};
+OO.Router.prototype.isSupported = OO.Router.static.isSupported;
 
-module.exports = Router;
+if ( typeof module !== 'undefined' && module.exports ) {
+       module.exports = OO.Router;
+}
 
 }( jQuery ) );
index 7bab542..9e18eb0 100644 (file)
@@ -44,37 +44,37 @@ class ApiComparePagesTest extends ApiTestCase {
                self::$repl['revA2'] = $this->addPage( 'A', 'A 2' );
                self::$repl['revA3'] = $this->addPage( 'A', 'A 3' );
                self::$repl['revA4'] = $this->addPage( 'A', 'A 4' );
-               self::$repl['pageA'] = Title::newFromText( 'ApiComparePagesTest A' )->getArticleId();
+               self::$repl['pageA'] = Title::newFromText( 'ApiComparePagesTest A' )->getArticleID();
 
                self::$repl['revB1'] = $this->addPage( 'B', 'B 1' );
                self::$repl['revB2'] = $this->addPage( 'B', 'B 2' );
                self::$repl['revB3'] = $this->addPage( 'B', 'B 3' );
                self::$repl['revB4'] = $this->addPage( 'B', 'B 4' );
-               self::$repl['pageB'] = Title::newFromText( 'ApiComparePagesTest B' )->getArticleId();
+               self::$repl['pageB'] = Title::newFromText( 'ApiComparePagesTest B' )->getArticleID();
 
                self::$repl['revC1'] = $this->addPage( 'C', 'C 1' );
                self::$repl['revC2'] = $this->addPage( 'C', 'C 2' );
                self::$repl['revC3'] = $this->addPage( 'C', 'C 3' );
-               self::$repl['pageC'] = Title::newFromText( 'ApiComparePagesTest C' )->getArticleId();
+               self::$repl['pageC'] = Title::newFromText( 'ApiComparePagesTest C' )->getArticleID();
 
                $id = $this->addPage( 'D', 'D 1' );
-               self::$repl['pageD'] = Title::newFromText( 'ApiComparePagesTest D' )->getArticleId();
+               self::$repl['pageD'] = Title::newFromText( 'ApiComparePagesTest D' )->getArticleID();
                wfGetDB( DB_MASTER )->delete( 'revision', [ 'rev_id' => $id ] );
 
                self::$repl['revE1'] = $this->addPage( 'E', 'E 1' );
                self::$repl['revE2'] = $this->addPage( 'E', 'E 2' );
                self::$repl['revE3'] = $this->addPage( 'E', 'E 3' );
                self::$repl['revE4'] = $this->addPage( 'E', 'E 4' );
-               self::$repl['pageE'] = Title::newFromText( 'ApiComparePagesTest E' )->getArticleId();
+               self::$repl['pageE'] = Title::newFromText( 'ApiComparePagesTest E' )->getArticleID();
                wfGetDB( DB_MASTER )->update(
                        'page', [ 'page_latest' => 0 ], [ 'page_id' => self::$repl['pageE'] ]
                );
 
                self::$repl['revF1'] = $this->addPage( 'F', "== Section 1 ==\nF 1.1\n\n== Section 2 ==\nF 1.2" );
-               self::$repl['pageF'] = Title::newFromText( 'ApiComparePagesTest F' )->getArticleId();
+               self::$repl['pageF'] = Title::newFromText( 'ApiComparePagesTest F' )->getArticleID();
 
                self::$repl['revG1'] = $this->addPage( 'G', "== Section 1 ==\nG 1.1", CONTENT_MODEL_TEXT );
-               self::$repl['pageG'] = Title::newFromText( 'ApiComparePagesTest G' )->getArticleId();
+               self::$repl['pageG'] = Title::newFromText( 'ApiComparePagesTest G' )->getArticleID();
 
                WikiPage::factory( Title::newFromText( 'ApiComparePagesTest C' ) )
                        ->doDeleteArticleReal( 'Test for ApiComparePagesTest' );
index 3fa8539..1e66a7d 100644 (file)
@@ -36,7 +36,7 @@ class ApiMoveTest extends ApiTestCase {
                        $this->assertSame( $toTitle->getPrefixedText(), $target->getPrefixedText() );
                }
 
-               $this->assertSame( $id, $toTitle->getArticleId() );
+               $this->assertSame( $id, $toTitle->getArticleID() );
        }
 
        /**
@@ -126,7 +126,7 @@ class ApiMoveTest extends ApiTestCase {
                                'to' => '[',
                        ] );
                } finally {
-                       $this->assertSame( $id, Title::newFromText( $name )->getArticleId() );
+                       $this->assertSame( $id, Title::newFromText( $name )->getArticleID() );
                }
        }
 
@@ -161,7 +161,7 @@ class ApiMoveTest extends ApiTestCase {
                                'to' => "$name 3",
                        ] );
                } finally {
-                       $this->assertSame( $id, Title::newFromText( "$name 2" )->getArticleId() );
+                       $this->assertSame( $id, Title::newFromText( "$name 2" )->getArticleID() );
                        $this->assertFalse( Title::newFromText( "$name 3" )->exists(),
                                "\"$name 3\" should not exist" );
                }
@@ -187,7 +187,7 @@ class ApiMoveTest extends ApiTestCase {
                                'tags' => 'custom tag',
                        ] );
                } finally {
-                       $this->assertSame( $id, Title::newFromText( $name )->getArticleId() );
+                       $this->assertSame( $id, Title::newFromText( $name )->getArticleID() );
                        $this->assertFalse( Title::newFromText( "$name 2" )->exists(),
                                "\"$name 2\" should not exist" );
                }
@@ -241,9 +241,9 @@ class ApiMoveTest extends ApiTestCase {
                ] );
 
                $this->assertMoved( $name, "$name 2", $id );
-               $this->assertSame( $talkId, Title::newFromText( "Talk:$name" )->getArticleId() );
+               $this->assertSame( $talkId, Title::newFromText( "Talk:$name" )->getArticleID() );
                $this->assertSame( $talkDestinationId,
-                       Title::newFromText( "Talk:$name 2" )->getArticleId() );
+                       Title::newFromText( "Talk:$name 2" )->getArticleID() );
                $this->assertSame( [ [
                        'message' => 'articleexists',
                        'params' => [],
@@ -278,9 +278,9 @@ class ApiMoveTest extends ApiTestCase {
                }
 
                $this->assertSame( $ids["$name/error"],
-                       Title::newFromText( "$name/error" )->getArticleId() );
+                       Title::newFromText( "$name/error" )->getArticleID() );
                $this->assertSame( $ids["$name 2/error"],
-                       Title::newFromText( "$name 2/error" )->getArticleId() );
+                       Title::newFromText( "$name 2/error" )->getArticleID() );
 
                $results = array_merge( $res[0]['move']['subpages'], $res[0]['move']['subpages-talk'] );
                foreach ( $results as $arr ) {
@@ -317,7 +317,7 @@ class ApiMoveTest extends ApiTestCase {
                                'to' => "$name 2",
                        ], null, $user );
                } finally {
-                       $this->assertSame( $id, Title::newFromText( "$name" )->getArticleId() );
+                       $this->assertSame( $id, Title::newFromText( "$name" )->getArticleID() );
                        $this->assertFalse( Title::newFromText( "$name 2" )->exists(),
                                "\"$name 2\" should not exist" );
                }
@@ -372,7 +372,7 @@ class ApiMoveTest extends ApiTestCase {
                ] );
 
                $this->assertMoved( "Talk:$name", $name, $idBase );
-               $this->assertSame( $idSub, Title::newFromText( "Talk:$name/1" )->getArticleId() );
+               $this->assertSame( $idSub, Title::newFromText( "Talk:$name/1" )->getArticleID() );
                $this->assertFalse( Title::newFromText( "$name/1" )->exists(),
                        "\"$name/1\" should not exist" );
 
index 95cb3b7..dc7678d 100644 (file)
@@ -38,7 +38,7 @@ class PageRestrictionTest extends RestrictionTestCase {
 
                $restriction = new $class( 1, 1 );
                $title = \Title::newFromId( 1 );
-               $this->assertEquals( $title->getArticleId(), $restriction->getTitle()->getArticleId() );
+               $this->assertEquals( $title->getArticleID(), $restriction->getTitle()->getArticleID() );
        }
 
        public function testNewFromRow() {
index 570291c..7d37881 100644 (file)
@@ -245,7 +245,7 @@ class BlockListPagerTest extends MediaWikiTestCase {
 
                $restriction = $restrictions[0];
                $this->assertEquals( $page->getId(), $restriction->getValue() );
-               $this->assertEquals( $page->getId(), $restriction->getTitle()->getArticleId() );
+               $this->assertEquals( $page->getId(), $restriction->getTitle()->getArticleID() );
                $this->assertEquals( $title->getDBKey(), $restriction->getTitle()->getDBKey() );
                $this->assertEquals( $title->getNamespace(), $restriction->getTitle()->getNamespace() );