Merge "Prefill username in form when calling Special:Log/<username>"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 26 Jul 2018 20:06:13 +0000 (20:06 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 26 Jul 2018 20:06:13 +0000 (20:06 +0000)
29 files changed:
.phpcs.xml
INSTALL
RELEASE-NOTES-1.32
composer.json
img_auth.php
includes/EditPage.php
includes/Revision.php
includes/Status.php
includes/Storage/DerivedPageDataUpdater.php
includes/Storage/RevisionSlots.php
includes/Storage/RevisionStore.php
includes/Title.php
includes/deferred/LinksUpdate.php
includes/htmlform/fields/HTMLSelectAndOtherField.php
includes/htmlform/fields/HTMLSelectOrOtherField.php
includes/libs/http/HttpAcceptParser.php
includes/libs/lockmanager/DBLockManager.php
includes/libs/objectcache/BagOStuff.php
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/IDatabase.php
includes/linkeddata/PageDataRequestHandler.php
includes/parser/ParserOptions.php
includes/site/DBSiteStore.php
includes/utils/UIDGenerator.php
includes/widget/SelectWithInputWidget.php
languages/i18n/en.json
tests/parser/ParserTestRunner.php
tests/phpunit/includes/GlobalFunctions/WfExpandUrlTest.php [new file with mode: 0644]
tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php [deleted file]

index 8d33f69..2a34154 100644 (file)
@@ -2,6 +2,7 @@
 <ruleset name="MediaWiki">
        <rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
                <exclude name="Generic.ControlStructures.InlineControlStructure" />
+               <exclude name="MediaWiki.Commenting.FunctionAnnotations.UnrecognizedAnnotation" />
                <exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
                <exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
                <exclude name="MediaWiki.Commenting.FunctionComment.MissingParamTag" />
                <exclude name="MediaWiki.Commenting.IllegalSingleLineComment.IllegalSingleLineCommentStart" />
                <exclude name="MediaWiki.Commenting.IllegalSingleLineComment.IllegalSingleLineCommentEnd" />
                <exclude name="MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures" />
+               <exclude name="MediaWiki.Commenting.MissingCovers.MissingCovers" />
                <exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
-               <exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
-               <exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.SingleSpaceBeforeSingleLineComment" />
                <exclude name="MediaWiki.Usage.DbrQueryUsage.DbrQueryFound" />
                <exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage" />
+               <exclude name="MediaWiki.Usage.ForbiddenFunctions.passthru" />
                <exclude name="MediaWiki.VariableAnalysis.ForbiddenGlobalVariables.ForbiddenGlobal$wgTitle" />
+               <exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
+               <exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.SingleSpaceBeforeSingleLineComment" />
                <exclude name="Squiz.Scope.MethodScope.Missing" />
                <exclude name="Squiz.Scope.MemberVarScope.Missing" />
-               <exclude name="MediaWiki.Commenting.MissingCovers.MissingCovers" />
        </rule>
        <rule ref="MediaWiki.NamingConventions.PrefixedGlobalFunctions">
                <properties>
                        <property name="ignoreList" type="array" value="$IP,$messageMemc" />
                </properties>
        </rule>
+       <rule ref="MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix">
+               <exclude-pattern>profileinfo\.php</exclude-pattern>
+               <exclude-pattern>maintenance/language/checkLanguage\.inc</exclude-pattern>
+               <exclude-pattern>maintenance/doMaintenance\.php</exclude-pattern>
+               <exclude-pattern>maintenance/mergeMessageFileList\.php</exclude-pattern>
+               <exclude-pattern>maintenance/commandLine\.inc</exclude-pattern>
+       </rule>
        <rule ref="Generic.Files.LineLength">
                <exclude-pattern>*/languages/messages/Messages*\.php</exclude-pattern>
        </rule>
diff --git a/INSTALL b/INSTALL
index 91dcbea..d68342c 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -17,9 +17,6 @@ Required software:
 MediaWiki is developed and tested mainly on Unix/Linux platforms, but should
 work on Windows as well.
 
-If your PHP is configured as a CGI plug-in rather than an Apache module you may
-experience problems, as this configuration is not well tested.
-
 Support for rendering mathematical formulas requires installing the Math extension,
 see https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:Math
 
index c91ae7d..0497531 100644 (file)
@@ -65,6 +65,8 @@ production.
 * Updated wikimedia/scoped-callback from 1.0.0 to 2.0.0.
 ** ScopedCallback objects can no longer be serialized.
 * Updated wikimedia/wrappedstring from 2.3.0 to 3.0.1.
+* Updated mediawiki/mediawiki-codesniffer from v20.0.0 to v21.0.0.
+* Updated composer/spdx-licenses from 1.3.0 to 1.4.0.
 
 ==== New external libraries ====
 * Added wikimedia/xmp-reader 0.5.1
index b16983f..dbc59a2 100644 (file)
        },
        "require-dev": {
                "cache/integration-tests": "0.16.0",
-               "composer/spdx-licenses": "1.3.0",
+               "composer/spdx-licenses": "1.4.0",
                "hamcrest/hamcrest-php": "^2.0",
                "jakub-onderka/php-parallel-lint": "0.9.2",
-               "jetbrains/phpstorm-stubs": "dev-master#1b9906084d6635456fcf3f3a01f0d7d5b99a578a",
+               "jetbrains/phpstorm-stubs": "dev-master#38ff1a581b297f7901e961b8c923862ea80c3b96",
                "justinrainbow/json-schema": "~5.2",
-               "mediawiki/mediawiki-codesniffer": "20.0.0",
+               "mediawiki/mediawiki-codesniffer": "21.0.0",
                "monolog/monolog": "~1.22.1",
                "nikic/php-parser": "3.1.3",
                "seld/jsonlint": "1.7.1",
index 2052809..ca69d31 100644 (file)
@@ -17,7 +17,8 @@
  *  just that it was. If you want to change this, you can set $wgImgAuthDetails to 'true'
  *  in localsettings.php and it will give the user the reason why access was denied.
  *
- * Your server needs to support PATH_INFO; CGI-based configurations usually don't.
+ * Your server needs to support REQUEST_URI or PATH_INFO; CGI-based
+ * configurations sometimes don't.
  *
  * 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
index a1cf3e2..16f1c5a 100644 (file)
@@ -2361,7 +2361,7 @@ ERROR;
         * Returns the revision that was current at the time editing was initiated on the client,
         * even if the edit was based on an old revision.
         *
-        * @warning: this method is very poorly named. If the user opened the form with ?oldid=X,
+        * @warning this method is very poorly named. If the user opened the form with ?oldid=X,
         *        one might think of X as the "base revision", which is NOT what this returns,
         *        see oldid for that. One might further assume that this corresponds to the $baseRevId
         *        parameter of WikiPage::doEditContent, which is not the case either.
index d6ff384..7ff73dd 100644 (file)
@@ -739,7 +739,7 @@ class Revision implements IDBAccessObject {
        /**
         * Set the title of the revision
         *
-        * @deprecated: since 1.31, this is now a noop. Pass the Title to the constructor instead.
+        * @deprecated since 1.31, this is now a noop. Pass the Title to the constructor instead.
         *
         * @param Title $title
         */
@@ -927,7 +927,7 @@ class Revision implements IDBAccessObject {
         * used to determine the content model to use. If no title is know, CONTENT_MODEL_WIKITEXT
         * is used as a last resort.
         *
-        * @todo: drop this, with MCR, there no longer is a single model associated with a revision.
+        * @todo drop this, with MCR, there no longer is a single model associated with a revision.
         *
         * @return string The content model id associated with this revision,
         *     see the CONTENT_MODEL_XXX constants.
@@ -942,7 +942,7 @@ class Revision implements IDBAccessObject {
         * If no content format was stored in the database, the default format for this
         * revision's content model is returned.
         *
-        * @todo: drop this, the format is irrelevant to the revision!
+        * @todo drop this, the format is irrelevant to the revision!
         *
         * @return string The content format id associated with this revision,
         *     see the CONTENT_FORMAT_XXX constants.
index 8cd72a5..877d221 100644 (file)
@@ -359,7 +359,7 @@ class Status extends StatusValue {
        /**
         * Returns a list of status messages of the given type (or all if false)
         *
-        * @note: this handles RawMessage poorly
+        * @note this handles RawMessage poorly
         *
         * @param string|bool $type
         * @return array
index 73463b5..6f241ba 100644 (file)
@@ -679,11 +679,11 @@ class DerivedPageDataUpdater implements IDBAccessObject {
         *
         * @see docs/pageupdater.txt for more information on when thie method can and should be called.
         *
-        * @note: Calling this method more than once with the same $slotsUpdate
+        * @note Calling this method more than once with the same $slotsUpdate
         * has no effect. Calling this method multiple times with different content will cause
         * an exception.
         *
-        * @note: Calling this method after prepareUpdate() has been called will cause an exception.
+        * @note Calling this method after prepareUpdate() has been called will cause an exception.
         *
         * @param User $user The user to act as context for pre-save transformation (PST).
         *        Type hint should be reduced to UserIdentity at some point.
@@ -826,7 +826,7 @@ class DerivedPageDataUpdater implements IDBAccessObject {
        /**
         * Whether the edit created, or should create, a new revision (that is, it's not a null-edit).
         *
-        * @warning: at present, "null-revisions" that do not change content but do have a revision
+        * @warning at present, "null-revisions" that do not change content but do have a revision
         * record would return false after prepareContent(), but true after prepareUpdate()!
         * This should probably be fixed.
         *
@@ -931,11 +931,11 @@ class DerivedPageDataUpdater implements IDBAccessObject {
         *
         * @see docs/pageupdater.txt for more information on when thie method can and should be called.
         *
-        * @note: Calling this method more than once with the same revision has no effect.
+        * @note Calling this method more than once with the same revision has no effect.
         * $options are only used for the first call. Calling this method multiple times with
         * different revisions will cause an exception.
         *
-        * @note: If grabCurrentRevision() (or prepareContent()) has been called before
+        * @note If grabCurrentRevision() (or prepareContent()) has been called before
         * calling this method, $revision->getParentRevision() has to refer to the revision that
         * was the current revision at the time grabCurrentRevision() was called.
         *
index ba9780f..91969fc 100644 (file)
@@ -139,7 +139,7 @@ class RevisionSlots {
        /**
         * Computes the total nominal size of the revision's slots, in bogo-bytes.
         *
-        * @warn This is potentially expensive! It may cause all slot's content to be loaded
+        * @warning This is potentially expensive! It may cause all slot's content to be loaded
         * and deserialized.
         *
         * @return int
@@ -181,7 +181,7 @@ class RevisionSlots {
         * is that slot's hash. For consistency, the combined hash of an empty set of slots
         * is the hash of the empty string.
         *
-        * @warn This is potentially expensive! It may cause all slot's content to be loaded
+        * @warning This is potentially expensive! It may cause all slot's content to be loaded
         * and deserialized, then re-serialized and hashed.
         *
         * @return string
index 602364c..d090d8b 100644 (file)
@@ -917,7 +917,7 @@ class RevisionStore
         * Such revisions can for instance identify page rename
         * operations and other such meta-modifications.
         *
-        * @note: This method grabs a FOR UPDATE lock on the relevant row of the page table,
+        * @note This method grabs a FOR UPDATE lock on the relevant row of the page table,
         * to prevent a new revision from being inserted before the null revision has been written
         * to the database.
         *
index b583554..f6bc947 100644 (file)
@@ -306,6 +306,10 @@ class Title implements LinkTarget {
        public static function newFromTextThrow( $text, $defaultNamespace = NS_MAIN ) {
                if ( is_object( $text ) ) {
                        throw new MWException( '$text must be a string, given an object' );
+               } elseif ( $text === null ) {
+                       // Legacy code relies on MalformedTitleException being thrown in this case
+                       // (happens when URL with no title in it is parsed). TODO fix
+                       throw new MalformedTitleException( 'title-invalid-empty' );
                }
 
                $titleCache = self::getTitleCache();
index 5c82f09..39e8bd9 100644 (file)
@@ -161,7 +161,7 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate {
        /**
         * Update link tables with outgoing links from an updated article
         *
-        * @note: this is managed by DeferredUpdates::execute(). Do not run this in a transaction.
+        * @note this is managed by DeferredUpdates::execute(). Do not run this in a transaction.
         */
        public function doUpdate() {
                if ( $this->ticket ) {
index a4d9bca..4e64e9d 100644 (file)
@@ -119,8 +119,14 @@ class HTMLSelectAndOtherField extends HTMLSelectField {
                        $dropdownInputAttribs['classes'] = [ $this->mClass ];
                }
 
+               $disabled = false;
+               if ( isset( $this->mParams[ 'disabled' ] ) && $this->mParams[ 'disabled' ] ) {
+                       $disabled = true;
+               }
+
                return $this->getInputWidget( [
                        'id' => $this->mID,
+                       'disabled' => $disabled,
                        'textinput' => $textAttribs,
                        'dropdowninput' => $dropdownInputAttribs,
                        'or' => false,
index 91050a0..47c1f18 100644 (file)
@@ -125,8 +125,14 @@ class HTMLSelectOrOtherField extends HTMLTextField {
                        $textAttribs['placeholder'] = $this->mPlaceholder;
                }
 
+               $disabled = false;
+               if ( isset( $this->mParams[ 'disabled' ] ) && $this->mParams[ 'disabled' ] ) {
+                       $disabled = true;
+               }
+
                return $this->getInputWidget( [
                        'id' => $this->mID,
+                       'disabled' => $disabled,
                        'textinput' => $textAttribs,
                        'dropdowninput' => $dropdownAttribs,
                        'or' => true,
index df22b41..93f5b0b 100644 (file)
@@ -23,7 +23,7 @@ class HttpAcceptParser {
         * Note that type parameters and accept extension like the "level" parameter
         * are not supported, weights are derived from "q" values only.
         *
-        * @todo: If additional type parameters are present, ignore them cleanly.
+        * @todo If additional type parameters are present, ignore them cleanly.
         *        At present, they often confuse the result.
         *
         * See HTTP/1.1 section 14 for details.
index aec9f25..5e8c22b 100644 (file)
@@ -94,7 +94,7 @@ abstract class DBLockManager extends QuorumLockManager {
        }
 
        /**
-        * @TODO change this code to work in one batch
+        * @todo change this code to work in one batch
         * @param string $lockSrv
         * @param array $pathsByType
         * @return StatusValue
index e03645f..82ae5ae 100644 (file)
@@ -238,7 +238,7 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface {
        abstract protected function doGet( $key, $flags = 0 );
 
        /**
-        * @note: This method is only needed if merge() uses mergeViaCas()
+        * @note This method is only needed if merge() uses mergeViaCas()
         *
         * @param string $key
         * @param mixed &$casToken
index dc3260d..4070a02 100644 (file)
@@ -287,7 +287,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        const STATUS_TRX_NONE = 3;
 
        /**
-        * @note: exceptions for missing libraries/drivers should be thrown in initConnection()
+        * @note exceptions for missing libraries/drivers should be thrown in initConnection()
         * @param array $params Parameters passed from Database::factory()
         */
        protected function __construct( array $params ) {
index 1ac7d09..61788e1 100644 (file)
@@ -32,7 +32,7 @@ use stdClass;
 /**
  * Basic database interface for live and lazy-loaded relation database handles
  *
- * @note: IDatabase and DBConnRef should be updated to reflect any changes
+ * @note IDatabase and DBConnRef should be updated to reflect any changes
  * @ingroup Database
  */
 interface IDatabase {
@@ -1500,7 +1500,7 @@ interface IDatabase {
         *
         * This is useful for combining cooperative locks and DB transactions.
         *
-        * @note: do not assume that *other* IDatabase instances will be AUTOCOMMIT mode
+        * @note do not assume that *other* IDatabase instances will be AUTOCOMMIT mode
         *
         * The callback takes the following arguments:
         *   - How the transaction ended (IDatabase::TRIGGER_COMMIT or IDatabase::TRIGGER_ROLLBACK)
@@ -1535,7 +1535,7 @@ interface IDatabase {
         *
         * Updates will execute in the order they were enqueued.
         *
-        * @note: do not assume that *other* IDatabase instances will be AUTOCOMMIT mode
+        * @note do not assume that *other* IDatabase instances will be AUTOCOMMIT mode
         *
         * The callback takes the following arguments:
         *   - How the transaction ended (IDatabase::TRIGGER_COMMIT or IDatabase::TRIGGER_IDLE)
@@ -1623,7 +1623,7 @@ interface IDatabase {
         *   - The failures are from contention solvable via onTransactionPreCommitOrIdle()
         *   - The failures are deadlocks; the RDBMs usually discard the whole transaction
         *
-        * @note: callers must use additional measures for situations involving two or more
+        * @note callers must use additional measures for situations involving two or more
         *   (peer) transactions (e.g. updating two database servers at once). The transaction
         *   and savepoint logic of this method only applies to this specific IDatabase instance.
         *
@@ -1702,7 +1702,7 @@ interface IDatabase {
         * corresponding startAtomic() implicitly started a transaction, that
         * transaction is rolled back.
         *
-        * @note: callers must use additional measures for situations involving two or more
+        * @note callers must use additional measures for situations involving two or more
         *   (peer) transactions (e.g. updating two database servers at once). The transaction
         *   and savepoint logic of startAtomic() are bound to specific IDatabase instances.
         *
index c8d111d..d70688f 100644 (file)
@@ -72,7 +72,7 @@ class PageDataRequestHandler {
         *        - oldid|revision: the revision ID
         * @param OutputPage $output
         *
-        * @note: Instead of an output page, a WebResponse could be sufficient, but
+        * @note Instead of an output page, a WebResponse could be sufficient, but
         *        redirect logic is currently implemented in OutputPage.
         *
         * @throws HttpError
index c8e68b2..e4b064e 100644 (file)
@@ -666,7 +666,7 @@ class ParserOptions {
        /**
         * Get the user language used by the parser for this page and split the parser cache.
         *
-        * @warning: Calling this causes the parser cache to be fragmented by user language!
+        * @warning Calling this causes the parser cache to be fragmented by user language!
         * To avoid cache fragmentation, output should not depend on the user language.
         * Use Parser::getFunctionLang() or Parser::getTargetLanguage() instead!
         *
@@ -687,7 +687,7 @@ class ParserOptions {
        /**
         * Same as getUserLangObj() but returns a string instead.
         *
-        * @warning: Calling this causes the parser cache to be fragmented by user language!
+        * @warning Calling this causes the parser cache to be fragmented by user language!
         * To avoid cache fragmentation, output should not depend on the user language.
         * Use Parser::getFunctionLang() or Parser::getTargetLanguage() instead!
         *
index 54d9e9c..b2403ce 100644 (file)
@@ -45,7 +45,7 @@ class DBSiteStore implements SiteStore {
        /**
         * @since 1.27
         *
-        * @todo: inject some kind of connection manager that is aware of the target wiki,
+        * @todo inject some kind of connection manager that is aware of the target wiki,
         * instead of injecting a LoadBalancer.
         *
         * @param LoadBalancer $dbLoadBalancer
index c23d999..d184e92 100644 (file)
@@ -84,7 +84,7 @@ class UIDGenerator {
        }
 
        /**
-        * @todo: move to MW-specific factory class and inject temp dir
+        * @todo move to MW-specific factory class and inject temp dir
         * @return UIDGenerator
         */
        protected static function singleton() {
index 5ceed4c..262903d 100644 (file)
@@ -36,6 +36,11 @@ class SelectWithInputWidget extends \OOUI\Widget {
                        $config
                );
 
+               if ( isset( $config['disabled'] ) && $config['disabled'] == true ) {
+                       $config['textinput']['disabled'] = true;
+                       $config['dropdowninput']['disabled'] = true;
+               }
+
                parent::__construct( $config );
 
                // Properties
index 4e9681a..2210195 100644 (file)
        "uploadstash-zero-length": "File is zero length.",
        "invalid-chunk-offset": "Invalid chunk offset",
        "img-auth-accessdenied": "Access denied",
-       "img-auth-nopathinfo": "Missing PATH_INFO.\nYour server is not set up to pass this information.\nIt may be CGI-based and cannot support img_auth.\nSee https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Image_Authorization.",
+       "img-auth-nopathinfo": "Missing path information.\nYour server must be set up to pass the REQUEST_URI and/or PATH_INFO variables.\nIf it is, try enabling $wgUsePathInfo.\nSee https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Image_Authorization.",
        "img-auth-notindir": "Requested path is not in the configured upload directory.",
        "img-auth-badtitle": "Unable to construct a valid title from \"$1\".",
        "img-auth-nologinnWL": "You are not logged in and \"$1\" is not in the whitelist.",
index 68bc61e..5eb91c3 100644 (file)
@@ -1250,7 +1250,7 @@ class ParserTestRunner {
         * For best performance, call this once only for all tests. However, it can
         * be called at the start of each test if more isolation is desired.
         *
-        * @todo: This is basically an unrefactored copy of
+        * @todo This is basically an unrefactored copy of
         * MediaWikiTestCase::setupAllTestDBs. They should be factored out somehow.
         *
         * Do not call this function from a MediaWikiTestCase subclass, since
diff --git a/tests/phpunit/includes/GlobalFunctions/WfExpandUrlTest.php b/tests/phpunit/includes/GlobalFunctions/WfExpandUrlTest.php
new file mode 100644 (file)
index 0000000..f008830
--- /dev/null
@@ -0,0 +1,153 @@
+<?php
+/**
+ * @group GlobalFunctions
+ * @covers ::wfExpandUrl
+ */
+class WfExpandUrlTest extends MediaWikiTestCase {
+       /**
+        * @dataProvider provideExpandableUrls
+        */
+       public function testWfExpandUrl( $fullUrl, $shortUrl, $defaultProto,
+               $server, $canServer, $httpsMode, $httpsPort, $message
+       ) {
+               // Fake $wgServer, $wgCanonicalServer and $wgRequest->getProtocol()
+               // fake edit to fake globals
+               $this->setMwGlobals( [
+                       'wgServer' => $server,
+                       'wgCanonicalServer' => $canServer,
+                       'wgRequest' => new FauxRequest( [], false, null, $httpsMode ? 'https' : 'http' ),
+                       'wgHttpsPort' => $httpsPort
+               ] );
+
+               $this->assertEquals( $fullUrl, wfExpandUrl( $shortUrl, $defaultProto ), $message );
+       }
+
+       /**
+        * Provider of URL examples for testing wfExpandUrl()
+        *
+        * @return array
+        */
+       public static function provideExpandableUrls() {
+               $modes = [ 'http', 'https' ];
+               $servers = [
+                       'http' => 'http://example.com',
+                       'https' => 'https://example.com',
+                       'protocol-relative' => '//example.com'
+               ];
+               $defaultProtos = [
+                       'http' => PROTO_HTTP,
+                       'https' => PROTO_HTTPS,
+                       'protocol-relative' => PROTO_RELATIVE,
+                       'current' => PROTO_CURRENT,
+                       'canonical' => PROTO_CANONICAL
+               ];
+
+               $retval = [];
+               foreach ( $modes as $mode ) {
+                       $httpsMode = $mode == 'https';
+                       foreach ( $servers as $serverDesc => $server ) {
+                               foreach ( $modes as $canServerMode ) {
+                                       $canServer = "$canServerMode://example2.com";
+                                       foreach ( $defaultProtos as $protoDesc => $defaultProto ) {
+                                               $retval[] = [
+                                                       'http://example.com', 'http://example.com',
+                                                       $defaultProto, $server, $canServer, $httpsMode, 443,
+                                                       "Testing fully qualified http URLs (no need to expand) "
+                                                               . "(defaultProto: $protoDesc , wgServer: $server, "
+                                                               . "wgCanonicalServer: $canServer, current request protocol: $mode )"
+                                               ];
+                                               $retval[] = [
+                                                       'https://example.com', 'https://example.com',
+                                                       $defaultProto, $server, $canServer, $httpsMode, 443,
+                                                       "Testing fully qualified https URLs (no need to expand) "
+                                                               . "(defaultProto: $protoDesc , wgServer: $server, "
+                                                               . "wgCanonicalServer: $canServer, current request protocol: $mode )"
+                                               ];
+                                               # Would be nice to support this, see fixme on wfExpandUrl()
+                                               $retval[] = [
+                                                       "wiki/FooBar", 'wiki/FooBar',
+                                                       $defaultProto, $server, $canServer, $httpsMode, 443,
+                                                       "Test non-expandable relative URLs (defaultProto: $protoDesc, "
+                                                               . "wgServer: $server, wgCanonicalServer: $canServer, "
+                                                               . "current request protocol: $mode )"
+                                               ];
+
+                                               // Determine expected protocol
+                                               if ( $protoDesc == 'protocol-relative' ) {
+                                                       $p = '';
+                                               } elseif ( $protoDesc == 'current' ) {
+                                                       $p = "$mode:";
+                                               } elseif ( $protoDesc == 'canonical' ) {
+                                                       $p = "$canServerMode:";
+                                               } else {
+                                                       $p = $protoDesc . ':';
+                                               }
+                                               // Determine expected server name
+                                               if ( $protoDesc == 'canonical' ) {
+                                                       $srv = $canServer;
+                                               } elseif ( $serverDesc == 'protocol-relative' ) {
+                                                       $srv = $p . $server;
+                                               } else {
+                                                       $srv = $server;
+                                               }
+
+                                               $retval[] = [
+                                                       "$p//wikipedia.org", '//wikipedia.org',
+                                                       $defaultProto, $server, $canServer, $httpsMode, 443,
+                                                       "Test protocol-relative URL (defaultProto: $protoDesc, "
+                                                               . "wgServer: $server, wgCanonicalServer: $canServer, "
+                                                               . "current request protocol: $mode )"
+                                               ];
+                                               $retval[] = [
+                                                       "$srv/wiki/FooBar",
+                                                       '/wiki/FooBar',
+                                                       $defaultProto,
+                                                       $server,
+                                                       $canServer,
+                                                       $httpsMode,
+                                                       443,
+                                                       "Testing expanding URL beginning with / (defaultProto: $protoDesc, "
+                                                               . "wgServer: $server, wgCanonicalServer: $canServer, "
+                                                               . "current request protocol: $mode )"
+                                               ];
+                                       }
+                               }
+                       }
+               }
+
+               // Don't add HTTPS port to foreign URLs
+               $retval[] = [
+                       'https://foreign.example.com/foo',
+                       'https://foreign.example.com/foo',
+                       PROTO_HTTPS,
+                       '//wiki.example.com',
+                       'http://wiki.example.com',
+                       'https',
+                       111,
+                       "Don't add HTTPS port to foreign URLs"
+               ];
+               $retval[] = [
+                       'https://foreign.example.com:222/foo',
+                       'https://foreign.example.com:222/foo',
+                       PROTO_HTTPS,
+                       '//wiki.example.com',
+                       'http://wiki.example.com',
+                       'https',
+                       111,
+                       "Don't overwrite HTTPS port of foreign URLs"
+               ];
+               // Do add HTTPS port to local URLs
+               $retval[] = [
+                       'https://wiki.example.com:111/foo',
+                       '/foo',
+                       PROTO_HTTPS,
+                       '//wiki.example.com',
+                       'http://wiki.example.com',
+                       'https',
+                       111,
+                       "Do add HTTPS port to protocol-relative URLs"
+               ];
+
+               return $retval;
+       }
+}
diff --git a/tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php b/tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php
deleted file mode 100644 (file)
index 159e4ad..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-<?php
-/**
- * @group GlobalFunctions
- * @covers ::wfExpandUrl
- */
-class WfExpandUrlTest extends MediaWikiTestCase {
-       /**
-        * @dataProvider provideExpandableUrls
-        */
-       public function testWfExpandUrl( $fullUrl, $shortUrl, $defaultProto,
-               $server, $canServer, $httpsMode, $httpsPort, $message
-       ) {
-               // Fake $wgServer, $wgCanonicalServer and $wgRequest->getProtocol()
-               $this->setMwGlobals( [
-                       'wgServer' => $server,
-                       'wgCanonicalServer' => $canServer,
-                       'wgRequest' => new FauxRequest( [], false, null, $httpsMode ? 'https' : 'http' ),
-                       'wgHttpsPort' => $httpsPort
-               ] );
-
-               $this->assertEquals( $fullUrl, wfExpandUrl( $shortUrl, $defaultProto ), $message );
-       }
-
-       /**
-        * Provider of URL examples for testing wfExpandUrl()
-        *
-        * @return array
-        */
-       public static function provideExpandableUrls() {
-               $modes = [ 'http', 'https' ];
-               $servers = [
-                       'http' => 'http://example.com',
-                       'https' => 'https://example.com',
-                       'protocol-relative' => '//example.com'
-               ];
-               $defaultProtos = [
-                       'http' => PROTO_HTTP,
-                       'https' => PROTO_HTTPS,
-                       'protocol-relative' => PROTO_RELATIVE,
-                       'current' => PROTO_CURRENT,
-                       'canonical' => PROTO_CANONICAL
-               ];
-
-               $retval = [];
-               foreach ( $modes as $mode ) {
-                       $httpsMode = $mode == 'https';
-                       foreach ( $servers as $serverDesc => $server ) {
-                               foreach ( $modes as $canServerMode ) {
-                                       $canServer = "$canServerMode://example2.com";
-                                       foreach ( $defaultProtos as $protoDesc => $defaultProto ) {
-                                               $retval[] = [
-                                                       'http://example.com', 'http://example.com',
-                                                       $defaultProto, $server, $canServer, $httpsMode, 443,
-                                                       "Testing fully qualified http URLs (no need to expand) "
-                                                               . "(defaultProto: $protoDesc , wgServer: $server, "
-                                                               . "wgCanonicalServer: $canServer, current request protocol: $mode )"
-                                               ];
-                                               $retval[] = [
-                                                       'https://example.com', 'https://example.com',
-                                                       $defaultProto, $server, $canServer, $httpsMode, 443,
-                                                       "Testing fully qualified https URLs (no need to expand) "
-                                                               . "(defaultProto: $protoDesc , wgServer: $server, "
-                                                               . "wgCanonicalServer: $canServer, current request protocol: $mode )"
-                                               ];
-                                               # Would be nice to support this, see fixme on wfExpandUrl()
-                                               $retval[] = [
-                                                       "wiki/FooBar", 'wiki/FooBar',
-                                                       $defaultProto, $server, $canServer, $httpsMode, 443,
-                                                       "Test non-expandable relative URLs (defaultProto: $protoDesc, "
-                                                               . "wgServer: $server, wgCanonicalServer: $canServer, "
-                                                               . "current request protocol: $mode )"
-                                               ];
-
-                                               // Determine expected protocol
-                                               if ( $protoDesc == 'protocol-relative' ) {
-                                                       $p = '';
-                                               } elseif ( $protoDesc == 'current' ) {
-                                                       $p = "$mode:";
-                                               } elseif ( $protoDesc == 'canonical' ) {
-                                                       $p = "$canServerMode:";
-                                               } else {
-                                                       $p = $protoDesc . ':';
-                                               }
-                                               // Determine expected server name
-                                               if ( $protoDesc == 'canonical' ) {
-                                                       $srv = $canServer;
-                                               } elseif ( $serverDesc == 'protocol-relative' ) {
-                                                       $srv = $p . $server;
-                                               } else {
-                                                       $srv = $server;
-                                               }
-
-                                               $retval[] = [
-                                                       "$p//wikipedia.org", '//wikipedia.org',
-                                                       $defaultProto, $server, $canServer, $httpsMode, 443,
-                                                       "Test protocol-relative URL (defaultProto: $protoDesc, "
-                                                               . "wgServer: $server, wgCanonicalServer: $canServer, "
-                                                               . "current request protocol: $mode )"
-                                               ];
-                                               $retval[] = [
-                                                       "$srv/wiki/FooBar",
-                                                       '/wiki/FooBar',
-                                                       $defaultProto,
-                                                       $server,
-                                                       $canServer,
-                                                       $httpsMode,
-                                                       443,
-                                                       "Testing expanding URL beginning with / (defaultProto: $protoDesc, "
-                                                               . "wgServer: $server, wgCanonicalServer: $canServer, "
-                                                               . "current request protocol: $mode )"
-                                               ];
-                                       }
-                               }
-                       }
-               }
-
-               // Don't add HTTPS port to foreign URLs
-               $retval[] = [
-                       'https://foreign.example.com/foo',
-                       'https://foreign.example.com/foo',
-                       PROTO_HTTPS,
-                       '//wiki.example.com',
-                       'http://wiki.example.com',
-                       'https',
-                       111,
-                       "Don't add HTTPS port to foreign URLs"
-               ];
-               $retval[] = [
-                       'https://foreign.example.com:222/foo',
-                       'https://foreign.example.com:222/foo',
-                       PROTO_HTTPS,
-                       '//wiki.example.com',
-                       'http://wiki.example.com',
-                       'https',
-                       111,
-                       "Don't overwrite HTTPS port of foreign URLs"
-               ];
-               // Do add HTTPS port to local URLs
-               $retval[] = [
-                       'https://wiki.example.com:111/foo',
-                       '/foo',
-                       PROTO_HTTPS,
-                       '//wiki.example.com',
-                       'http://wiki.example.com',
-                       'https',
-                       111,
-                       "Do add HTTPS port to protocol-relative URLs"
-               ];
-
-               return $retval;
-       }
-}