From: jenkins-bot Date: Thu, 4 Aug 2016 09:30:53 +0000 (+0000) Subject: Merge "Move MediaHandler defaults out of global scope" X-Git-Tag: 1.31.0-rc.0~6172 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%29%20.%20%22?a=commitdiff_plain;h=1cdd4682ed43ffe4d95597e54836189ca974404b;hp=1b1b3cdb5438e4b649e425e0334c3a72bfca0598;p=lhc%2Fweb%2Fwiklou.git Merge "Move MediaHandler defaults out of global scope" --- diff --git a/RELEASE-NOTES-1.28 b/RELEASE-NOTES-1.28 index c8bf207b16..757cec3a22 100644 --- a/RELEASE-NOTES-1.28 +++ b/RELEASE-NOTES-1.28 @@ -36,6 +36,8 @@ production. * Added a new hook, 'UploadVerifyUpload', which can be used to reject a file upload. Unlike 'UploadVerifyFile' it provides information about upload comment and the file description page, but does not run for uploads to stash. +* (T141604) Extensions can now provide a better error message when their + maintenance scripts are run without the extension being installed. === External library changes in 1.28 === @@ -51,6 +53,11 @@ production. === Action API changes in 1.28 === * Added 'maxarticlesize' property to action=query&meta=siteinfo which contains the value of $wgMaxArticleSize. +* Property 'modulemessages' from action=parse&prop=modules was removed + (deprecated since 1.26). +* The following response properties from action=login, deprecated in 1.27, are + now removed: lgtoken, cookieprefix, sessionid. Clients should handle cookies + to properly manage session state. === Action API internal changes in 1.28 === * Added a new hook, 'ApiMakeParserOptions', to allow extensions to better @@ -77,6 +84,24 @@ changes to languages because of Phabricator reports. * The 'UserLoginComplete' hook has a new parameter to differentiate between actual login and visiting the login page while already logged in. * ResourceLoader::makeLoaderURL() was removed (deprecated since 1.24). +* $.fn.liveAndTestAtStart was removed (deprecated since 1.24). +* Linker::link() and Linker::linkKnown() were deprecated; please instead use + MediaWiki\Linker\LinkRenderer. In addition, the LinkBegin and LinkEnd hooks + were replaced by HtmlPageLinkRendererBegin and HtmlPageLinkRendererEnd + respectively. See docs/hooks.txt for the specific changes needed for those hooks. +* Aliases for Linker methods, deprecated since 1.21, were removed from Skin: + * Skin::commentBlock() (use Linker::commentBlock() instead) + * Skin::generateRollback() (use Linker::generateRollback() instead) + * Skin::link() (use MediaWiki\Linker\LinkRenderer instead) + * Skin::linkKnown() (use MediaWiki\Linker\LinkRenderer instead) + * Skin::userLink() (use Linker::userLink() instead) + * Skin::userToolLinks() (use Linker::userToolLinks() instead) +* The 'ParserLimitReportFormat' hook was removed. +* Disabled "bug 2702" HTML tidying of parsed UI messages on wikis where Tidy is + disabled. +* DifferenceEngine::generateDiffBody() was removed (deprecated since 1.21). +* UploadBase::stashFileGetKey() and UploadBase::stashSession() were deprecated. + Use ...->stashFile()->getFileKey() instead. == Compatibility == diff --git a/UPGRADE b/UPGRADE index 088701a3eb..0fff28962c 100644 --- a/UPGRADE +++ b/UPGRADE @@ -1,18 +1,17 @@ - This file provides an overview of the MediaWiki upgrade process. For help with specific problems, check -* the documentation at https://www.mediawiki.org +* the documentation at https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents/ * the mediawiki-l mailing list archive at http://lists.wikimedia.org/pipermail/mediawiki-l/ -* the bug tracker at https://phabricator.wikimedia.org +* the bug tracker at https://phabricator.wikimedia.org/ for information and workarounds to common issues. == Overview == Comprehensive documentation on upgrading to the latest version of the software -is available at https://www.mediawiki.org/wiki/Manual:Upgrading. +is available at https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Upgrading === Consult the release notes === @@ -28,7 +27,7 @@ you take a complete backup of your wiki database and files and verify it. While the upgrade scripts are somewhat robust, there is no guarantee that things will not fail, leaving the database in an inconsistent state. -https://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki provides an overview of +https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Backing_up_a_wiki provides an overview of the backup process. You should also refer to the documentation for your database management system for information on backing up a database, and to your operating system documentation for information on making copies of files. diff --git a/autoload.php b/autoload.php index f9b0f64362..76c4cea6a0 100644 --- a/autoload.php +++ b/autoload.php @@ -514,41 +514,41 @@ $wgAutoloadLocalClasses = [ 'GitInfo' => __DIR__ . '/includes/GitInfo.php', 'GlobalDependency' => __DIR__ . '/includes/cache/CacheDependency.php', 'GlobalVarConfig' => __DIR__ . '/includes/config/GlobalVarConfig.php', - 'HTMLApiField' => __DIR__ . '/includes/htmlform/HTMLApiField.php', - 'HTMLAutoCompleteSelectField' => __DIR__ . '/includes/htmlform/HTMLAutoCompleteSelectField.php', - 'HTMLButtonField' => __DIR__ . '/includes/htmlform/HTMLButtonField.php', + 'HTMLApiField' => __DIR__ . '/includes/htmlform/fields/HTMLApiField.php', + 'HTMLAutoCompleteSelectField' => __DIR__ . '/includes/htmlform/fields/HTMLAutoCompleteSelectField.php', + 'HTMLButtonField' => __DIR__ . '/includes/htmlform/fields/HTMLButtonField.php', 'HTMLCacheUpdate' => __DIR__ . '/includes/deferred/HTMLCacheUpdate.php', 'HTMLCacheUpdateJob' => __DIR__ . '/includes/jobqueue/jobs/HTMLCacheUpdateJob.php', - 'HTMLCheckField' => __DIR__ . '/includes/htmlform/HTMLCheckField.php', - 'HTMLCheckMatrix' => __DIR__ . '/includes/htmlform/HTMLCheckMatrix.php', - 'HTMLComboboxField' => __DIR__ . '/includes/htmlform/HTMLComboboxField.php', - 'HTMLEditTools' => __DIR__ . '/includes/htmlform/HTMLEditTools.php', + 'HTMLCheckField' => __DIR__ . '/includes/htmlform/fields/HTMLCheckField.php', + 'HTMLCheckMatrix' => __DIR__ . '/includes/htmlform/fields/HTMLCheckMatrix.php', + 'HTMLComboboxField' => __DIR__ . '/includes/htmlform/fields/HTMLComboboxField.php', + 'HTMLEditTools' => __DIR__ . '/includes/htmlform/fields/HTMLEditTools.php', 'HTMLFileCache' => __DIR__ . '/includes/cache/HTMLFileCache.php', - 'HTMLFloatField' => __DIR__ . '/includes/htmlform/HTMLFloatField.php', + 'HTMLFloatField' => __DIR__ . '/includes/htmlform/fields/HTMLFloatField.php', 'HTMLForm' => __DIR__ . '/includes/htmlform/HTMLForm.php', 'HTMLFormField' => __DIR__ . '/includes/htmlform/HTMLFormField.php', - 'HTMLFormFieldCloner' => __DIR__ . '/includes/htmlform/HTMLFormFieldCloner.php', + 'HTMLFormFieldCloner' => __DIR__ . '/includes/htmlform/fields/HTMLFormFieldCloner.php', 'HTMLFormFieldRequiredOptionsException' => __DIR__ . '/includes/htmlform/HTMLFormFieldRequiredOptionsException.php', - 'HTMLFormFieldWithButton' => __DIR__ . '/includes/htmlform/HTMLFormFieldWithButton.php', - 'HTMLHiddenField' => __DIR__ . '/includes/htmlform/HTMLHiddenField.php', - 'HTMLInfoField' => __DIR__ . '/includes/htmlform/HTMLInfoField.php', - 'HTMLIntField' => __DIR__ . '/includes/htmlform/HTMLIntField.php', - 'HTMLMultiSelectField' => __DIR__ . '/includes/htmlform/HTMLMultiSelectField.php', + 'HTMLFormFieldWithButton' => __DIR__ . '/includes/htmlform/fields/HTMLFormFieldWithButton.php', + 'HTMLHiddenField' => __DIR__ . '/includes/htmlform/fields/HTMLHiddenField.php', + 'HTMLInfoField' => __DIR__ . '/includes/htmlform/fields/HTMLInfoField.php', + 'HTMLIntField' => __DIR__ . '/includes/htmlform/fields/HTMLIntField.php', + 'HTMLMultiSelectField' => __DIR__ . '/includes/htmlform/fields/HTMLMultiSelectField.php', 'HTMLNestedFilterable' => __DIR__ . '/includes/htmlform/HTMLNestedFilterable.php', - 'HTMLRadioField' => __DIR__ . '/includes/htmlform/HTMLRadioField.php', - 'HTMLSelectAndOtherField' => __DIR__ . '/includes/htmlform/HTMLSelectAndOtherField.php', - 'HTMLSelectField' => __DIR__ . '/includes/htmlform/HTMLSelectField.php', - 'HTMLSelectLimitField' => __DIR__ . '/includes/htmlform/HTMLSelectLimitField.php', - 'HTMLSelectNamespace' => __DIR__ . '/includes/htmlform/HTMLSelectNamespace.php', - 'HTMLSelectNamespaceWithButton' => __DIR__ . '/includes/htmlform/HTMLSelectNamespaceWithButton.php', - 'HTMLSelectOrOtherField' => __DIR__ . '/includes/htmlform/HTMLSelectOrOtherField.php', - 'HTMLSubmitField' => __DIR__ . '/includes/htmlform/HTMLSubmitField.php', - 'HTMLTagFilter' => __DIR__ . '/includes/htmlform/HTMLTagFilter.php', - 'HTMLTextAreaField' => __DIR__ . '/includes/htmlform/HTMLTextAreaField.php', - 'HTMLTextField' => __DIR__ . '/includes/htmlform/HTMLTextField.php', - 'HTMLTextFieldWithButton' => __DIR__ . '/includes/htmlform/HTMLTextFieldWithButton.php', - 'HTMLTitleTextField' => __DIR__ . '/includes/htmlform/HTMLTitleTextField.php', - 'HTMLUserTextField' => __DIR__ . '/includes/htmlform/HTMLUserTextField.php', + 'HTMLRadioField' => __DIR__ . '/includes/htmlform/fields/HTMLRadioField.php', + 'HTMLSelectAndOtherField' => __DIR__ . '/includes/htmlform/fields/HTMLSelectAndOtherField.php', + 'HTMLSelectField' => __DIR__ . '/includes/htmlform/fields/HTMLSelectField.php', + 'HTMLSelectLimitField' => __DIR__ . '/includes/htmlform/fields/HTMLSelectLimitField.php', + 'HTMLSelectNamespace' => __DIR__ . '/includes/htmlform/fields/HTMLSelectNamespace.php', + 'HTMLSelectNamespaceWithButton' => __DIR__ . '/includes/htmlform/fields/HTMLSelectNamespaceWithButton.php', + 'HTMLSelectOrOtherField' => __DIR__ . '/includes/htmlform/fields/HTMLSelectOrOtherField.php', + 'HTMLSubmitField' => __DIR__ . '/includes/htmlform/fields/HTMLSubmitField.php', + 'HTMLTagFilter' => __DIR__ . '/includes/htmlform/fields/HTMLTagFilter.php', + 'HTMLTextAreaField' => __DIR__ . '/includes/htmlform/fields/HTMLTextAreaField.php', + 'HTMLTextField' => __DIR__ . '/includes/htmlform/fields/HTMLTextField.php', + 'HTMLTextFieldWithButton' => __DIR__ . '/includes/htmlform/fields/HTMLTextFieldWithButton.php', + 'HTMLTitleTextField' => __DIR__ . '/includes/htmlform/fields/HTMLTitleTextField.php', + 'HTMLUserTextField' => __DIR__ . '/includes/htmlform/fields/HTMLUserTextField.php', 'HWLDFWordAccumulator' => __DIR__ . '/includes/diff/DairikiDiff.php', 'HashBagOStuff' => __DIR__ . '/includes/libs/objectcache/HashBagOStuff.php', 'HashConfig' => __DIR__ . '/includes/config/HashConfig.php', @@ -755,7 +755,7 @@ $wgAutoloadLocalClasses = [ 'LonelyPagesPage' => __DIR__ . '/includes/specials/SpecialLonelypages.php', 'LongPagesPage' => __DIR__ . '/includes/specials/SpecialLongpages.php', 'MIMEsearchPage' => __DIR__ . '/includes/specials/SpecialMIMEsearch.php', - 'MWCallableUpdate' => __DIR__ . '/includes/deferred/CallableUpdate.php', + 'MWCallableUpdate' => __DIR__ . '/includes/deferred/MWCallableUpdate.php', 'MWContentSerializationException' => __DIR__ . '/includes/content/ContentHandler.php', 'MWCryptHKDF' => __DIR__ . '/includes/utils/MWCryptHKDF.php', 'MWCryptHash' => __DIR__ . '/includes/utils/MWCryptHash.php', @@ -1170,6 +1170,7 @@ $wgAutoloadLocalClasses = [ 'ResourceLoaderUserDefaultsModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserDefaultsModule.php', 'ResourceLoaderUserModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserModule.php', 'ResourceLoaderUserOptionsModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserOptionsModule.php', + 'ResourceLoaderUserStylesModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserStylesModule.php', 'ResourceLoaderUserTokensModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserTokensModule.php', 'ResourceLoaderWikiModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderWikiModule.php', 'RestbaseVirtualRESTService' => __DIR__ . '/includes/libs/virtualrest/RestbaseVirtualRESTService.php', diff --git a/composer.json b/composer.json index 1bd3d4c5a4..9bd0fa1f07 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "ext-xml": "*", "liuggio/statsd-php-client": "1.0.18", "mediawiki/at-ease": "1.1.0", - "oojs/oojs-ui": "0.17.6", + "oojs/oojs-ui": "0.17.7", "oyejorge/less.php": "1.7.0.10", "php": ">=5.5.9", "psr/log": "1.0.0", diff --git a/docs/README b/docs/README index 5bc8bfc665..6f3da973d6 100644 --- a/docs/README +++ b/docs/README @@ -5,7 +5,7 @@ The 'docs' directory contain various text files that should help you understand the most important parts of the code of MediaWiki. More in-depth documentation can be found at: https://www.mediawiki.org/wiki/Manual:Code - + https://www.mediawiki.org/wiki/Developer_hub API documentation is automatically generated and updated daily at: https://doc.wikimedia.org/mediawiki-core/master/php/html/ diff --git a/docs/extension.schema.json b/docs/extension.schema.json index f2406c8ee7..110e99d4e6 100644 --- a/docs/extension.schema.json +++ b/docs/extension.schema.json @@ -625,6 +625,11 @@ "capitallinkoverride": { "type": "boolean", "description": "Set $wgCapitalLinks on a per-namespace basis" + }, + "conditional": { + "type": "boolean", + "description": "Whether the namespace is conditional upon configuration and should not be registered (requires separate registration via a hook)", + "default": false } }, "required": ["id", "constant", "name"] diff --git a/docs/extension.schema.v1.json b/docs/extension.schema.v1.json index 893facfd7a..37235e93ab 100644 --- a/docs/extension.schema.v1.json +++ b/docs/extension.schema.v1.json @@ -615,6 +615,11 @@ "capitallinkoverride": { "type": "boolean", "description": "Set $wgCapitalLinks on a per-namespace basis" + }, + "conditional": { + "type": "boolean", + "description": "Whether the namespace is conditional upon configuration and should not be registered (requires separate registration via a hook)", + "default": false } }, "required": ["id", "constant", "name"] diff --git a/docs/hooks.txt b/docs/hooks.txt index e1b397472d..c53490a112 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -608,6 +608,7 @@ $reason: the reason the article was deleted $id: id of the article that was deleted $content: the Content of the deleted page $logEntry: the ManualLogEntry used to record the deletion +$archivedRevisionCount: the number of revisions archived during the deletion 'ArticleEditUpdateNewTalk': Before updating user_newtalk when a user talk page was changed. @@ -2360,24 +2361,12 @@ cache or return false to not use it. &$parser: Parser object &$varCache: variable cache (array) -'ParserLimitReport': DEPRECATED! Use ParserLimitReportPrepare and -ParserLimitReportFormat instead. +'ParserLimitReport': DEPRECATED! Use ParserLimitReportPrepare instead. Called at the end of Parser:parse() when the parser will include comments about size of the text parsed. $parser: Parser object &$limitReport: text that will be included (without comment tags) -'ParserLimitReportFormat': Called for each row in the parser limit report that -needs formatting. If nothing handles this hook, the default is to use "$key" to -get the label, and "$key-value" or "$key-value-text"/"$key-value-html" to -format the value. -$key: Key for the limit report item (string) -&$value: Value of the limit report item -&$report: String onto which to append the data -$isHTML: If true, $report is an HTML table with two columns; if false, it's - text intended for display in a monospaced font. -$localize: If false, $report should be output in English. - 'ParserLimitReportPrepare': Called at the end of Parser:parse() when the parser will include comments about size of the text parsed. Hooks should use $output->setLimitReportData() to populate data. Functions for this hook should diff --git a/extensions/README b/extensions/README index 923a19b705..5c9bf53933 100644 --- a/extensions/README +++ b/extensions/README @@ -1,9 +1,12 @@ +== User Information == + Extensions are distributed separately. Drop them into this directory and enable as per the extension's installation instructions. You can find a list of extensions and documentation at -. +. +== Development Information == If you are a developer, you might want to fetch the extension tree in another directory and make a symbolic link: diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 883b8a32c1..8dc7d4094a 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -81,18 +81,6 @@ class AutoLoader { require $filename; } - /** - * Force a class to be run through the autoloader, helpful for things like - * Sanitizer that have define()s outside of their class definition. Of course - * this wouldn't be necessary if everything in MediaWiki was class-based. Sigh. - * - * @param string $class - * @return bool Return the results of class_exists() so we know if we were successful - */ - static function loadClass( $class ) { - return class_exists( $class ); - } - /** * Method to clear the protected class property $autoloadLocalClassesLower. * Used in tests. diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index 8dd3f5c516..490f548135 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -407,11 +407,26 @@ class CategoryViewer extends ContextSource { return $r; } + /** + * Return pretty name which is display name if given and different from prefix text or + * the unprefixed page name. + * + * @return string HTML safe name. + */ + function getPrettyPageNameHtml() { + $displayTitle = $this->getOutput()->getPageTitle(); + if ( $displayTitle === $this->getTitle()->getPrefixedText() ) { + return htmlspecialchars( $this->getTitle()->getText() ); + } else { + return $displayTitle; + } + } + /** * @return string */ function getPagesSection() { - $ti = wfEscapeWikiText( $this->title->getText() ); + $name = $this->getPrettyPageNameHtml(); # Don't show articles section if there are none. $r = ''; @@ -427,7 +442,7 @@ class CategoryViewer extends ContextSource { if ( $rescnt > 0 ) { $r = "
\n"; - $r .= '

' . $this->msg( 'category_header', $ti )->parse() . "

\n"; + $r .= '

' . $this->msg( 'category_header' )->rawParams( $name )->parse() . "

\n"; $r .= $countmsg; $r .= $this->getSectionPagingLinks( 'page' ); $r .= $this->formatList( $this->articles, $this->articles_start_char ); @@ -441,6 +456,7 @@ class CategoryViewer extends ContextSource { * @return string */ function getImageSection() { + $name = $this->getPrettyPageNameHtml(); $r = ''; $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery ); $dbcnt = $this->cat->getFileCount(); @@ -450,10 +466,7 @@ class CategoryViewer extends ContextSource { if ( $rescnt > 0 ) { $r .= "
\n"; $r .= '

' . - $this->msg( - 'category-media-header', - wfEscapeWikiText( $this->title->getText() ) - )->text() . + $this->msg( 'category-media-header' )->rawParams( $name )->parse() . "

\n"; $r .= $countmsg; $r .= $this->getSectionPagingLinks( 'file' ); diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 27fdd90fd7..3c5e2d2bf3 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -398,9 +398,13 @@ $wgAllowImageMoving = true; $wgEnableAsyncUploads = false; /** - * These are additional characters that should be replaced with '-' in filenames + * Additional characters that are not allowed in filenames. They are replaced with '-' when + * uploading. Like $wgLegalTitleChars, this is a regexp character class. + * + * Slashes and backslashes are disallowed regardless of this setting, but included here for + * completeness. */ -$wgIllegalFileChars = ":"; +$wgIllegalFileChars = ":\\/\\\\"; /** * What directory to place deleted uploads in. @@ -2509,7 +2513,7 @@ $wgFileCacheDepth = 2; /** * Kept for extension compatibility; see $wgParserCacheType - * @deprecated 1.26 + * @deprecated since 1.26 */ $wgEnableParserCache = true; diff --git a/includes/EditPage.php b/includes/EditPage.php index fa5c53def1..674cf2874e 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -260,9 +260,6 @@ class EditPage { /** @var bool */ public $tooBig = false; - /** @var bool */ - public $kblength = false; - /** @var bool */ public $missingComment = false; @@ -396,6 +393,9 @@ class EditPage { /** @var bool */ protected $edit; + /** @var bool|int */ + protected $contentLength = false; + /** * @var bool Set in ApiEditPage, based on ContentHandler::allowsDirectApiEditing */ @@ -1774,8 +1774,8 @@ class EditPage { return $status; } - $this->kblength = (int)( strlen( $this->textbox1 ) / 1024 ); - if ( $this->kblength > $wgMaxArticleSize ) { + $this->contentLength = strlen( $this->textbox1 ); + if ( $this->contentLength > $wgMaxArticleSize * 1024 ) { // Error will be displayed by showEditForm() $this->tooBig = true; $status->setResult( false, self::AS_CONTENT_TOO_BIG ); @@ -2062,8 +2062,8 @@ class EditPage { } // Check for length errors again now that the section is merged in - $this->kblength = (int)( strlen( $this->toEditText( $content ) ) / 1024 ); - if ( $this->kblength > $wgMaxArticleSize ) { + $this->contentLength = strlen( $this->toEditText( $content ) ); + if ( $this->contentLength > $wgMaxArticleSize * 1024 ) { $this->tooBig = true; $status->setResult( false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED ); return $status; @@ -2968,15 +2968,15 @@ class EditPage { 'wrap' => "
\n$1
" ] ); } - if ( $this->kblength === false ) { - $this->kblength = (int)( strlen( $this->textbox1 ) / 1024 ); + if ( $this->contentLength === false ) { + $this->contentLength = strlen( $this->textbox1 ); } - if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) { + if ( $this->tooBig || $this->contentLength > $wgMaxArticleSize * 1024 ) { $wgOut->wrapWikiMsg( "
\n$1\n
", [ 'longpageerror', - $wgLang->formatNum( $this->kblength ), + $wgLang->formatNum( round( $this->contentLength / 1024, 3 ) ), $wgLang->formatNum( $wgMaxArticleSize ) ] ); diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 66e244082e..7117f4c29a 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -222,17 +222,17 @@ function wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) { * Merge arrays in the style of getUserPermissionsErrors, with duplicate removal * e.g. * wfMergeErrorArrays( - * array( array( 'x' ) ), - * array( array( 'x', '2' ) ), - * array( array( 'x' ) ), - * array( array( 'y' ) ) + * [ [ 'x' ] ], + * [ [ 'x', '2' ] ], + * [ [ 'x' ] ], + * [ [ 'y' ] ] * ); * returns: - * array( - * array( 'x', '2' ), - * array( 'x' ), - * array( 'y' ) - * ) + * [ + * [ 'x', '2' ], + * [ 'x' ], + * [ 'y' ] + * ] * * @param array $array1,... * @return array @@ -827,7 +827,7 @@ function wfParseUrl( $url ) { $bits = parse_url( $url ); MediaWiki\restoreWarnings(); // parse_url() returns an array without scheme for some invalid URLs, e.g. - // parse_url("%0Ahttp://example.com") == array( 'host' => '%0Ahttp', 'path' => 'example.com' ) + // parse_url("%0Ahttp://example.com") == [ 'host' => '%0Ahttp', 'path' => 'example.com' ] if ( !$bits || !isset( $bits['scheme'] ) ) { return false; } @@ -2950,7 +2950,7 @@ function wfRelativePath( $path, $from ) { * Supports base 2 through 36; digit values 10-36 are represented * as lowercase letters a-z. Input is case-insensitive. * - * @deprecated 1.27 Use Wikimedia\base_convert() directly + * @deprecated since 1.27 Use Wikimedia\base_convert() directly * * @param string $input Input number * @param int $sourceBase Base of the input number @@ -3350,9 +3350,9 @@ function wfCountDown( $seconds ) { } /** - * Replace all invalid characters with - - * Additional characters can be defined in $wgIllegalFileChars (see bug 20489) - * By default, $wgIllegalFileChars = ':' + * Replace all invalid characters with '-'. + * Additional characters can be defined in $wgIllegalFileChars (see T22489). + * By default, $wgIllegalFileChars includes ':', '/', '\'. * * @param string $name Filename to process * @return string @@ -3360,12 +3360,13 @@ function wfCountDown( $seconds ) { function wfStripIllegalFilenameChars( $name ) { global $wgIllegalFileChars; $illegalFileChars = $wgIllegalFileChars ? "|[" . $wgIllegalFileChars . "]" : ''; - $name = wfBaseName( $name ); $name = preg_replace( "/[^" . Title::legalChars() . "]" . $illegalFileChars . "/", '-', $name ); + // $wgIllegalFileChars may not include '/' and '\', so we still need to do this + $name = wfBaseName( $name ); return $name; } @@ -3524,7 +3525,7 @@ function wfGetParserCacheStorage() { * @param string|null $deprecatedVersion Optionally mark hook as deprecated with version number * * @return bool True if no handler aborted the hook - * @deprecated 1.25 - use Hooks::run + * @deprecated since 1.25 - use Hooks::run */ function wfRunHooks( $event, array $args = [], $deprecatedVersion = null ) { return Hooks::run( $event, $args, $deprecatedVersion ); diff --git a/includes/Linker.php b/includes/Linker.php index 1979e44fbc..5e540b9c03 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -170,6 +170,7 @@ class Linker { * link() replaces the old functions in the makeLink() family. * * @since 1.18 Method exists since 1.16 as non-static, made static in 1.18. + * @deprecated since 1.28, use MediaWiki\Linker\LinkRenderer instead * * @param Title $target Can currently only be a Title, but this may * change to support Images, literal URLs, etc. @@ -245,7 +246,9 @@ class Linker { /** * Identical to link(), except $options defaults to 'known'. + * * @since 1.16.3 + * @deprecated since 1.28, use MediaWiki\Linker\LinkRenderer instead * @see Linker::link * @return string */ diff --git a/includes/OutputPage.php b/includes/OutputPage.php index ecc719a044..b6c48abba2 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -290,6 +290,9 @@ class OutputPage extends ContextSource { */ private $copyrightUrl; + /** @var array Profiling data */ + private $limitReportData = []; + /** * Constructor for OutputPage. This should not be called directly. * Instead a new RequestContext should be created and it will implicitly create @@ -604,29 +607,6 @@ class OutputPage extends ContextSource { $this->mModuleStyles = array_merge( $this->mModuleStyles, (array)$modules ); } - /** - * Get the list of module messages to include on this page - * - * @deprecated since 1.26 Obsolete - * @param bool $filter - * @param string|null $position - * @return array Array of module names - */ - public function getModuleMessages( $filter = false, $position = null ) { - wfDeprecated( __METHOD__, '1.26' ); - return []; - } - - /** - * Load messages of one or more ResourceLoader modules. - * - * @deprecated since 1.26 Use addModules() instead - * @param string|array $modules Module name (string) or array of module names - */ - public function addModuleMessages( $modules ) { - wfDeprecated( __METHOD__, '1.26' ); - } - /** * @return null|string ResourceLoader target */ @@ -653,7 +633,7 @@ class OutputPage extends ContextSource { } /** - * Add or replace an header item to the output + * Add or replace a head item to the output * * Whenever possible, use more specific options like ResourceLoader modules, * OutputPage::addLink(), OutputPage::addMetaLink() and OutputPage::addFeedLink() @@ -668,6 +648,16 @@ class OutputPage extends ContextSource { $this->mHeadItems[$name] = $value; } + /** + * Add one or more head items to the output + * + * @since 1.28 + * @param string|string[] $value Raw HTML + */ + public function addHeadItems( $values ) { + $this->mHeadItems = array_merge( $this->mHeadItems, (array)$values ); + } + /** * Check if the header item $name is already set * @@ -1777,11 +1767,14 @@ class OutputPage extends ContextSource { } } - // enable OOUI if requested via ParserOutput + // Enable OOUI if requested via ParserOutput if ( $parserOutput->getEnableOOUI() ) { $this->enableOOUI(); } + // Include profiling data + $this->limitReportData = $parserOutput->getLimitReportData(); + // Link flags are ignored for now, but may in the future be // used to mark individual language links. $linkFlags = []; @@ -3098,7 +3091,13 @@ class OutputPage extends ContextSource { * @return string */ function getBottomScripts() { - return $this->getScriptsForBottomQueue(); + return $this->getScriptsForBottomQueue() . + ResourceLoader::makeInlineScript( + ResourceLoader::makeConfigSetScript( + [ 'wgPageParseReport' => $this->limitReportData ], + true + ) + ); } /** @@ -3661,7 +3660,7 @@ class OutputPage extends ContextSource { ) { // We're on a preview of a CSS subpage // Exclude this page from the user module in case it's in there (bug 26283) - $link = $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_STYLES, + $link = $this->makeResourceLoaderLink( 'user.styles', ResourceLoaderModule::TYPE_STYLES, [ 'excludepage' => $this->getTitle()->getPrefixedDBkey() ] ); $otherTags = array_merge( $otherTags, $link['html'] ); @@ -3676,7 +3675,7 @@ class OutputPage extends ContextSource { $otherTags[] = Html::inlineStyle( $previewedCSS ); } else { // Load the user styles normally - $moduleStyles[] = 'user'; + $moduleStyles[] = 'user.styles'; } // Per-user preference styles diff --git a/includes/Pingback.php b/includes/Pingback.php index 10d2904039..dd68102391 100644 --- a/includes/Pingback.php +++ b/includes/Pingback.php @@ -202,7 +202,7 @@ class Pingback { * * - * @param data Pingback data as an associative array + * @param array $data Pingback data as an associative array * @return bool true on success, false on failure */ private function postPingback( array $data ) { diff --git a/includes/RevisionList.php b/includes/RevisionList.php index 731d1b3e5d..811870c8c0 100644 --- a/includes/RevisionList.php +++ b/includes/RevisionList.php @@ -23,7 +23,7 @@ /** * List for revision table items for a single page */ -abstract class RevisionListBase extends ContextSource { +abstract class RevisionListBase extends ContextSource implements Iterator { /** @var Title */ public $title; @@ -89,6 +89,10 @@ abstract class RevisionListBase extends ContextSource { return $this->current; } + public function rewind() { + $this->reset(); + } + /** * Get the current list item, or false if we are at the end * @return Revision @@ -107,6 +111,14 @@ abstract class RevisionListBase extends ContextSource { return $this->current; } + public function key() { + return $this->res ? $this->res->key(): 0; + } + + public function valid() { + return $this->res ? $this->res->valid() : false; + } + /** * Get the number of items in the list. * @return int diff --git a/includes/Services/ServiceContainer.php b/includes/Services/ServiceContainer.php index b336795ee4..bad0ef9ce6 100644 --- a/includes/Services/ServiceContainer.php +++ b/includes/Services/ServiceContainer.php @@ -367,4 +367,12 @@ class ServiceContainer implements DestructibleService { return $service; } + /** + * @param string $name + * @return bool Whether the service is disabled + * @since 1.28 + */ + public function isServiceDisabled( $name ) { + return isset( $this->disabled[$name] ); + } } diff --git a/includes/SiteConfiguration.php b/includes/SiteConfiguration.php index 5b9bdfa1b1..885f926fa2 100644 --- a/includes/SiteConfiguration.php +++ b/includes/SiteConfiguration.php @@ -36,15 +36,15 @@ * * @code * $conf = new SiteConfiguration; - * $conf->wikis = array( 'de', 'en', 'beta' ); + * $conf->wikis = [ 'de', 'en', 'beta' ]; * @endcode * * When configuring the MediaWiki global settings (the $wg variables), * the identifiers will be available to specify settings on a per wiki basis. * * @code - * $conf->settings = array( - * 'wgSomeSetting' => array( + * $conf->settings = [ + * 'wgSomeSetting' => [ * * # production: * 'de' => false, @@ -52,8 +52,8 @@ * * # test: * 'beta => true, - * ), - * ); + * ], + * ]; * @endcode * * With three wikis, that is easy to manage. But what about a farm with @@ -62,15 +62,15 @@ * the above code could be written: * * @code - * $conf->settings = array( - * 'wgSomeSetting' => array( + * $conf->settings = [ + * 'wgSomeSetting' => [ * * 'default' => false, * * # Enable feature on test * 'beta' => true, - * ), - * ); + * ], + * ]; * @endcode * * @@ -80,23 +80,23 @@ * on a per wiki basis. * * @code - * $conf->settings = array( - * 'wgMergeSetting' = array( + * $conf->settings = [ + * 'wgMergeSetting' = [ * # Value that will be shared among all wikis: - * 'default' => array( NS_USER => true ), + * 'default' => [ NS_USER => true ], * * # Leading '+' means merging the array of value with the defaults - * '+beta' => array( NS_HELP => true ), - * ), - * ); + * '+beta' => [ NS_HELP => true ], + * ], + * ]; * * # Get configuration for the German site: * $conf->get( 'wgMergeSetting', 'de' ); - * // --> array( NS_USER => true ); + * // --> [ NS_USER => true ]; * * # Get configuration for the testing site: * $conf->get( 'wgMergeSetting', 'beta' ); - * // --> array( NS_USER => true, NS_HELP => true ); + * // --> [ NS_USER => true, NS_HELP => true ]; * @endcode * * Finally, to load all configuration settings, extract them in global context: @@ -108,9 +108,14 @@ * extract( $globals ); * @endcode * + * @note For WikiMap to function, the configuration must define string values for + * $wgServer (or $wgCanonicalServer) and $wgArticlePath, even if these are the + * same for all wikis or can be correctly determined by the logic in + * Setup.php. + * * @todo Give examples for, * suffixes: - * $conf->suffixes = array( 'wiki' ); + * $conf->suffixes = [ 'wiki' ]; * localVHosts * callbacks! */ diff --git a/includes/Status.php b/includes/Status.php index 45d8bed2fa..e5788733cf 100644 --- a/includes/Status.php +++ b/includes/Status.php @@ -385,7 +385,7 @@ class Status { * * @return array A list in which each entry is an array with a message key as its first element. * The remaining array elements are the message parameters. - * @deprecated 1.25 + * @deprecated since 1.25 */ public function getErrorsArray() { return $this->getStatusArray( 'error' ); @@ -396,7 +396,7 @@ class Status { * * @return array A list in which each entry is an array with a message key as its first element. * The remaining array elements are the message parameters. - * @deprecated 1.25 + * @deprecated since 1.25 */ public function getWarningsArray() { return $this->getStatusArray( 'warning' ); diff --git a/includes/Title.php b/includes/Title.php index 8aa8cb7db7..ea42768c0e 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -500,7 +500,7 @@ class Title implements LinkTarget { * @param string $interwiki The interwiki prefix * @return Title The new object */ - public static function &makeTitle( $ns, $title, $fragment = '', $interwiki = '' ) { + public static function makeTitle( $ns, $title, $fragment = '', $interwiki = '' ) { $t = new Title(); $t->mInterwiki = $interwiki; $t->mFragment = $fragment; diff --git a/includes/WatchedItem.php b/includes/WatchedItem.php index b070e1eba6..bfd1d6136b 100644 --- a/includes/WatchedItem.php +++ b/includes/WatchedItem.php @@ -156,54 +156,6 @@ class WatchedItem { return new self( $user, $title, self::DEPRECATED_USAGE_TIMESTAMP, (bool)$checkRights ); } - /** - * @deprecated since 1.27 Use WatchedItemStore::resetNotificationTimestamp() - */ - public function resetNotificationTimestamp( $force = '', $oldid = 0 ) { - wfDeprecated( __METHOD__, '1.27' ); - if ( $this->checkRights && !$this->user->isAllowed( 'editmywatchlist' ) ) { - return; - } - MediaWikiServices::getInstance()->getWatchedItemStore()->resetNotificationTimestamp( - $this->user, - $this->getTitle(), - $force, - $oldid - ); - } - - /** - * @deprecated since 1.27 Use WatchedItemStore::addWatchBatch() - */ - public static function batchAddWatch( array $items ) { - wfDeprecated( __METHOD__, '1.27' ); - if ( !$items ) { - return false; - } - - $targets = []; - $users = []; - /** @var WatchedItem $watchedItem */ - foreach ( $items as $watchedItem ) { - $user = $watchedItem->getUser(); - if ( $watchedItem->checkRights && !$user->isAllowed( 'editmywatchlist' ) ) { - continue; - } - $userId = $user->getId(); - $users[$userId] = $user; - $targets[$userId][] = $watchedItem->getTitle()->getSubjectPage(); - $targets[$userId][] = $watchedItem->getTitle()->getTalkPage(); - } - - $store = MediaWikiServices::getInstance()->getWatchedItemStore(); - $success = true; - foreach ( $users as $userId => $user ) { - $success &= $store->addWatchBatchForUser( $user, $targets[$userId] ); - } - - return $success; - } - /** * @deprecated since 1.27 Use User::addWatch() * @return bool diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 30efb3b49f..b5c57ee972 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -565,8 +565,7 @@ class WebRequest { /** * Fetch a text string from the given array or return $default if it's not - * set. Carriage returns are stripped from the text, and with some language - * modules there is an input transliteration applied. This should generally + * set. Carriage returns are stripped from the text. This should generally * be used for form "