<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>
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
* 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
},
"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",
* 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
* 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.
/**
* 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
*/
* 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.
* 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.
/**
* 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
*
* @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.
/**
* 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.
*
*
* @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.
*
/**
* 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
* 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
* 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.
*
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();
/**
* 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 ) {
$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,
$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,
* 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.
}
/**
- * @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
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
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 ) {
/**
* 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 {
*
* 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)
*
* 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)
* - 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.
*
* 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.
*
* - 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
/**
* 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!
*
/**
* 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!
*
/**
* @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
}
/**
- * @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() {
$config
);
+ if ( isset( $config['disabled'] ) && $config['disabled'] == true ) {
+ $config['textinput']['disabled'] = true;
+ $config['dropdowninput']['disabled'] = true;
+ }
+
parent::__construct( $config );
// Properties
"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.",
* 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
--- /dev/null
+<?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;
+ }
+}
+++ /dev/null
-<?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;
- }
-}