Merge "Ensure LanguageCode::bcp47() returns a valid BCP 47 language code"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 11 Oct 2018 20:46:35 +0000 (20:46 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 11 Oct 2018 20:46:35 +0000 (20:46 +0000)
30 files changed:
.mailmap
RELEASE-NOTES-1.32
docs/hooks.txt
includes/EditPage.php
includes/GlobalFunctions.php
includes/MediaWiki.php
includes/Revision/RenderedRevision.php
includes/actions/Action.php
includes/api/ApiBase.php
includes/cache/MessageCache.php
includes/deferred/DeferredUpdates.php
includes/filerepo/file/File.php
includes/installer/CliInstaller.php
includes/installer/Installer.php
includes/installer/i18n/en.json
includes/installer/i18n/qqq.json
includes/jobqueue/jobs/ThumbnailRenderJob.php
includes/media/MediaHandler.php
includes/parser/Parser.php
includes/parser/ParserOutput.php
includes/skins/Skin.php
includes/user/User.php
maintenance/install.php
maintenance/update.php
tests/phpunit/MediaWikiTestCase.php
tests/phpunit/includes/HooksTest.php
tests/phpunit/includes/parser/ParserOutputTest.php
tests/phpunit/includes/specialpage/AbstractChangesListSpecialPageTestCase.php
tests/phpunit/includes/specials/SpecialWatchlistTest.php
tests/phpunit/languages/LanguageConverterTest.php

index f199b65..8637e77 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -30,6 +30,7 @@ Aaron Schulz <aschulz@wikimedia.org> <aaron@users.mediawiki.org>
 Adam Roses Wight <awight@wikimedia.org>
 Adam Roses Wight <awight@wikimedia.org> <spam@ludd.net>
 addshore <addshorewiki@gmail.com>
+addshore <addshorewiki@gmail.com> <adamshorland@gmail.com>
 Aditya Sastry <ganeshaditya1@gmail.com>
 Adrian Heine <adrian.heine@wikimedia.de>
 Alex Z. <mrzmanwiki@gmail.com> <mrzman@users.mediawiki.org>
@@ -121,8 +122,9 @@ Daniel Friesen <mediawiki@danielfriesen.name>
 Daniel Friesen <mediawiki@danielfriesen.name> <daniel@nadir-seen-fire.com>
 Daniel Friesen <mediawiki@danielfriesen.name> <dantman@users.mediawiki.org>
 Daniel Friesen <mediawiki@danielfriesen.name> <pub-github@nadir-seen-fire.com>
-Daniel Kinzler <daniel.kinzler@wikimedia.de>
-Daniel Kinzler <daniel.kinzler@wikimedia.de> <daniel@users.mediawiki.org>
+Daniel Kinzler <dkinzler@wikimedia.org>
+Daniel Kinzler <dkinzler@wikimedia.org> <daniel.kinzler@wikimedia.de>
+Daniel Kinzler <dkinzler@wikimedia.org> <daniel@users.mediawiki.org>
 Daniel Renfro <bluecurio@gmail.com> <drenfro@vistaprint.com>
 Danny B. <Wikipedia.Danny.B@email.cz>
 Danny B. <Wikipedia.Danny.B@email.cz> <danny.b@email.cz>
@@ -132,6 +134,8 @@ Darian Anthony Patrick <dpatrick@wikimedia.org>
 Darkdragon09 <ubuntu@ip-172-31-39-38.us-west-2.compute.internal>
 David Causse <dcausse@wikimedia.org>
 David Chan <david@sheetmusic.org.uk>
+Dayllan Maza <dmaza@wikimedia.org>
+Dayllan Maza <dmaza@wikimedia.org> <dayllan.maza@gmail.com>
 Dereckson <dereckson@espace-win.org>
 Derk-Jan Hartman <hartman@videolan.org>
 Derk-Jan Hartman <hartman@videolan.org> <hartman.wiki@gmail.com>
@@ -240,6 +244,8 @@ Karun Dambiec <karun.84@gmx.de>
 Katie Filbert <aude.wiki@gmail.com>
 Katie Filbert <aude.wiki@gmail.com> <aude@users.mediawiki.org>
 Kevin Israel <pleasestand@live.com>
+Kosta Harlan <kharlan@wikimedia.org>
+Kosta Harlan <kharlan@wikimedia.org> <kosta@fastmail.com>
 Kunal Grover <kunalgrover05@gmail.com>
 Kunal Mehta <legoktm@member.fsf.org>
 Kunal Mehta <legoktm@member.fsf.org> <legoktm.wikipedia@gmail.com>
@@ -327,6 +333,7 @@ Patrick Reilly <preilly@wikimedia.org>
 Patrick Reilly <preilly@wikimedia.org> <preilly@users.mediawiki.org>
 Patrick Westerhoff <PatrickWesterhoff@gmail.com>
 Paul Copperman <paul.copperman@gmail.com> <pcopp@users.mediawiki.org>
+Petar Petković <ppetkovic@wikimedia.org>
 Peter Coombe <pcoombe@wikimedia.org>
 Peter Coti <petercoti@gmail.com>
 Peter Potrowl <peter017@gmail.com> <peter17@users.mediawiki.org>
index 45b06ee..6ba7d97 100644 (file)
@@ -343,6 +343,18 @@ because of Phabricator reports.
   ChangesListSpecialPageQuery.
 * The global function wfUsePHP, deprecated since 1.30, has now been removed. To
   assert a newer version of PHP than MediaWiki does, use extension registration.
+* The hook 'ChangesListSpecialPageFilters', deprecated in 1.29, has now been
+  removed. Use the 'ChangesListSpecialPageStructuredFilters' hook instead.
+* DeferredUpdates::setImmediateMode(), deprecated since 1.29, has been removed.
+* File / MediaHandler::getStreamHeaders(), deprecated since 1.30, was removed.
+* The hook 'DoEditSectionLink', deprecated since 1.25, has been removed. Use
+  the hook 'SkinEditSectionLinks' instead.
+* The hook 'UserGetImplicitGroups', deprecated since 1.25, has been removed.
+* The global function wfRunHooks, deprecated since 1.25, has now been removed.
+  Use Hooks::run().
+* The hook 'UnknownAction', deprecated since 1.19, has now been removed.
+* The hook 'ParserLimitReport', deprecated since 1.22, has been removed. Use
+  the hooks 'ParserLimitReportPrepare' and 'ParserLimitReportFormat' instead.
 
 === Deprecations in 1.32 ===
 * HTMLForm::setSubmitProgressive() is deprecated. No need to call it. Submit
@@ -513,6 +525,9 @@ because of Phabricator reports.
   as a string. They should be given as a OOUI\FieldLayout object instead.
   Notably, this affects fields defined in the 'GetPreferences' hook, because
   Special:Preferences uses an OOUI form now. (If possible, don't use 'rawrow'.)
+* In Skin::doEditSectionLink omitting the parameters $tooltip and $lang is
+  deprecated. For the $lang parameter, types other than Language are
+  deprecated.
 
 === Other changes in 1.32 ===
 * (T198811) The following tables have had their UNIQUE indexes turned into
index 78ed1b4..fd7b300 100644 (file)
@@ -1015,16 +1015,6 @@ $rows: The data that will be rendered. May be a ResultWrapper instance or
 $unpatrolled: Whether or not we are showing unpatrolled changes.
 $watched: Whether or not the change is watched by the user.
 
-'ChangesListSpecialPageFilters': DEPRECATED since 1.29! Use
-'ChangesListSpecialPageStructuredFilters' instead.
-Called after building form options on pages
-inheriting from ChangesListSpecialPage (in core: RecentChanges,
-RecentChangesLinked and Watchlist).
-$special: ChangesListSpecialPage instance
-&$filters: associative array of filter definitions. The keys are the HTML
-  name/URL parameters. Each key maps to an associative array with a 'msg'
-  (message key) and a 'default' value.
-
 'ChangesListSpecialPageQuery': Called when building SQL query on pages
 inheriting from ChangesListSpecialPage (in core: RecentChanges,
 RecentChangesLinked and Watchlist).
@@ -1395,19 +1385,6 @@ an article
 &$article: article (object) being viewed
 &$oldid: oldid (int) being viewed
 
-'DoEditSectionLink': DEPRECATED since 1.25! Use SkinEditSectionLinks instead.
-Override the HTML generated for section edit links
-$skin: Skin object rendering the UI
-$title: Title object for the title being linked to (may not be the same as
-  the page title, if the section is included from a template)
-$section: The designation of the section being pointed to, to be included in
-  the link, like "&section=$section"
-$tooltip: The default tooltip.  Escape before using.
-  By default, this is wrapped in the 'editsectionhint' message.
-&$result: The HTML to return, prefilled with the default plus whatever other
-  changes earlier hooks have made
-$lang: The language code to use for the link in the wfMessage function
-
 'EditFilter': Perform checks on an edit
 $editor: EditPage instance (object). The edit form (see includes/EditPage.php)
 $text: Contents of the edit box
@@ -2670,13 +2647,6 @@ cache or return false to not use it.
 &$parser: Parser object
 &$varCache: variable cache (array)
 
-'ParserLimitReport': DEPRECATED since 1.22! Use ParserLimitReportPrepare and
-ParserLimitReportFormat 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
@@ -3583,12 +3553,6 @@ Since 1.24: Paths pointing to a directory will be recursively scanned for
 test case files matching the suffix "Test.php".
 &$paths: list of test cases and directories to search.
 
-'UnknownAction': DEPRECATED since 1.19! To add an action in an extension,
-create a subclass of Action, and add a new key to $wgActions.
-An unknown "action" has occurred (useful for defining your own actions).
-$action: action name
-$article: article "acted on"
-
 'UnwatchArticle': Before a watch is removed from an article.
 &$user: user watching
 &$page: WikiPage object to be removed
@@ -3747,10 +3711,6 @@ $user: User object
 &$timestamp: timestamp, change this to override local email authentication
   timestamp
 
-'UserGetImplicitGroups': DEPRECATED since 1.25!
-Called in User::getImplicitGroups().
-&$groups: List of implicit (automatically-assigned) groups
-
 'UserGetLanguageObject': Called when getting user's interface language object.
 $user: User object
 &$code: Language code that will be used to create the object
index 6b79538..7143c3f 100644 (file)
@@ -2991,7 +2991,7 @@ ERROR;
                                        $this->contentFormat,
                                        $ex->getMessage()
                                );
-                               $out->addWikiText( '<div class="error">' . $msg->text() . '</div>' );
+                               $out->addWikiText( '<div class="error">' . $msg->plain() . '</div>' );
                        }
                }
 
@@ -3466,7 +3466,7 @@ ERROR;
                                        $this->contentFormat,
                                        $ex->getMessage()
                                );
-                               $out->addWikiText( '<div class="error">' . $msg->text() . '</div>' );
+                               $out->addWikiText( '<div class="error">' . $msg->plain() . '</div>' );
                        }
                }
        }
index 49a2612..b536e69 100644 (file)
@@ -3037,21 +3037,6 @@ function wfGetMessageCacheStorage() {
        return ObjectCache::getInstance( $wgMessageCacheType );
 }
 
-/**
- * Call hook functions defined in $wgHooks
- *
- * @param string $event Event name
- * @param array $args Parameters passed to hook functions
- * @param string|null $deprecatedVersion Optionally mark hook as deprecated with version number
- *
- * @return bool True if no handler aborted the hook
- * @deprecated since 1.25 - use Hooks::run
- */
-function wfRunHooks( $event, array $args = [], $deprecatedVersion = null ) {
-       wfDeprecated( __METHOD__, '1.25' );
-       return Hooks::run( $event, $args, $deprecatedVersion );
-}
-
 /**
  * Wrapper around php's unpack.
  *
index 4636ba3..bc57637 100644 (file)
@@ -501,18 +501,10 @@ class MediaWiki {
                        $action->show();
                        return;
                }
-               // NOTE: deprecated hook. Add to $wgActions instead
-               if ( Hooks::run(
-                       'UnknownAction',
-                       [
-                               $request->getVal( 'action', 'view' ),
-                               $page
-                       ],
-                       '1.19'
-               ) ) {
-                       $output->setStatusCode( 404 );
-                       $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
-               }
+
+               // If we've not found out which action it is by now, it's unknown
+               $output->setStatusCode( 404 );
+               $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
        }
 
        /**
index 9cb20e0..6eee3c4 100644 (file)
@@ -31,6 +31,7 @@ use Psr\Log\NullLogger;
 use Revision;
 use Title;
 use User;
+use Content;
 use Wikimedia\Assert\Assert;
 
 /**
@@ -207,12 +208,7 @@ class RenderedRevision implements SlotRenderingProvider {
                                        'Access to the content has been suppressed for this audience'
                                );
                        } else {
-                               $output = $content->getParserOutput(
-                                       $this->title,
-                                       $this->revision->getId(),
-                                       $this->options,
-                                       $withHtml
-                               );
+                               $output = $this->getSlotParserOutputUncached( $content, $withHtml );
 
                                if ( $withHtml && !$output->hasText() ) {
                                        throw new LogicException(
@@ -232,6 +228,21 @@ class RenderedRevision implements SlotRenderingProvider {
                return $this->slotsOutput[$role];
        }
 
+       /**
+        * @note This method exist to make duplicate parses easier to see during profiling
+        * @param Content $content
+        * @param bool $withHtml
+        * @return ParserOutput
+        */
+       private function getSlotParserOutputUncached( Content $content, $withHtml ) {
+               return $content->getParserOutput(
+                       $this->title,
+                       $this->revision->getId(),
+                       $this->options,
+                       $withHtml
+               );
+       }
+
        /**
         * Updates the RevisionRecord after the revision has been saved. This can be used to discard
         * and cached ParserOutput so parser functions like {{REVISIONTIMESTAMP}} or {{REVISIONID}}
index fb761a7..e5233f0 100644 (file)
@@ -30,7 +30,7 @@ use MediaWiki\MediaWikiServices;
  * are distinct from Special Pages because an action must apply to exactly one page.
  *
  * To add an action in an extension, create a subclass of Action, and add the key to
- * $wgActions.  There is also the deprecated UnknownAction hook
+ * $wgActions.
  *
  * Actions generally fall into two groups: the show-a-form-then-do-something-with-the-input
  * format (protect, delete, move, etc), and the just-do-something format (watch, rollback,
index ac07eeb..c2e37e0 100644 (file)
@@ -2247,7 +2247,7 @@ abstract class ApiBase extends ContextSource {
 
                // Avoid PHP 7.1 warning of passing $this by reference
                $apiModule = $this;
-               Hooks::run( 'APIGetDescription', [ &$apiModule, &$desc ] );
+               Hooks::run( 'APIGetDescription', [ &$apiModule, &$desc ], '1.25' );
                $desc = self::escapeWikiText( $desc );
                if ( is_array( $desc ) ) {
                        $desc = implode( "\n", $desc );
@@ -2337,7 +2337,7 @@ abstract class ApiBase extends ContextSource {
 
                // Avoid PHP 7.1 warning of passing $this by reference
                $apiModule = $this;
-               Hooks::run( 'APIGetParamDescription', [ &$apiModule, &$desc ] );
+               Hooks::run( 'APIGetParamDescription', [ &$apiModule, &$desc ], '1.25' );
 
                if ( !$desc ) {
                        $desc = [];
index 76d31ff..733b1b7 100644 (file)
@@ -464,13 +464,7 @@ class MessageCache {
 
                $cache = [];
 
-               # Common conditions
-               $conds = [
-                       'page_is_redirect' => 0,
-                       'page_namespace' => NS_MEDIAWIKI,
-               ];
-
-               $mostused = [];
+               $mostused = []; // list of "<cased message key>/<code>"
                if ( $wgAdaptiveMessageCache && $code !== $wgLanguageCode ) {
                        if ( !$this->cache->has( $wgLanguageCode ) ) {
                                $this->load( $wgLanguageCode );
@@ -481,6 +475,14 @@ class MessageCache {
                        }
                }
 
+               // Get the list of software-defined messages in core/extensions
+               $overridable = array_flip( Language::getMessageKeysFor( $wgLanguageCode ) );
+
+               // Common conditions
+               $conds = [
+                       'page_is_redirect' => 0,
+                       'page_namespace' => NS_MEDIAWIKI,
+               ];
                if ( count( $mostused ) ) {
                        $conds['page_title'] = $mostused;
                } elseif ( $code !== $wgLanguageCode ) {
@@ -492,31 +494,28 @@ class MessageCache {
                                $dbr->buildLike( $dbr->anyString(), '/', $dbr->anyString() );
                }
 
-               # Conditions to fetch oversized pages to ignore them
-               $bigConds = $conds;
-               $bigConds[] = 'page_len > ' . intval( $wgMaxMsgCacheEntrySize );
-
-               # Load titles for all oversized pages in the MediaWiki namespace
+               // Set the stubs for oversized software-defined messages in the main cache map
                $res = $dbr->select(
                        'page',
                        [ 'page_title', 'page_latest' ],
-                       $bigConds,
+                       array_merge( $conds, [ 'page_len > ' . intval( $wgMaxMsgCacheEntrySize ) ] ),
                        __METHOD__ . "($code)-big"
                );
                foreach ( $res as $row ) {
-                       $cache[$row->page_title] = '!TOO BIG';
+                       $name = $this->contLang->lcfirst( $row->page_title );
+                       // Include entries/stubs for all keys in $mostused in adaptive mode
+                       if ( $wgAdaptiveMessageCache || isset( $overridable[$name] ) ) {
+                               $cache[$row->page_title] = '!TOO BIG';
+                       }
                        // At least include revision ID so page changes are reflected in the hash
                        $cache['EXCESSIVE'][$row->page_title] = $row->page_latest;
                }
 
-               # Conditions to load the remaining pages with their contents
-               $smallConds = $conds;
-               $smallConds[] = 'page_len <= ' . intval( $wgMaxMsgCacheEntrySize );
-
+               // Set the text for small software-defined messages in the main cache map
                $res = $dbr->select(
                        [ 'page', 'revision', 'text' ],
-                       [ 'page_title', 'old_id', 'old_text', 'old_flags' ],
-                       $smallConds,
+                       [ 'page_title', 'page_latest', 'old_id', 'old_text', 'old_flags' ],
+                       array_merge( $conds, [ 'page_len <= ' . intval( $wgMaxMsgCacheEntrySize ) ] ),
                        __METHOD__ . "($code)-small",
                        [],
                        [
@@ -524,23 +523,30 @@ class MessageCache {
                                'text' => [ 'JOIN', 'rev_text_id=old_id' ],
                        ]
                );
-
                foreach ( $res as $row ) {
-                       $text = Revision::getRevisionText( $row );
-                       if ( $text === false ) {
-                               // Failed to fetch data; possible ES errors?
-                               // Store a marker to fetch on-demand as a workaround...
-                               // TODO Use a differnt marker
-                               $entry = '!TOO BIG';
-                               wfDebugLog(
-                                       'MessageCache',
-                                       __METHOD__
-                                       . ": failed to load message page text for {$row->page_title} ($code)"
-                               );
+                       $name = $this->contLang->lcfirst( $row->page_title );
+                       // Include entries/stubs for all keys in $mostused in adaptive mode
+                       if ( $wgAdaptiveMessageCache || isset( $overridable[$name] ) ) {
+                               $text = Revision::getRevisionText( $row );
+                               if ( $text === false ) {
+                                       // Failed to fetch data; possible ES errors?
+                                       // Store a marker to fetch on-demand as a workaround...
+                                       // TODO Use a differnt marker
+                                       $entry = '!TOO BIG';
+                                       wfDebugLog(
+                                               'MessageCache',
+                                               __METHOD__
+                                               . ": failed to load message page text for {$row->page_title} ($code)"
+                                       );
+                               } else {
+                                       $entry = ' ' . $text;
+                               }
+                               $cache[$row->page_title] = $entry;
                        } else {
-                               $entry = ' ' . $text;
+                               // T193271: cache object gets too big and slow to generate.
+                               // At least include revision ID so page changes are reflected in the hash.
+                               $cache['EXCESSIVE'][$row->page_title] = $row->page_latest;
                        }
-                       $cache[$row->page_title] = $entry;
                }
 
                $cache['VERSION'] = MSG_CACHE_VERSION;
@@ -818,9 +824,8 @@ class MessageCache {
                Hooks::run( 'MessageCache::get', [ &$lckey ] );
 
                // Loop through each language in the fallback list until we find something useful
-               $lang = wfGetLangObj( $langcode );
                $message = $this->getMessageFromFallbackChain(
-                       $lang,
+                       wfGetLangObj( $langcode ),
                        $lckey,
                        !$this->mDisable && $useDB
                );
@@ -912,7 +917,6 @@ class MessageCache {
                                        $this->getMessagePageName( $langcode, $uckey ),
                                        $langcode
                                );
-
                                if ( $message !== false ) {
                                        return $message;
                                }
@@ -987,44 +991,54 @@ class MessageCache {
                $this->load( $code );
 
                $entry = $this->cache->getField( $code, $title );
+
                if ( $entry !== null ) {
+                       // Message page exists as an override of a software messages
                        if ( substr( $entry, 0, 1 ) === ' ' ) {
                                // The message exists and is not '!TOO BIG'
                                return (string)substr( $entry, 1 );
                        } elseif ( $entry === '!NONEXISTENT' ) {
+                               // The text might be '-' or missing due to some data loss
                                return false;
                        }
-                       // Fall through and try invididual message cache below
-               } else {
-                       // Message does not have a MediaWiki page definition
-                       $message = false;
-                       Hooks::run( 'MessagesPreLoad', [ $title, &$message, $code ] );
-                       if ( $message !== false ) {
-                               $this->cache->setField( $code, $title, ' ' . $message );
-                       } else {
-                               $this->cache->setField( $code, $title, '!NONEXISTENT' );
-                       }
-
-                       return $message;
-               }
-
-               if ( $this->cacheVolatile[$code] ) {
-                       $entry = false;
-                       // Make sure that individual keys respect the WAN cache holdoff period too
-                       LoggerFactory::getInstance( 'MessageCache' )->debug(
-                               __METHOD__ . ': loading volatile key \'{titleKey}\'',
-                               [ 'titleKey' => $title, 'code' => $code ] );
+                       // Load the message page, utilizing the individual message cache.
+                       // If the page does not exist, there will be no hook handler fallbacks.
+                       $entry = $this->loadCachedMessagePageEntry(
+                               $title,
+                               $code,
+                               $this->cache->getField( $code, 'HASH' )
+                       );
                } else {
-                       // Try the individual message cache
+                       // Message page does not exist or does not override a software message.
+                       // Load the message page, utilizing the individual message cache.
                        $entry = $this->loadCachedMessagePageEntry(
                                $title,
                                $code,
                                $this->cache->getField( $code, 'HASH' )
                        );
+                       if ( substr( $entry, 0, 1 ) !== ' ' ) {
+                               // Message does not have a MediaWiki page definition; try hook handlers
+                               $message = false;
+                               Hooks::run( 'MessagesPreLoad', [ $title, &$message, $code ] );
+                               if ( $message !== false ) {
+                                       $this->cache->setField( $code, $title, ' ' . $message );
+                               } else {
+                                       $this->cache->setField( $code, $title, '!NONEXISTENT' );
+                               }
+
+                               return $message;
+                       }
                }
 
                if ( $entry !== false && substr( $entry, 0, 1 ) === ' ' ) {
-                       $this->cache->setField( $code, $title, $entry );
+                       if ( $this->cacheVolatile[$code] ) {
+                               // Make sure that individual keys respect the WAN cache holdoff period too
+                               LoggerFactory::getInstance( 'MessageCache' )->debug(
+                                       __METHOD__ . ': loading volatile key \'{titleKey}\'',
+                                       [ 'titleKey' => $title, 'code' => $code ] );
+                       } else {
+                               $this->cache->setField( $code, $title, $entry );
+                       }
                        // The message exists, so make sure a string is returned
                        return (string)substr( $entry, 1 );
                }
index 8543c4b..e6a0e81 100644 (file)
@@ -135,15 +135,6 @@ class DeferredUpdates {
                }
        }
 
-       /**
-        * @param bool $value Whether to just immediately run updates in addUpdate()
-        * @since 1.28
-        * @deprecated 1.29 Causes issues in Web-executed jobs - see T165714 and T100085.
-        */
-       public static function setImmediateMode( $value ) {
-               wfDeprecated( __METHOD__, '1.29' );
-       }
-
        /**
         * @param DeferrableUpdate[] $queue
         * @param DeferrableUpdate $update
index 6a788b6..6d01c29 100644 (file)
@@ -2168,14 +2168,6 @@ abstract class File implements IDBAccessObject {
                return true;
        }
 
-       /**
-        * @deprecated since 1.30, use File::getContentHeaders instead
-        */
-       function getStreamHeaders() {
-               wfDeprecated( __METHOD__, '1.30' );
-               return $this->getContentHeaders();
-       }
-
        /**
         * @return string[] HTTP header name/value map to use for HEAD/GET request responses
         * @since 1.30
index aee51e7..f59b5da 100644 (file)
@@ -50,30 +50,30 @@ class CliInstaller extends Installer {
        /**
         * @param string $siteName
         * @param string|null $admin
-        * @param array $option
+        * @param array $options
         */
-       function __construct( $siteName, $admin = null, array $option = [] ) {
+       function __construct( $siteName, $admin = null, array $options = [] ) {
                global $wgContLang;
 
                parent::__construct();
 
-               if ( isset( $option['scriptpath'] ) ) {
+               if ( isset( $options['scriptpath'] ) ) {
                        $this->specifiedScriptPath = true;
                }
 
                foreach ( $this->optionMap as $opt => $global ) {
-                       if ( isset( $option[$opt] ) ) {
-                               $GLOBALS[$global] = $option[$opt];
-                               $this->setVar( $global, $option[$opt] );
+                       if ( isset( $options[$opt] ) ) {
+                               $GLOBALS[$global] = $options[$opt];
+                               $this->setVar( $global, $options[$opt] );
                        }
                }
 
-               if ( isset( $option['lang'] ) ) {
+               if ( isset( $options['lang'] ) ) {
                        global $wgLang, $wgLanguageCode;
-                       $this->setVar( '_UserLang', $option['lang'] );
-                       $wgLanguageCode = $option['lang'];
+                       $this->setVar( '_UserLang', $options['lang'] );
+                       $wgLanguageCode = $options['lang'];
                        $wgContLang = MediaWikiServices::getInstance()->getContentLanguage();
-                       $wgLang = Language::factory( $option['lang'] );
+                       $wgLang = Language::factory( $options['lang'] );
                        RequestContext::getMain()->setLanguage( $wgLang );
                }
 
@@ -89,32 +89,47 @@ class CliInstaller extends Installer {
                        $this->setVar( '_AdminName', $admin );
                }
 
-               if ( !isset( $option['installdbuser'] ) ) {
+               if ( !isset( $options['installdbuser'] ) ) {
                        $this->setVar( '_InstallUser',
                                $this->getVar( 'wgDBuser' ) );
                        $this->setVar( '_InstallPassword',
                                $this->getVar( 'wgDBpassword' ) );
                } else {
                        $this->setVar( '_InstallUser',
-                               $option['installdbuser'] );
+                               $options['installdbuser'] );
                        $this->setVar( '_InstallPassword',
-                               $option['installdbpass'] ?? "" );
+                               $options['installdbpass'] ?? "" );
 
                        // Assume that if we're given the installer user, we'll create the account.
                        $this->setVar( '_CreateDBAccount', true );
                }
 
-               if ( isset( $option['pass'] ) ) {
-                       $this->setVar( '_AdminPassword', $option['pass'] );
+               if ( isset( $options['pass'] ) ) {
+                       $this->setVar( '_AdminPassword', $options['pass'] );
                }
 
                // Detect and inject any extension found
-               if ( isset( $option['with-extensions'] ) ) {
+               if ( isset( $options['extensions'] ) ) {
+                       $status = $this->validateExtensions(
+                               'extension', 'extensions', $options['extensions'] );
+                       if ( !$status->isOK() ) {
+                               $this->showStatusMessage( $status );
+                       }
+                       $this->setVar( '_Extensions', $status->value );
+               } elseif ( isset( $options['with-extensions'] ) ) {
                        $this->setVar( '_Extensions', array_keys( $this->findExtensions() ) );
                }
 
                // Set up the default skins
-               $skins = array_keys( $this->findExtensions( 'skins' ) );
+               if ( isset( $options['skins'] ) ) {
+                       $status = $this->validateExtensions( 'skin', 'skins', $options['skins'] );
+                       if ( !$status->isOK() ) {
+                               $this->showStatusMessage( $status );
+                       }
+                       $skins = $status->value;
+               } else {
+                       $skins = array_keys( $this->findExtensions( 'skins' ) );
+               }
                $this->setVar( '_Skins', $skins );
 
                if ( $skins ) {
@@ -123,6 +138,28 @@ class CliInstaller extends Installer {
                }
        }
 
+       private function validateExtensions( $type, $directory, $nameLists ) {
+               $extensions = [];
+               $status = new Status;
+               foreach ( (array)$nameLists as $nameList ) {
+                       foreach ( explode( ',', $nameList ) as $name ) {
+                               $name = trim( $name );
+                               if ( $name === '' ) {
+                                       continue;
+                               }
+                               $extStatus = $this->getExtensionInfo( $type, $directory, $name );
+                               if ( $extStatus->isOK() ) {
+                                       $extensions[] = $name;
+                               } else {
+                                       $status->merge( $extStatus );
+                               }
+                       }
+               }
+               $extensions = array_unique( $extensions );
+               $status->value = $extensions;
+               return $status;
+       }
+
        /**
         * Main entry point.
         */
index 0f8a5b0..d51ea2e 100644 (file)
@@ -1264,15 +1264,33 @@ abstract class Installer {
        }
 
        /**
-        * Finds extensions that follow the format /$directory/Name/Name.php,
-        * and returns an array containing the value for 'Name' for each found extension.
+        * Find extensions or skins in a subdirectory of $IP.
+        * Returns an array containing the value for 'Name' for each found extension.
         *
-        * Reasonable values for $directory include 'extensions' (the default) and 'skins'.
-        *
-        * @param string $directory Directory to search in
+        * @param string $directory Directory to search in, relative to $IP, must be either "extensions"
+        *     or "skins"
         * @return array [ $extName => [ 'screenshots' => [ '...' ] ]
         */
        public function findExtensions( $directory = 'extensions' ) {
+               switch ( $directory ) {
+                       case 'extensions':
+                               return $this->findExtensionsByType( 'extension', 'extensions' );
+                       case 'skins':
+                               return $this->findExtensionsByType( 'skin', 'skins' );
+                       default:
+                               throw new InvalidArgumentException( "Invalid extension type" );
+               }
+       }
+
+       /**
+        * Find extensions or skins, and return an array containing the value for 'Name' for each found
+        * extension.
+        *
+        * @param string $type Either "extension" or "skin"
+        * @param string $directory Directory to search in, relative to $IP
+        * @return array [ $extName => [ 'screenshots' => [ '...' ] ]
+        */
+       protected function findExtensionsByType( $type = 'extension', $directory = 'extensions' ) {
                if ( $this->getVar( 'IP' ) === null ) {
                        return [];
                }
@@ -1282,40 +1300,15 @@ abstract class Installer {
                        return [];
                }
 
-               // extensions -> extension.json, skins -> skin.json
-               $jsonFile = substr( $directory, 0, strlen( $directory ) - 1 ) . '.json';
-
                $dh = opendir( $extDir );
                $exts = [];
                while ( ( $file = readdir( $dh ) ) !== false ) {
                        if ( !is_dir( "$extDir/$file" ) ) {
                                continue;
                        }
-                       $fullJsonFile = "$extDir/$file/$jsonFile";
-                       $isJson = file_exists( $fullJsonFile );
-                       $isPhp = false;
-                       if ( !$isJson ) {
-                               // Only fallback to PHP file if JSON doesn't exist
-                               $fullPhpFile = "$extDir/$file/$file.php";
-                               $isPhp = file_exists( $fullPhpFile );
-                       }
-                       if ( $isJson || $isPhp ) {
-                               // Extension exists. Now see if there are screenshots
-                               $exts[$file] = [];
-                               if ( is_dir( "$extDir/$file/screenshots" ) ) {
-                                       $paths = glob( "$extDir/$file/screenshots/*.png" );
-                                       foreach ( $paths as $path ) {
-                                               $exts[$file]['screenshots'][] = str_replace( $extDir, "../$directory", $path );
-                                       }
-
-                               }
-                       }
-                       if ( $isJson ) {
-                               $info = $this->readExtension( $fullJsonFile );
-                               if ( $info === false ) {
-                                       continue;
-                               }
-                               $exts[$file] += $info;
+                       $status = $this->getExtensionInfo( $type, $directory, $file );
+                       if ( $status->isOK() ) {
+                               $exts[$file] = $status->value;
                        }
                }
                closedir( $dh );
@@ -1324,12 +1317,65 @@ abstract class Installer {
                return $exts;
        }
 
+       /**
+        * @param string $type Either "extension" or "skin"
+        * @param string $parentRelPath The parent directory relative to $IP
+        * @param string $name The extension or skin name
+        * @return Status An object containing an error list. If there were no errors, an associative
+        *     array of information about the extension can be found in $status->value.
+        */
+       protected function getExtensionInfo( $type, $parentRelPath, $name ) {
+               if ( $this->getVar( 'IP' ) === null ) {
+                       throw new Exception( 'Cannot find extensions since the IP variable is not yet set' );
+               }
+               if ( $type !== 'extension' && $type !== 'skin' ) {
+                       throw new InvalidArgumentException( "Invalid extension type" );
+               }
+               $absDir = $this->getVar( 'IP' ) . "/$parentRelPath/$name";
+               $relDir = "../$parentRelPath/$name";
+               if ( !is_dir( $absDir ) ) {
+                       return Status::newFatal( 'config-extension-not-found', $name );
+               }
+               $jsonFile = $type . '.json';
+               $fullJsonFile = "$absDir/$jsonFile";
+               $isJson = file_exists( $fullJsonFile );
+               $isPhp = false;
+               if ( !$isJson ) {
+                       // Only fallback to PHP file if JSON doesn't exist
+                       $fullPhpFile = "$absDir/$name.php";
+                       $isPhp = file_exists( $fullPhpFile );
+               }
+               if ( !$isJson && !$isPhp ) {
+                       return Status::newFatal( 'config-extension-not-found', $name );
+               }
+
+               // Extension exists. Now see if there are screenshots
+               $info = [];
+               if ( is_dir( "$absDir/screenshots" ) ) {
+                       $paths = glob( "$absDir/screenshots/*.png" );
+                       foreach ( $paths as $path ) {
+                               $info['screenshots'][] = str_replace( $absDir, $relDir, $path );
+                       }
+               }
+
+               if ( $isJson ) {
+                       $jsonStatus = $this->readExtension( $fullJsonFile );
+                       if ( !$jsonStatus->isOK() ) {
+                               return $jsonStatus;
+                       }
+                       $info += $jsonStatus->value;
+               }
+
+               return Status::newGood( $info );
+       }
+
        /**
         * @param string $fullJsonFile
         * @param array $extDeps
         * @param array $skinDeps
         *
-        * @return array|bool False if this extension can't be loaded
+        * @return Status On success, an array of extension information is in $status->value. On
+        *    failure, the Status object will have an error list.
         */
        private function readExtension( $fullJsonFile, $extDeps = [], $skinDeps = [] ) {
                $load = [
@@ -1340,7 +1386,7 @@ abstract class Installer {
                        foreach ( $extDeps as $dep ) {
                                $fname = "$extDir/$dep/extension.json";
                                if ( !file_exists( $fname ) ) {
-                                       return false;
+                                       return Status::newFatal( 'config-extension-not-found', $dep );
                                }
                                $load[$fname] = 1;
                        }
@@ -1350,7 +1396,7 @@ abstract class Installer {
                        foreach ( $skinDeps as $dep ) {
                                $fname = "$skinDir/$dep/skin.json";
                                if ( !file_exists( $fname ) ) {
-                                       return false;
+                                       return Status::newFatal( 'config-extension-not-found', $dep );
                                }
                                $load[$fname] = 1;
                        }
@@ -1364,7 +1410,8 @@ abstract class Installer {
                        ) {
                                // If something is incompatible with a dependency, we have no real
                                // option besides skipping it
-                               return false;
+                               return Status::newFatal( 'config-extension-dependency',
+                                       basename( dirname( $fullJsonFile ) ), $e->getMessage() );
                        } elseif ( $e->missingExtensions || $e->missingSkins ) {
                                // There's an extension missing in the dependency tree,
                                // so add those to the dependency list and try again
@@ -1375,7 +1422,8 @@ abstract class Installer {
                                );
                        }
                        // Some other kind of dependency error?
-                       return false;
+                       return Status::newFatal( 'config-extension-dependency',
+                               basename( dirname( $fullJsonFile ) ), $e->getMessage() );
                }
                $ret = [];
                // The order of credits will be the order of $load,
@@ -1397,7 +1445,7 @@ abstract class Installer {
                }
                $ret['type'] = $credits['type'];
 
-               return $ret;
+               return Status::newGood( $ret );
        }
 
        /**
index c89be17..893df5a 100644 (file)
        "config-skins-screenshot": "$1 ($2)",
        "config-extensions-requires": "$1 (requires $2)",
        "config-screenshot": "screenshot",
+       "config-extension-not-found": "Could not find the registration file for the extension \"$1\"",
+       "config-extension-dependency": "A dependency error was encountered while installing the extension \"$1\": $2",
        "mainpagetext": "<strong>MediaWiki has been installed.</strong>",
        "mainpagedocfooter": "Consult the [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide] for information on using the wiki software.\n\n== Getting started ==\n* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings Configuration settings list]\n* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]\n* [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]\n* [https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation#Translation_resources Localise MediaWiki for your language]\n* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Combating_spam Learn how to combat spam on your wiki]"
 }
index e423bcd..39dbbca 100644 (file)
        "config-skins-screenshot": "Radio button text, $1 is the skin name, and $2 is a link to a screenshot of that skin, where the link text is {{msg-mw|config-screenshot}}.",
        "config-extensions-requires": "Radio button text, $1 is the extension name, and $2 are links to other extensions that this one requires.\n{{Identical|Require}}",
        "config-screenshot": "Link text for the link in {{msg-mw|config-skins-screenshot}}\n{{Identical|Screenshot}}",
+       "config-extension-not-found": "An error shown when an extension or skin named by the user could not be found.\n* $1 is the extension name",
+       "config-extension-dependency": "An error shown if an extension could not be loaded due to it depending on the wrong version of MediaWiki or an uninstallable extension.\n* $1 is the extension name\n* $2 is a more detailed explanation, in English",
        "mainpagetext": "Along with {{msg-mw|mainpagedocfooter}}, the text you will see on the Main Page when your wiki is installed.",
        "mainpagedocfooter": "Along with {{msg-mw|mainpagetext}}, the text you will see on the Main Page when your wiki is installed.\nThis might be a good place to put information about <nowiki>{{GRAMMAR:}}</nowiki>. See [[{{NAMESPACE}}:{{BASEPAGENAME}}/fi]] for an example. For languages having grammatical distinctions and not having an appropriate <nowiki>{{GRAMMAR:}}</nowiki> software available, a suggestion to check and possibly amend the messages having <nowiki>{{SITENAME}}</nowiki> may be valuable. See [[{{NAMESPACE}}:{{BASEPAGENAME}}/ksh]] for an example."
 }
index f87a336..63575eb 100644 (file)
@@ -134,4 +134,16 @@ class ThumbnailRenderJob extends Job {
                }
                return false;
        }
+
+       /**
+        * Whether to retry the job.
+        * @return bool
+        */
+       public function allowRetries() {
+               // ThumbnailRenderJob is a warmup for the thumbnails cache,
+               // so loosing it is not a problem. Most times the job fails
+               // for non-renderable or missing images which will not be fixed
+               // by a retry, but will create additional load on the renderer.
+               return false;
+       }
 }
index 0f820ae..71db975 100644 (file)
@@ -303,16 +303,6 @@ abstract class MediaHandler {
                return [ $ext, $mime ];
        }
 
-       /**
-        * @deprecated since 1.30, use MediaHandler::getContentHeaders instead
-        * @param array $metadata
-        * @return array
-        */
-       public function getStreamHeaders( $metadata ) {
-               wfDeprecated( __METHOD__, '1.30' );
-               return $this->getContentHeaders( $metadata );
-       }
-
        /**
         * True if the handled types can be transformed
         *
index 90ef335..dcb2c89 100644 (file)
@@ -612,8 +612,6 @@ class Parser {
                // Since we're not really outputting HTML, decode the entities and
                // then re-encode the things that need hiding inside HTML comments.
                $limitReport = htmlspecialchars_decode( $limitReport );
-               // Run deprecated hook
-               Hooks::run( 'ParserLimitReport', [ $this, &$limitReport ], '1.22' );
 
                // Sanitize for comment. Note '‐' in the replacement is U+2010,
                // which looks much like the problematic '-'.
index 445981b..6d238ca 100644 (file)
@@ -338,7 +338,7 @@ class ParserOutput extends CacheTime {
                                        return $skin->doEditSectionLink( $editsectionPage,
                                                $editsectionSection,
                                                $editsectionContent,
-                                               $wgLang->getCode()
+                                               $wgLang
                                        );
                                },
                                $text
@@ -1290,42 +1290,6 @@ class ParserOutput extends CacheTime {
                );
        }
 
-       // TODO remove this method once old parser cache objects have expired, probably mid-October 2018
-       public function __wakeup() {
-               // T203716 remove wrapper that was added by logic in an older version of this class,
-               // where the wrapper was included in mText. This might sometimes remove a wrapper that's
-               // genuine content (manually added to a system message), but that will work out OK, see below.
-               $text = $this->getRawText();
-               $start = Html::openElement( 'div', [
-                       'class' => 'mw-parser-output'
-               ] );
-               $startLen = strlen( $start );
-               $end = Html::closeElement( 'div' );
-               $endPos = strrpos( $text, $end );
-               $endLen = strlen( $end );
-               if ( substr( $text, 0, $startLen ) === $start && $endPos !== false
-                        // if the closing div is followed by real content, bail out of unwrapping
-                        && preg_match( '/^(?>\s*<!--.*?-->)*\s*$/s', substr( $text, $endPos + $endLen ) )
-               ) {
-                       $text = substr( $text, $startLen );
-                       $text = substr( $text, 0, $endPos - $startLen ) .
-                                       substr( $text, $endPos - $startLen + $endLen );
-                       $this->setText( $text );
-                       // We found a wrapper to remove, so the ParserOutput was probably created by the
-                       // code path that now contains an addWrapperDivClass( 'mw-parser-output' ) call,
-                       // but it did not contain it when this object was cached, so we need to fix the
-                       // wrapper class variable.
-                       // If this was a message with a manually added wrapper, we are technically wrong about
-                       // this but we were wrong about the unwrapping as well so it will work out just right,
-                       // except when this is a normal page view of such a message page, in which case
-                       // it will be single-wrapped instead of double-wrapped (harmless) or something wants
-                       // render the message with unwrap=true (in which case the message won't be wrapped even
-                       // though it should, but the few code paths using unwrap=true only do it for real pages).
-                       $this->clearWrapperDivClass();
-                       $this->addWrapperDivClass( 'mw-parser-output' );
-               }
-       }
-
        /**
         * Merges internal metadata such as flags, accessed options, and profiling info
         * from $source into this ParserOutput. This should be used whenever the state of $source
index ed4045d..f545532 100644 (file)
@@ -1610,15 +1610,20 @@ abstract class Skin extends ContextSource {
         * @param string $section The designation of the section being pointed to,
         *   to be included in the link, like "&section=$section"
         * @param string|null $tooltip The tooltip to use for the link: will be escaped
-        *   and wrapped in the 'editsectionhint' message
-        * @param string $lang Language code
+        *   and wrapped in the 'editsectionhint' message.
+        *   Not setting this parameter is deprecated.
+        * @param Language|string $lang Language object or language code string.
+        *   Type string is deprecated. Not setting this parameter is deprecated.
         * @return string HTML to use for edit link
         */
        public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) {
                // HTML generated here should probably have userlangattributes
                // added to it for LTR text on RTL pages
 
-               $lang = wfGetLangObj( $lang );
+               if ( !$lang instanceof Language ) {
+                       wfDeprecated( __METHOD__ . ' with other type than Language for $lang', '1.32' );
+                       $lang = wfGetLangObj( $lang );
+               }
 
                $attribs = [];
                if ( !is_null( $tooltip ) ) {
@@ -1659,12 +1664,6 @@ abstract class Skin extends ContextSource {
                );
 
                $result .= '<span class="mw-editsection-bracket">]</span></span>';
-               // Deprecated, use SkinEditSectionLinks hook instead
-               Hooks::run(
-                       'DoEditSectionLink',
-                       [ $this, $nt, $section, $tooltip, &$result, $lang ],
-                       '1.25'
-               );
                return $result;
        }
 
index ada5dc9..fe9a5c9 100644 (file)
@@ -5123,16 +5123,13 @@ class User implements IDBAccessObject, UserIdentity {
 
        /**
         * Get a list of implicit groups
+        * TODO: Should we deprecate this? It's trivial, but we don't want to encourage use of globals.
+        *
         * @return array Array of Strings Array of internal group names
         */
        public static function getImplicitGroups() {
                global $wgImplicitGroups;
-
-               $groups = $wgImplicitGroups;
-               # Deprecated, use $wgImplicitGroups instead
-               Hooks::run( 'UserGetImplicitGroups', [ &$groups ], '1.25' );
-
-               return $groups;
+               return $wgImplicitGroups;
        }
 
        /**
index 438e9dc..3395458 100644 (file)
@@ -90,6 +90,10 @@ class CommandLineInstaller extends Maintenance {
                $this->addOption( 'env-checks', "Run environment checks only, don't change anything" );
 
                $this->addOption( 'with-extensions', "Detect and include extensions" );
+               $this->addOption( 'extensions', 'Comma-separated list of extensions to install',
+                       false, true, false, true );
+               $this->addOption( 'skins', 'Comma-separated list of skins to install (default: all)',
+                       false, true, false, true );
        }
 
        public function getDbType() {
index c780b6a..2a1feb4 100755 (executable)
@@ -85,7 +85,7 @@ class UpdateMediaWiki extends Maintenance {
        }
 
        function execute() {
-               global $wgVersion, $wgLang, $wgAllowSchemaUpdates;
+               global $wgVersion, $wgLang, $wgAllowSchemaUpdates, $wgMessagesDirs;
 
                if ( !$wgAllowSchemaUpdates
                        && !( $this->hasOption( 'force' )
@@ -111,6 +111,9 @@ class UpdateMediaWiki extends Maintenance {
                        }
                }
 
+               // T206765: We need to load the installer i18n files as some of errors come installer/updater code
+               $wgMessagesDirs['MediawikiInstaller'] = dirname( __DIR__ ) . '/includes/installer/i18n';
+
                $lang = Language::factory( 'en' );
                // Set global language to ensure localised errors are in English (T22633)
                RequestContext::getMain()->setLanguage( $lang );
index feab0df..287d28c 100644 (file)
@@ -100,6 +100,14 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
         */
        private $mwGlobalsToUnset = [];
 
+       /**
+        * Holds original values of ini settings to be restored
+        * in tearDown().
+        * @see setIniSettings()
+        * @var array
+        */
+       private $iniSettings = [];
+
        /**
         * Holds original loggers which have been replaced by setLogger()
         * @var LoggerInterface[]
@@ -573,6 +581,9 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
                foreach ( $this->mwGlobalsToUnset as $value ) {
                        unset( $GLOBALS[$value] );
                }
+               foreach ( $this->iniSettings as $name => $value ) {
+                       ini_set( $name, $value );
+               }
                if (
                        array_key_exists( 'wgExtraNamespaces', $this->mwGlobals ) ||
                        in_array( 'wgExtraNamespaces', $this->mwGlobalsToUnset )
@@ -722,6 +733,18 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
                }
        }
 
+       /**
+        * Set an ini setting for the duration of the test
+        * @param string $name Name of the setting
+        * @param string $value Value to set
+        * @since 1.32
+        */
+       protected function setIniSetting( $name, $value ) {
+               $original = ini_get( $name );
+               $this->iniSettings[$name] = $original;
+               ini_set( $name, $value );
+       }
+
        /**
         * Must be called whenever namespaces are changed, e.g., $wgExtraNamespaces is altered.
         * Otherwise old namespace data will lurk and cause bugs.
index c1efc7f..c66b712 100644 (file)
@@ -54,23 +54,6 @@ class HooksTest extends MediaWikiTestCase {
                ];
        }
 
-       /**
-        * @dataProvider provideHooks
-        * @covers ::wfRunHooks
-        */
-       public function testOldStyleHooks( $msg, array $hook, $expectedFoo, $expectedBar ) {
-               global $wgHooks;
-
-               $this->hideDeprecated( 'wfRunHooks' );
-               $foo = $bar = 'original';
-
-               $wgHooks['MediaWikiHooksTest001'][] = $hook;
-               wfRunHooks( 'MediaWikiHooksTest001', [ &$foo, &$bar ] );
-
-               $this->assertSame( $expectedFoo, $foo, $msg );
-               $this->assertSame( $expectedBar, $bar, $msg );
-       }
-
        /**
         * @dataProvider provideHooks
         * @covers Hooks::register
index 94cbf5c..390ea41 100644 (file)
@@ -149,37 +149,6 @@ class ParserOutputTest extends MediaWikiLangTestCase {
                $this->assertNotContains( 'class="foo bar"', $text );
        }
 
-       public function testT203716() {
-               // simulate extra wrapping from old parser cache
-               $out = new ParserOutput( '<div class="mw-parser-output">Foo</div>' );
-               $out = unserialize( serialize( $out ) );
-
-               $plainText = $out->getText( [ 'unwrap' => true ] );
-               $wrappedText = $out->getText( [ 'unwrap' => false ] );
-               $wrappedText2 = $out->getText( [ 'wrapperDivClass' => 'mw-parser-output' ] );
-
-               $this->assertNotContains( '<div', $plainText );
-               $this->assertContains( '<div', $wrappedText );
-               $this->assertStringNotMatchesFormat( '<div%s<div%s', $wrappedText );
-               $this->assertContains( '<div', $wrappedText2 );
-               $this->assertStringNotMatchesFormat( '<div%s<div%s', $wrappedText2 );
-
-               // simulate ParserOuput creation by new parser code
-               $out = new ParserOutput( 'Foo' );
-               $out->addWrapperDivClass( 'mw-parser-outout' );
-               $out = unserialize( serialize( $out ) );
-
-               $plainText = $out->getText( [ 'unwrap' => true ] );
-               $wrappedText = $out->getText( [ 'unwrap' => false ] );
-               $wrappedText2 = $out->getText( [ 'wrapperDivClass' => 'mw-parser-output' ] );
-
-               $this->assertNotContains( '<div', $plainText );
-               $this->assertContains( '<div', $wrappedText );
-               $this->assertStringNotMatchesFormat( '<div%s<div%s', $wrappedText );
-               $this->assertContains( '<div', $wrappedText2 );
-               $this->assertStringNotMatchesFormat( '<div%s<div%s', $wrappedText2 );
-       }
-
        /**
         * @covers ParserOutput::getText
         * @dataProvider provideGetText
index d57d489..92d986d 100644 (file)
@@ -32,12 +32,6 @@ abstract class AbstractChangesListSpecialPageTestCase extends MediaWikiTestCase
                        'patrol' => true,
                ];
 
-               // Deprecated
-               $this->setTemporaryHook(
-                       'ChangesListSpecialPageFilters',
-                       null
-               );
-
                # setup the ChangesListSpecialPage (or subclass) object
                $this->changesListSpecialPage = $this->getPage();
                $context = $this->changesListSpecialPage->getContext();
index 2ebefac..28e26a0 100644 (file)
@@ -13,11 +13,6 @@ class SpecialWatchlistTest extends SpecialPageTestBase {
        public function setUp() {
                parent::setUp();
 
-               $this->setTemporaryHook(
-                       'ChangesListSpecialPageFilters',
-                       null
-               );
-
                $this->setTemporaryHook(
                        'ChangesListSpecialPageQuery',
                        null
@@ -102,11 +97,6 @@ class SpecialWatchlistTest extends SpecialPageTestBase {
                        $this->newSpecialPage()
                );
 
-               $this->setTemporaryHook(
-                       'ChangesListSpecialPageFilters',
-                       null
-               );
-
                $page->registerFilters();
 
                // Does not consider $preferences, just wiki's defaults
index 8ccacfc..0ce0e90 100644 (file)
@@ -169,9 +169,8 @@ class LanguageConverterTest extends MediaWikiLangTestCase {
                        $testString .= 'xxx xxx xxx';
                }
                $testString .= "\n<big id='в'></big>";
-               $old = ini_set( 'pcre.backtrack_limit', 200 );
+               $this->setIniSetting( 'pcre.backtrack_limit', 200 );
                $result = $this->lc->autoConvert( $testString, 'tg-latn' );
-               ini_set( 'pcre.backtrack_limit', $old );
                // The в in the id attribute should not get converted to a v
                $this->assertFalse(
                        strpos( $result, 'v' ),