From: jenkins-bot Date: Wed, 9 Nov 2016 16:18:55 +0000 (+0000) Subject: Merge "Even more out-factoring to methods in the header" X-Git-Tag: 1.31.0-rc.0~4914 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%2C%22id_auteur=%24connecte%22%29%20.%20%22?a=commitdiff_plain;h=ea60bd7c46f2ccc866829f06919ad87e5ca9de53;hp=bcc28e8b772066c56a339448b86cb549c772d259;p=lhc%2Fweb%2Fwiklou.git Merge "Even more out-factoring to methods in the header" --- diff --git a/RELEASE-NOTES-1.28 b/RELEASE-NOTES-1.28 index a2a986f1d1..557162e9ef 100644 --- a/RELEASE-NOTES-1.28 +++ b/RELEASE-NOTES-1.28 @@ -5,6 +5,20 @@ THIS IS NOT A RELEASE YET MediaWiki 1.28 is an alpha-quality branch and is not recommended for use in production. +=== Changes since 1.28.0rc0 === +* (T142210) The changes to move the parser "NewPP limit report" from a HTML + comment to a machine-readable JavaScript config option 'wgPageParseReport' + have been undone. They caused the human-readable limit report to be shown + incompletely or not at all. ParserOutput::setLimitReportData() and + getLimitReportData() behave as they did in MediaWiki 1.27 again. +* (T149510) Value of {{DISPLAYTITLE:}} parser function will not be used for + the text of subheadings on a category page when creating it. This wasn't + working correctly. +* (T106793) MediaWiki will no longer try to perform a HTTP redirect to the + canonical pretty URL when a non-pretty URL is used. It resulted in redirect + loops in some clients and in some server configurations. This undoes a change + made in MediaWiki 1.26. + === Configuration changes in 1.28 === * $wgSend404Code now affects status code of action=history if the page is not there. * BREAKING CHANGE: $wgHTTPProxy is now *required* for all external requests @@ -34,6 +48,14 @@ production. instead of just administrators ('sysop'). Documentation for this feature is available at . * $wgRevisionCacheExpiry is now set to one week by default instead of being disabled. +* Magic links are now disabled by default, and can be re-enabled by modifying the value + of $wgEnableMagicLinks. Their usage is discouraged, but if they are manually enabled, + a tracking category will be added to help identify usage and make it easier to migrate + away from. If you depend upon magic link functionality, it is requested that you comment + on and + explain your use case(s). +* New config variable $wgCSPFalsePositiveUrls to control what URLs to ignore + in upcoming Content-Security-Policy feature's reporting. === New features in 1.28 === * User::isBot() method for checking if an account is a bot role account. @@ -203,7 +225,6 @@ changes to languages because of Phabricator reports. * 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). @@ -223,8 +244,6 @@ changes to languages because of Phabricator reports. Instead of --keep-uploads, use the same option to parserTests.php, but you must specify a directory with --upload-dir. * The 'jquery.arrowSteps' ResourceLoader module is now deprecated. -* (T62604) Core parser functions returning a number now format the number according - to the page content language, not wiki content language. * IP::isConfiguredProxy() and IP::isTrustedProxy() were removed. Callers should migrate to using the same functions on a ProxyLookup instance, obtainable from MediaWikiServices. diff --git a/RELEASE-NOTES-1.29 b/RELEASE-NOTES-1.29 index 6c5380942b..5a38cf91a2 100644 --- a/RELEASE-NOTES-1.29 +++ b/RELEASE-NOTES-1.29 @@ -20,6 +20,10 @@ production. === Bug fixes in 1.29 === === Action API changes in 1.29 === +* Submitting sensitive authentication request parameters to action=clientlogin, + action=createaccount, action=linkaccount, and action=changeauthenticationdata + in the query string is now an error. They should be submitted in the POST + body instead. === Action API internal changes in 1.29 === diff --git a/autoload.php b/autoload.php index 3a2d06ff20..30ef985be0 100644 --- a/autoload.php +++ b/autoload.php @@ -556,6 +556,7 @@ $wgAutoloadLocalClasses = [ 'HTMLSelectNamespace' => __DIR__ . '/includes/htmlform/fields/HTMLSelectNamespace.php', 'HTMLSelectNamespaceWithButton' => __DIR__ . '/includes/htmlform/fields/HTMLSelectNamespaceWithButton.php', 'HTMLSelectOrOtherField' => __DIR__ . '/includes/htmlform/fields/HTMLSelectOrOtherField.php', + 'HTMLSizeFilterField' => __DIR__ . '/includes/htmlform/fields/HTMLSizeFilterField.php', 'HTMLSubmitField' => __DIR__ . '/includes/htmlform/fields/HTMLSubmitField.php', 'HTMLTagFilter' => __DIR__ . '/includes/htmlform/fields/HTMLTagFilter.php', 'HTMLTextAreaField' => __DIR__ . '/includes/htmlform/fields/HTMLTextAreaField.php', @@ -858,6 +859,7 @@ $wgAutoloadLocalClasses = [ 'MediaWiki\\Diff\\WordAccumulator' => __DIR__ . '/includes/diff/WordAccumulator.php', 'MediaWiki\\Interwiki\\ClassicInterwikiLookup' => __DIR__ . '/includes/interwiki/ClassicInterwikiLookup.php', 'MediaWiki\\Interwiki\\InterwikiLookup' => __DIR__ . '/includes/interwiki/InterwikiLookup.php', + 'MediaWiki\\Interwiki\\InterwikiLookupAdapter' => __DIR__ . '/includes/interwiki/InterwikiLookupAdapter.php', 'MediaWiki\\Languages\\Data\\Names' => __DIR__ . '/languages/data/Names.php', 'MediaWiki\\Languages\\Data\\ZhConversion' => __DIR__ . '/languages/data/ZhConversion.php', 'MediaWiki\\Linker\\LinkRenderer' => __DIR__ . '/includes/linker/LinkRenderer.php', @@ -919,6 +921,7 @@ $wgAutoloadLocalClasses = [ 'MediaWiki\\Tidy\\TidyDriverBase' => __DIR__ . '/includes/tidy/TidyDriverBase.php', 'MediaWiki\\Widget\\ComplexNamespaceInputWidget' => __DIR__ . '/includes/widget/ComplexNamespaceInputWidget.php', 'MediaWiki\\Widget\\ComplexTitleInputWidget' => __DIR__ . '/includes/widget/ComplexTitleInputWidget.php', + 'MediaWiki\\Widget\\DateInputWidget' => __DIR__ . '/includes/widget/DateInputWidget.php', 'MediaWiki\\Widget\\DateTimeInputWidget' => __DIR__ . '/includes/widget/DateTimeInputWidget.php', 'MediaWiki\\Widget\\NamespaceInputWidget' => __DIR__ . '/includes/widget/NamespaceInputWidget.php', 'MediaWiki\\Widget\\SearchInputWidget' => __DIR__ . '/includes/widget/SearchInputWidget.php', @@ -1007,6 +1010,7 @@ $wgAutoloadLocalClasses = [ 'OrphanStats' => __DIR__ . '/maintenance/storage/orphanStats.php', 'Orphans' => __DIR__ . '/maintenance/orphans.php', 'OutputPage' => __DIR__ . '/includes/OutputPage.php', + 'PHPVersionCheck' => __DIR__ . '/includes/PHPVersionCheck.php', 'PNGHandler' => __DIR__ . '/includes/media/PNG.php', 'PNGMetadataExtractor' => __DIR__ . '/includes/media/PNGMetadataExtractor.php', 'PPCustomFrame_DOM' => __DIR__ . '/includes/parser/Preprocessor_DOM.php', @@ -1529,6 +1533,7 @@ $wgAutoloadLocalClasses = [ 'WatchAction' => __DIR__ . '/includes/actions/WatchAction.php', 'WatchedItem' => __DIR__ . '/includes/WatchedItem.php', 'WatchedItemQueryService' => __DIR__ . '/includes/WatchedItemQueryService.php', + 'WatchedItemQueryServiceExtension' => __DIR__ . '/includes/WatchedItemQueryServiceExtension.php', 'WatchedItemStore' => __DIR__ . '/includes/WatchedItemStore.php', 'WatchlistCleanup' => __DIR__ . '/maintenance/cleanupWatchlist.php', 'WebInstaller' => __DIR__ . '/includes/installer/WebInstaller.php', diff --git a/docs/hooks.txt b/docs/hooks.txt index 562d7b4b2f..4543077c56 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -565,6 +565,18 @@ your callback to the $tokenFunctions array and return true (returning false makes no sense). &$tokenFunctions: array(action => callback) +'ApiQueryWatchlistExtractOutputData': Extract row data for ApiQueryWatchlist. +$module: ApiQueryWatchlist instance +$watchedItem: WatchedItem instance +$recentChangeInfo: Array of recent change info data +&$vals: Associative array of data to be output for the row + +'ApiQueryWatchlistPrepareWatchedItemQueryServiceOptions': Populate the options +to be passed from ApiQueryWatchlist to WatchedItemQueryService. +$module: ApiQueryWatchlist instance +$params: Array of parameters, as would be returned by $module->extractRequestParams() +&$options: Array of options for WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo() + 'ApiRsdServiceApis': Add or remove APIs from the RSD services list. Each service should have its own entry in the $apis array and have a unique name, passed as key for the array that represents the service data. In this data array, the @@ -1188,7 +1200,6 @@ wrapped in a span element which has class="patrollink". $differenceEngine: DifferenceEngine object &$markAsPatrolledLink: The "mark as patrolled" link HTML (string) $rcid: Recent change ID (rc_id) for this change (int) -$token: Patrol token; $rcid is used in generating this variable 'DifferenceEngineMarkPatrolledRCID': Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the @@ -1914,8 +1925,8 @@ $code: language of the preferred translations in various places to allow extensions to define the effective language links for a page. $title: The page's Title. -&$links: Associative array mapping language codes to prefixed links of the - form "language:title". +&$links: Array with elements of the form "language:title" in the order + that they will be output. &$linkFlags: Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. @@ -2475,12 +2486,24 @@ cache or return false to not use it. &$parser: Parser object &$varCache: variable cache (array) -'ParserLimitReport': DEPRECATED! Use ParserLimitReportPrepare instead. +'ParserLimitReport': DEPRECATED! 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 +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 @@ -2509,10 +2532,6 @@ $showEditLinks: boolean describing whether this section has an edit link &$globals: Array with all the globals which should be set for parser tests. The arrays keys serve as the globals names, its values are the globals values. -'ParserTestParser': Called when creating a new instance of Parser in -tests/parser/parserTest.inc. -&$parser: Parser object created - 'ParserTestTables': Alter the list of tables to duplicate when parser tests are run. Use when page save hooks require the presence of custom tables to ensure that tests continue to run properly. @@ -3735,6 +3754,10 @@ used to alter the SQL query which gets the list of wanted pages. &$user: user that watched &$page: WikiPage object watched +'WatchedItemQueryServiceExtensions': Create a WatchedItemQueryServiceExtension. +&$extensions: Add WatchedItemQueryServiceExtension objects to this array +$watchedItemQueryService: Service object + 'WatchlistEditorBeforeFormRender': Before building the Special:EditWatchlist form, used to manipulate the list of pages or preload data based on that list. &$watchlistInfo: array of watchlisted pages in diff --git a/includes/AjaxDispatcher.php b/includes/AjaxDispatcher.php index 91422385a2..d444a2791f 100644 --- a/includes/AjaxDispatcher.php +++ b/includes/AjaxDispatcher.php @@ -90,7 +90,6 @@ class AjaxDispatcher { # Or we could throw an exception: # throw new MWException( __METHOD__ . ' called without any data (mode empty).' ); } - } /** @@ -156,6 +155,5 @@ class AjaxDispatcher { } } } - } } diff --git a/includes/AjaxResponse.php b/includes/AjaxResponse.php index 4fe46dd1af..0686578c17 100644 --- a/includes/AjaxResponse.php +++ b/includes/AjaxResponse.php @@ -161,7 +161,7 @@ class AjaxResponse { // For back-compat, it is supported that mResponseCode be a string like " 200 OK" // (with leading space and the status message after). Cast response code to an integer // to take advantage of PHP's conversion rules which will turn " 200 OK" into 200. - // http://php.net/string#language.types.string.conversion + // https://secure.php.net/manual/en/language.types.string.php#language.types.string.conversion $n = intval( trim( $this->mResponseCode ) ); HttpStatus::header( $n ); } diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index c858dd7164..b95f274406 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -422,26 +422,11 @@ 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() { - $name = $this->getPrettyPageNameHtml(); + $ti = wfEscapeWikiText( $this->title->getText() ); # Don't show articles section if there are none. $r = ''; @@ -457,7 +442,7 @@ class CategoryViewer extends ContextSource { if ( $rescnt > 0 ) { $r = "
\n"; - $r .= '

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

\n"; + $r .= '

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

\n"; $r .= $countmsg; $r .= $this->getSectionPagingLinks( 'page' ); $r .= $this->formatList( $this->articles, $this->articles_start_char ); @@ -471,7 +456,6 @@ 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(); @@ -481,7 +465,10 @@ class CategoryViewer extends ContextSource { if ( $rescnt > 0 ) { $r .= "
\n"; $r .= '

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

\n"; $r .= $countmsg; $r .= $this->getSectionPagingLinks( 'file' ); diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 98dd2b7b4f..9d8ccf89c4 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -311,7 +311,7 @@ $wgAppleTouchIcon = false; * Value for the referrer policy meta tag. * One of 'never', 'default', 'origin', 'always'. Setting it to false just * prevents the meta tag from being output. - * See http://www.w3.org/TR/referrer-policy/ for details. + * See https://www.w3.org/TR/referrer-policy/ for details. * * @since 1.25 */ @@ -658,7 +658,7 @@ $wgLockManagers = []; /** * Show Exif data, on by default if available. - * Requires PHP's Exif extension: http://www.php.net/manual/en/ref.exif.php + * Requires PHP's Exif extension: https://secure.php.net/manual/en/ref.exif.php * * @note FOR WINDOWS USERS: * To enable Exif functions, add the following line to the "Windows @@ -1511,7 +1511,7 @@ $wgDjvuTxt = null; * For now we recommend you use djvudump instead. The djvuxml output is * probably more stable, so we'll switch back to it as soon as they fix * the efficiency problem. - * http://sourceforge.net/tracker/index.php?func=detail&aid=1704049&group_id=32953&atid=406583 + * https://sourceforge.net/tracker/index.php?func=detail&aid=1704049&group_id=32953&atid=406583 * * @par Example: * @code @@ -1973,7 +1973,7 @@ $wgDBerrorLog = false; * Defaults to the wiki timezone ($wgLocaltimezone). * * A list of usable timezones can found at: - * http://php.net/manual/en/timezones.php + * https://secure.php.net/manual/en/timezones.php * * @par Examples: * @code @@ -3110,7 +3110,7 @@ $wgForceUIMsgAsContentMsg = []; * timezone-nameinlowercase like timezone-utc. * * A list of usable timezones can found at: - * http://php.net/manual/en/timezones.php + * https://secure.php.net/manual/en/timezones.php * * @par Examples: * @code @@ -3178,7 +3178,7 @@ $wgHtml5 = true; * * If your wiki uses RDFa, set it to the correct value for RDFa+HTML5. * Correct current values are 'HTML+RDFa 1.0' or 'XHTML+RDFa 1.0'. - * See also http://www.w3.org/TR/rdfa-in-html/#document-conformance + * See also https://www.w3.org/TR/rdfa-in-html/#document-conformance * @since 1.16 */ $wgHtml5Version = null; @@ -4216,7 +4216,7 @@ $wgAllowImageTag = false; /** * Configuration for HTML postprocessing tool. Set this to a configuration * array to enable an external tool. Dave Raggett's "HTML Tidy" is typically - * used. See http://www.w3.org/People/Raggett/tidy/ + * used. See https://www.w3.org/People/Raggett/tidy/ * * If this is null and $wgUseTidy is true, the deprecated configuration * parameters will be used instead. @@ -4363,9 +4363,9 @@ $wgTranscludeCacheExpiry = 3600; * @since 1.28 */ $wgEnableMagicLinks = [ - 'ISBN' => true, - 'PMID' => true, - 'RFC' => true + 'ISBN' => false, + 'PMID' => false, + 'RFC' => false ]; /** @} */ # end of parser settings } @@ -5747,6 +5747,8 @@ $wgGrantPermissions['viewdeleted']['browsearchive'] = true; $wgGrantPermissions['viewdeleted']['deletedhistory'] = true; $wgGrantPermissions['viewdeleted']['deletedtext'] = true; +$wgGrantPermissions['viewrestrictedlogs']['suppressionlog'] = true; + $wgGrantPermissions['delete'] = $wgGrantPermissions['editpage'] + $wgGrantPermissions['viewdeleted']; $wgGrantPermissions['delete']['delete'] = true; @@ -5797,6 +5799,7 @@ $wgGrantPermissionGroups = [ 'blockusers' => 'administration', 'delete' => 'administration', 'viewdeleted' => 'administration', + 'viewrestrictedlogs' => 'administration', 'protect' => 'administration', 'createaccount' => 'administration', @@ -6372,9 +6375,9 @@ $wgDisableInternalSearch = false; * To forward to Google you'd have something like: * @code * $wgSearchForwardUrl = - * 'http://www.google.com/search?q=$1' . - * '&domains=http://example.com' . - * '&sitesearch=http://example.com' . + * 'https://www.google.com/search?q=$1' . + * '&domains=https://example.com' . + * '&sitesearch=https://example.com' . * '&ie=utf-8&oe=utf-8'; * @endcode */ @@ -6707,9 +6710,9 @@ $wgFeedDiffCutoff = 32768; * Should be a format as key (either 'rss' or 'atom') and an URL to the feed * as value. * @par Example: - * Configure the 'atom' feed to http://example.com/somefeed.xml + * Configure the 'atom' feed to https://example.com/somefeed.xml * @code - * $wgSiteFeed['atom'] = "http://example.com/somefeed.xml"; + * $wgSiteFeed['atom'] = "https://example.com/somefeed.xml"; * @endcode */ $wgOverrideSiteFeed = []; @@ -7118,7 +7121,7 @@ $wgAutoloadAttemptLowercase = true; * 'Foo Barstein', * ], * 'version' => '1.9.0', - * 'url' => 'http://example.org/example-extension/', + * 'url' => 'https://example.org/example-extension/', * 'descriptionmsg' => 'exampleextension-desc', * 'license-name' => 'GPL-2.0+', * ]; @@ -7145,7 +7148,7 @@ $wgAutoloadAttemptLowercase = true; * - author: A string or an array of strings. Authors can be linked using * the regular wikitext link syntax. To have an internationalized version of * "and others" show, add an element "...". This element can also be linked, - * for instance "[http://example ...]". + * for instance "[https://example ...]". * * - descriptionmsg: A message key or an an array with message key and parameters: * `'descriptionmsg' => 'exampleextension-desc',` @@ -7363,7 +7366,7 @@ $wgCategoryPagingLimit = 200; * all languages in a mediocre way. However, it is better than "uppercase". * * To use the uca-default collation, you must have PHP's intl extension - * installed. See http://php.net/manual/en/intl.setup.php . The details of the + * installed. See https://secure.php.net/manual/en/intl.setup.php . The details of the * resulting collation will depend on the version of ICU installed on the * server. * @@ -8032,7 +8035,7 @@ $wgShellCgroup = false; $wgPhpCli = '/usr/bin/php'; /** - * Locale for LC_CTYPE, to work around http://bugs.php.net/bug.php?id=45132 + * Locale for LC_CTYPE, to work around https://bugs.php.net/bug.php?id=45132 * For Unix-like operating systems, set this to to a locale that has a UTF-8 * character set. Only the character set is relevant. */ diff --git a/includes/EditPage.php b/includes/EditPage.php index cd6fb562bb..78ef2e32cb 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1044,7 +1044,6 @@ class EditPage { // Allow extensions to modify form data Hooks::run( 'EditPage::importFormData', [ $this, $request ] ); - } /** @@ -1646,7 +1645,7 @@ class EditPage { // being set. This is used by ConfirmEdit to display a captcha // without any error message cruft. } else { - $this->hookError = $this->formatStatusErrors( $status ); + $this->hookError = $status->getWikiText(); } // Use the existing $status->value if the hook set it if ( !$status->value ) { @@ -1656,7 +1655,7 @@ class EditPage { } elseif ( !$status->isOK() ) { # ...or the hook could be expecting us to produce an error // FIXME this sucks, we should just use the Status object throughout - $this->hookError = $this->formatStatusErrors( $status ); + $this->hookError = $status->getWikiText(); $status->fatal( 'hookaborted' ); $status->value = self::AS_HOOK_ERROR_EXPECTED; return false; @@ -1665,26 +1664,6 @@ class EditPage { return true; } - /** - * Wrap status errors in an errorbox for increased visiblity - * - * @param Status $status - * @return string - */ - private function formatStatusErrors( Status $status ) { - $errmsg = $status->getHTML( - 'edit-error-short', - 'edit-error-long', - $this->context->getLanguage() - ); - return << -{$errmsg} -
-
-ERROR; - } - /** * Return the summary to be used for a new section. * @@ -2257,7 +2236,6 @@ ERROR; * @return bool */ private function mergeChangesIntoContent( &$editContent ) { - $db = wfGetDB( DB_MASTER ); // This is the revision the editor started from @@ -2844,7 +2822,6 @@ ERROR; if ( !$wgUser->getOption( 'previewontop' ) ) { $this->displayPreviewArea( $previewOutput, false ); } - } /** @@ -2870,7 +2847,6 @@ ERROR; return Html::rawElement( 'div', [ 'class' => 'templatesUsed' ], $templateListFormatter->format( $templates, $type ) ); - } /** @@ -3512,22 +3488,16 @@ HTML ] ) . Html::openElement( 'tbody' ); - foreach ( $output->getLimitReportData()['limitreport'] as $key => $value ) { + foreach ( $output->getLimitReportData() as $key => $value ) { if ( Hooks::run( 'ParserLimitReportFormat', [ $key, &$value, &$limitReport, true, true ] ) ) { - $keyMsg = wfMessage( "limitreport-$key" ); - $valueMsg = wfMessage( - [ "limitreport-$key-value-html", "limitreport-$key-value" ] - ); + $keyMsg = wfMessage( $key ); + $valueMsg = wfMessage( [ "$key-value-html", "$key-value" ] ); if ( !$valueMsg->exists() ) { $valueMsg = new RawMessage( '$1' ); } if ( !$keyMsg->isDisabled() && !$valueMsg->isDisabled() ) { - // If it's a value/limit array, convert it for $1/$2 - if ( is_array( $value ) && isset( $value['value'] ) ) { - $value = [ $value['value'], $value['limit'] ]; - } $limitReport .= Html::openElement( 'tr' ) . Html::rawElement( 'th', null, $keyMsg->parse() ) . Html::rawElement( 'td', null, $valueMsg->params( $value )->parse() ) . @@ -4359,6 +4329,9 @@ HTML return strtr( $result, [ "�" => "&#x" ] ); } + /** + * @since 1.29 + */ protected function addEditNotices() { global $wgOut; @@ -4377,6 +4350,9 @@ HTML } } + /** + * @since 1.29 + */ protected function addTalkPageText() { global $wgOut; diff --git a/includes/Feed.php b/includes/Feed.php index 8bfe1c7ef9..189fd9f2fb 100644 --- a/includes/Feed.php +++ b/includes/Feed.php @@ -236,7 +236,6 @@ abstract class ChannelFeed extends FeedItem { $wgOut->addVaryHeader( 'X-Forwarded-Proto' ); } $wgOut->sendCacheControl(); - } /** diff --git a/includes/FormOptions.php b/includes/FormOptions.php index 5e5e8d4011..725a512980 100644 --- a/includes/FormOptions.php +++ b/includes/FormOptions.php @@ -52,6 +52,9 @@ class FormOptions implements ArrayAccess { * This is useful for the namespace selector. */ const INTNULL = 3; + /** Array type, maps guessType() to WebRequest::getArray() + * @since 1.29 */ + const ARR = 5; /* @} */ /** @@ -120,6 +123,8 @@ class FormOptions implements ArrayAccess { return self::FLOAT; } elseif ( is_string( $data ) ) { return self::STRING; + } elseif ( is_array( $data ) ) { + return self::ARR; } else { throw new MWException( 'Unsupported datatype' ); } @@ -358,6 +363,9 @@ class FormOptions implements ArrayAccess { case self::INTNULL: $value = $r->getIntOrNull( $name ); break; + case self::ARR: + $value = $r->getArray( $name ); + break; default: throw new MWException( 'Unsupported datatype' ); } @@ -370,7 +378,7 @@ class FormOptions implements ArrayAccess { /** @name ArrayAccess functions * These functions implement the ArrayAccess PHP interface. - * @see http://php.net/manual/en/class.arrayaccess.php + * @see https://secure.php.net/manual/en/class.arrayaccess.php */ /* @{ */ /** diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index bae9c772e3..b3ccc5675a 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -40,7 +40,7 @@ use Wikimedia\ScopedCallback; */ // hash_equals function only exists in PHP >= 5.6.0 -// http://php.net/hash_equals +// https://secure.php.net/hash_equals if ( !function_exists( 'hash_equals' ) ) { /** * Check whether a user-provided string is equal to a fixed-length secret string @@ -1670,7 +1670,9 @@ function wfClientAcceptsGzip( $force = false ) { function wfEscapeWikiText( $text ) { global $wgEnableMagicLinks; static $repl = null, $repl2 = null; - if ( $repl === null ) { + if ( $repl === null || defined( 'MW_PARSER_TEST' ) || defined( 'MW_PHPUNIT_TEST' ) ) { + // Tests depend upon being able to change $wgEnableMagicLinks, so don't cache + // in those situations $repl = [ '"' => '"', '&' => '&', "'" => ''', '<' => '<', '=' => '=', '>' => '>', '[' => '[', ']' => ']', @@ -2136,7 +2138,7 @@ function wfMkdirParents( $dir, $mode = null, $caller = null ) { */ function wfRecursiveRemoveDir( $dir ) { wfDebug( __FUNCTION__ . "( $dir )\n" ); - // taken from http://de3.php.net/manual/en/function.rmdir.php#98622 + // taken from https://secure.php.net/manual/en/function.rmdir.php#98622 if ( is_dir( $dir ) ) { $objects = scandir( $dir ); foreach ( $objects as $object ) { @@ -2229,8 +2231,8 @@ function wfEscapeShellArg( /*...*/ ) { // Escaping for an MSVC-style command line parser and CMD.EXE // @codingStandardsIgnoreStart For long URLs // Refs: - // * http://web.archive.org/web/20020708081031/http://mailman.lyra.org/pipermail/scite-interest/2002-March/000436.html - // * http://technet.microsoft.com/en-us/library/cc723564.aspx + // * https://web.archive.org/web/20020708081031/http://mailman.lyra.org/pipermail/scite-interest/2002-March/000436.html + // * https://technet.microsoft.com/en-us/library/cc723564.aspx // * T15518 // * CR r63214 // Double the backslashes before any double quotes. Escape the double quotes. @@ -2330,7 +2332,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = [], if ( wfIsWindows() ) { /* Surrounding a set in quotes (method used by wfEscapeShellArg) makes the quotes themselves * appear in the environment variable, so we must use carat escaping as documented in - * http://technet.microsoft.com/en-us/library/cc723564.aspx + * https://technet.microsoft.com/en-us/library/cc723564.aspx * Note however that the quote isn't listed there, but is needed, and the parentheses * are listed there but doesn't appear to need it. */ @@ -2548,7 +2550,7 @@ function wfShellExecWithStderr( $cmd, &$retval = null, $environ = [], $limits = } /** - * Workaround for http://bugs.php.net/bug.php?id=45132 + * Workaround for https://bugs.php.net/bug.php?id=45132 * escapeshellarg() destroys non-ASCII characters if LANG is not a UTF-8 locale */ function wfInitShellLocale() { @@ -2800,7 +2802,7 @@ function wfUseMW( $req_ver ) { /** * Return the final portion of a pathname. * Reimplemented because PHP5's "basename()" is buggy with multibyte text. - * http://bugs.php.net/bug.php?id=33898 + * https://bugs.php.net/bug.php?id=33898 * * PHP's basename() only considers '\' a pathchar on Windows and Netware. * We'll consider it so always, as we don't want '\s' in our Unix paths either. diff --git a/includes/Html.php b/includes/Html.php index 48b30c7802..0b6b6556ac 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -3,7 +3,7 @@ * Collection of methods to generate HTML content * * Copyright © 2009 Aryeh Gregor - * http://www.mediawiki.org/ + * https://www.mediawiki.org/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -156,10 +156,10 @@ class Html { * @param string $contents The raw HTML contents of the element: *not* * escaped! * @param array $attrs Associative array of attributes, e.g., [ - * 'href' => 'http://www.mediawiki.org/' ]. See expandAttributes() for + * 'href' => 'https://www.mediawiki.org/' ]. See expandAttributes() for * further documentation. * @param string[] $modifiers classes to add to the button - * @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers + * @see https://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers * @return string Raw HTML */ public static function linkButton( $contents, array $attrs, array $modifiers = [] ) { @@ -176,10 +176,10 @@ class Html { * @param string $contents The raw HTML contents of the element: *not* * escaped! * @param array $attrs Associative array of attributes, e.g., [ - * 'href' => 'http://www.mediawiki.org/' ]. See expandAttributes() for + * 'href' => 'https://www.mediawiki.org/' ]. See expandAttributes() for * further documentation. * @param string[] $modifiers classes to add to the button - * @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers + * @see https://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers * @return string Raw HTML */ public static function submitButton( $contents, array $attrs, array $modifiers = [] ) { @@ -200,7 +200,7 @@ class Html { * * @param string $element The element's name, e.g., 'a' * @param array $attribs Associative array of attributes, e.g., [ - * 'href' => 'http://www.mediawiki.org/' ]. See expandAttributes() for + * 'href' => 'https://www.mediawiki.org/' ]. See expandAttributes() for * further documentation. * @param string $contents The raw HTML contents of the element: *not* * escaped! @@ -321,7 +321,7 @@ class Html { * * @param string $element Name of the element, e.g., 'a' * @param array $attribs Associative array of attributes, e.g., [ - * 'href' => 'http://www.mediawiki.org/' ]. See expandAttributes() for + * 'href' => 'https://www.mediawiki.org/' ]. See expandAttributes() for * further documentation. * @return array An array of attributes functionally identical to $attribs */ @@ -431,8 +431,8 @@ class Html { /** * Given an associative array of element attributes, generate a string * to stick after the element name in HTML output. Like [ 'href' => - * 'http://www.mediawiki.org/' ] becomes something like - * ' href="http://www.mediawiki.org"'. Again, this is like + * 'https://www.mediawiki.org/' ] becomes something like + * ' href="https://www.mediawiki.org"'. Again, this is like * Xml::expandAttributes(), but it implements some HTML-specific logic. * * Attributes that can contain space-separated lists ('class', 'accesskey' and 'rel') array @@ -458,7 +458,7 @@ class Html { * @endcode * * @param array $attribs Associative array of attributes, e.g., [ - * 'href' => 'http://www.mediawiki.org/' ]. Values will be HTML-escaped. + * 'href' => 'https://www.mediawiki.org/' ]. Values will be HTML-escaped. * A value of false means to omit the attribute. For boolean attributes, * you can omit the key, e.g., [ 'checked' ] instead of * [ 'checked' => 'checked' ] or such. @@ -501,8 +501,8 @@ class Html { continue; } - // http://www.w3.org/TR/html401/index/attributes.html ("space-separated") - // http://www.w3.org/TR/html5/index.html#attributes-1 ("space-separated") + // https://www.w3.org/TR/html401/index/attributes.html ("space-separated") + // https://www.w3.org/TR/html5/index.html#attributes-1 ("space-separated") $spaceSeparatedListAttributes = [ 'class', // html4, html5 'accesskey', // as of html5, multiple space-separated values allowed @@ -956,7 +956,7 @@ class Html { * @return bool */ public static function isXmlMimeType( $mimetype ) { - # http://www.whatwg.org/html/infrastructure.html#xml-mime-type + # https://html.spec.whatwg.org/multipage/infrastructure.html#xml-mime-type # * text/xml # * application/xml # * Any MIME type with a subtype ending in +xml (this implicitly includes application/xhtml+xml) @@ -1005,7 +1005,7 @@ class Html { * * @note srcset width and height values are not supported. * - * @see http://www.whatwg.org/html/embedded-content-1.html#attr-img-srcset + * @see https://html.spec.whatwg.org/#attr-img-srcset * * @par Example: * @code diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index f21128e59e..eaa1c99539 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -313,8 +313,6 @@ class MediaWiki { * - Normalise empty title: * /wiki/ -> /wiki/Main * /w/index.php?title= -> /wiki/Main - * - Normalise non-standard title urls: - * /w/index.php?title=Foo_Bar -> /wiki/Foo_Bar * - Don't redirect anything with query parameters other than 'title' or 'action=view'. * * @param Title $title @@ -327,6 +325,8 @@ class MediaWiki { if ( $request->getVal( 'action', 'view' ) != 'view' || $request->wasPosted() + || ( $request->getVal( 'title' ) !== null + && $title->getPrefixedDBkey() == $request->getVal( 'title' ) ) || count( $request->getValueNames( [ 'action', 'title' ] ) ) || !Hooks::run( 'TestCanonicalRedirect', [ $request, $title, $output ] ) ) { @@ -341,19 +341,7 @@ class MediaWiki { } // Redirect to canonical url, make it a 301 to allow caching $targetUrl = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); - - if ( $targetUrl != $request->getFullRequestURL() ) { - $output->setCdnMaxage( 1200 ); - $output->redirect( $targetUrl, '301' ); - return true; - } - - // If there is no title, or the title is in a non-standard encoding, we demand - // a redirect. If cgi somehow changed the 'title' query to be non-standard while - // the url is standard, the server is misconfigured. - if ( $request->getVal( 'title' ) === null - || $title->getPrefixedDBkey() != $request->getVal( 'title' ) - ) { + if ( $targetUrl == $request->getFullRequestURL() ) { $message = "Redirect loop detected!\n\n" . "This means the wiki got confused about what page was " . "requested; this sometimes happens when moving a wiki " . @@ -375,7 +363,9 @@ class MediaWiki { } throw new HttpError( 500, $message ); } - return false; + $output->setSquidMaxage( 1200 ); + $output->redirect( $targetUrl, '301' ); + return true; } /** @@ -676,14 +666,14 @@ class MediaWiki { /** * @param string $url * @param IContextSource $context - * @return string|bool Either "local" or "remote" if in the farm, false otherwise + * @return string Either "local", "remote" if in the farm, "external" otherwise */ private static function getUrlDomainDistance( $url, IContextSource $context ) { static $relevantKeys = [ 'host' => true, 'port' => true ]; $infoCandidate = wfParseUrl( $url ); if ( $infoCandidate === false ) { - return false; + return 'external'; } $infoCandidate = array_intersect_key( $infoCandidate, $relevantKeys ); @@ -705,7 +695,7 @@ class MediaWiki { } } - return false; + return 'external'; } /** diff --git a/includes/MediaWikiServices.php b/includes/MediaWikiServices.php index ba8b71b0f1..7c9363ca19 100644 --- a/includes/MediaWikiServices.php +++ b/includes/MediaWikiServices.php @@ -22,6 +22,7 @@ use MediaWiki\Services\NoSuchServiceException; use MWException; use MimeAnalyzer; use ObjectCache; +use Parser; use ProxyLookup; use SearchEngine; use SearchEngineConfig; @@ -191,7 +192,6 @@ class MediaWikiServices extends ServiceContainer { } else { $oldInstance->destroy(); } - } /** @@ -297,7 +297,7 @@ class MediaWikiServices extends ServiceContainer { self::resetGlobalInstance(); // Child, reseed because there is no bug in PHP: - // http://bugs.php.net/bug.php?id=42465 + // https://bugs.php.net/bug.php?id=42465 mt_srand( getmypid() ); } @@ -565,6 +565,14 @@ class MediaWikiServices extends ServiceContainer { return $this->getService( 'ProxyLookup' ); } + /** + * @since 1.29 + * @return Parser + */ + public function getParser() { + return $this->getService( 'Parser' ); + } + /** * @since 1.28 * @return GenderCache diff --git a/includes/MergeHistory.php b/includes/MergeHistory.php index f797fe355c..e57f88099a 100644 --- a/includes/MergeHistory.php +++ b/includes/MergeHistory.php @@ -90,7 +90,8 @@ class MergeHistory { 'revision', 'MAX(rev_timestamp)', [ - 'rev_timestamp <= ' . $this->dbw->timestamp( $mwTimestamp ), + 'rev_timestamp <= ' . + $this->dbw->addQuotes( $this->dbw->timestamp( $mwTimestamp ) ), 'rev_page' => $this->source->getArticleID() ], __METHOD__ @@ -118,7 +119,8 @@ class MergeHistory { $this->timestampLimit = $lasttimestamp; } - $this->timeWhere = "rev_timestamp <= {$this->dbw->timestamp( $timeInsert )}"; + $this->timeWhere = "rev_timestamp <= " . + $this->dbw->addQuotes( $this->dbw->timestamp( $timeInsert ) ); } catch ( TimestampException $ex ) { // The timestamp we got is screwed up and merge cannot continue // This should be detected by $this->isValidMerge() diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 863a426524..50629ba154 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -295,9 +295,6 @@ 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 @@ -1214,8 +1211,8 @@ class OutputPage extends ContextSource { /** * Add new language links * - * @param array $newLinkArray Associative array mapping language code to the page - * name + * @param string[] $newLinkArray Array of interwiki-prefixed (non DB key) titles + * (e.g. 'fr:Test page') */ public function addLanguageLinks( array $newLinkArray ) { $this->mLanguageLinks += $newLinkArray; @@ -1224,8 +1221,8 @@ class OutputPage extends ContextSource { /** * Reset the language links and add new language links * - * @param array $newLinkArray Associative array mapping language code to the page - * name + * @param string[] $newLinkArray Array of interwiki-prefixed (non DB key) titles + * (e.g. 'fr:Test page') */ public function setLanguageLinks( array $newLinkArray ) { $this->mLanguageLinks = $newLinkArray; @@ -1234,7 +1231,7 @@ class OutputPage extends ContextSource { /** * Get the list of language links * - * @return array Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page') + * @return string[] Array of interwiki-prefixed (non DB key) titles (e.g. 'fr:Test page') */ public function getLanguageLinks() { return $this->mLanguageLinks; @@ -1713,7 +1710,6 @@ class OutputPage extends ContextSource { $popts->setTidy( $oldTidy ); $this->addParserOutput( $parserOutput ); - } /** @@ -1776,16 +1772,11 @@ class OutputPage extends ContextSource { } } - // Enable OOUI if requested via ParserOutput + // enable OOUI if requested via ParserOutput if ( $parserOutput->getEnableOOUI() ) { $this->enableOOUI(); } - // Include profiling data - if ( !$this->limitReportData ) { - $this->setLimitReportData( $parserOutput->getLimitReportData() ); - } - // Link flags are ignored for now, but may in the future be // used to mark individual language links. $linkFlags = []; @@ -2198,22 +2189,26 @@ class OutputPage extends ContextSource { # We'll purge the proxy cache explicitly, but require end user agents # to revalidate against the proxy on each visit. # Surrogate-Control controls our CDN, Cache-Control downstream caches - wfDebug( __METHOD__ . ": proxy caching with ESI; {$this->mLastModified} **", 'private' ); + wfDebug( __METHOD__ . + ": proxy caching with ESI; {$this->mLastModified} **", 'private' ); # start with a shorter timeout for initial testing # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"'); - $response->header( 'Surrogate-Control: max-age=' . $config->get( 'SquidMaxage' ) - . '+' . $this->mCdnMaxage . ', content="ESI/1.0"' ); + $response->header( + "Surrogate-Control: max-age={$config->get( 'SquidMaxage' )}" . + "+{$this->mCdnMaxage}, content=\"ESI/1.0\"" + ); $response->header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' ); } else { # We'll purge the proxy cache for anons explicitly, but require end user agents # to revalidate against the proxy on each visit. # IMPORTANT! The CDN needs to replace the Cache-Control header with # Cache-Control: s-maxage=0, must-revalidate, max-age=0 - wfDebug( __METHOD__ . ": local proxy caching; {$this->mLastModified} **", 'private' ); + wfDebug( __METHOD__ . + ": local proxy caching; {$this->mLastModified} **", 'private' ); # start with a shorter timeout for initial testing # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" ); - $response->header( 'Cache-Control: s-maxage=' . $this->mCdnMaxage - . ', must-revalidate, max-age=0' ); + $response->header( "Cache-Control: " . + "s-maxage={$this->mCdnMaxage}, must-revalidate, max-age=0" ); } } else { # We do want clients to cache if they can, but they *must* check for updates @@ -2807,8 +2802,8 @@ class OutputPage extends ContextSource { // The spec recommends defining XHTML5's charset using the XML declaration // instead of meta. // Our XML declaration is output by Html::htmlHeader. - // http://www.whatwg.org/html/semantics.html#attr-meta-http-equiv-content-type - // http://www.whatwg.org/html/semantics.html#charset + // https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-content-type + // https://html.spec.whatwg.org/multipage/semantics.html#charset $pieces[] = Html::element( 'meta', [ 'charset' => 'UTF-8' ] ); } @@ -2963,15 +2958,6 @@ class OutputPage extends ContextSource { } } - if ( $this->limitReportData ) { - $chunks[] = ResourceLoader::makeInlineScript( - ResourceLoader::makeConfigSetScript( - [ 'wgPageParseReport' => $this->limitReportData ], - true - ) - ); - } - return self::combineWrappedStrings( $chunks ); } @@ -3692,7 +3678,7 @@ class OutputPage extends ContextSource { public static function transformCssMedia( $media ) { global $wgRequest; - // http://www.w3.org/TR/css3-mediaqueries/#syntax + // https://www.w3.org/TR/css3-mediaqueries/#syntax $screenMediaQueryRegex = '/^(?:only\s+)?screen\b/i'; // Switch in on-screen display for media testing @@ -3873,12 +3859,4 @@ class OutputPage extends ContextSource { 'mediawiki.widgets.styles', ] ); } - - /** - * @param array $data Data from ParserOutput::getLimitReportData() - * @since 1.28 - */ - public function setLimitReportData( array $data ) { - $this->limitReportData = $data; - } } diff --git a/includes/PHPVersionCheck.php b/includes/PHPVersionCheck.php index 656ba43d4d..e6e96c7ede 100644 --- a/includes/PHPVersionCheck.php +++ b/includes/PHPVersionCheck.php @@ -1,4 +1,7 @@ 'mbstring', 'utf8_encode' => 'xml', 'ctype_digit' => 'ctype', 'json_decode' => 'json', 'iconv' => 'iconv', ); - // List of extensions we're missing - $missingExtensions = array(); - // @codingStandardsIgnoreEnd - foreach ( $extensions as $function => $extension ) { - if ( !function_exists( $function ) ) { - $missingExtensions[] = $extension; + /** + * @var string Which entry point we are protecting. One of: + * - index.php + * - load.php + * - api.php + * - mw-config/index.php + * - cli + */ + var $entryPoint = null; + + /** + * @param string $entryPoint Which entry point we are protecting. One of: + * - index.php + * - load.php + * - api.php + * - mw-config/index.php + * - cli + * @return $this + */ + function setEntryPoint( $entryPoint ) { + $this->entryPoint = $entryPoint; + } + + /** + * Returns the version of the installed php implementation. + * + * @return string + */ + function getPHPImplVersion() { + return PHP_VERSION; + } + + /** + * Displays an error, if the installed php version does not meet the minimum requirement. + * + * @return $this + */ + function checkRequiredPHPVersion() { + if ( !function_exists( 'version_compare' ) + || version_compare( $this->getPHPImplVersion(), $this->minimumVersionPHP ) < 0 + ) { + $shortText = "MediaWiki $this->mwVersion requires at least PHP version" + . " $this->minimumVersionPHP, you are using PHP {$this->getPHPImplVersion()}."; + + $longText = "Error: You might be using on older PHP version. \n" + . "MediaWiki $this->mwVersion needs PHP $this->minimumVersionPHP or higher.\n\n" + . "Check if you have a newer php executable with a different name, " + . "such as php5.\n\n"; + + $longHtml = <<upgrading your copy of PHP. + PHP versions less than 5.5.0 are no longer supported by the PHP Group and will not receive + security or bugfix updates. +

+

+ If for some reason you are unable to upgrade your PHP version, you will need to + download an older version + of MediaWiki from our website. See our + compatibility page + for details of which versions are compatible with prior versions of PHP. +HTML; + $this->triggerError( 'Supported PHP versions', $shortText, $longText, $longHtml ); } } - if ( $missingExtensions ) { - wfMissingExtensions( $entryPoint, $mwVersion, $missingExtensions ); + /** + * Displays an error, if the vendor/autoload.php file could not be found. + * + * @return $this + */ + function checkVendorExistence() { + if ( !file_exists( dirname( __FILE__ ) . '/../vendor/autoload.php' ) ) { + $shortText = "Installing some external dependencies (e.g. via composer) is required."; + + $longText = "Error: You are missing some external dependencies. \n" + . "MediaWiki now also has some external dependencies that need to be installed\n" + . "via composer or from a separate git repo. Please see\n" + . "https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n" + . "for help on installing the required components."; + + $longHtml = <<mediawiki.org + for help on installing the required components. +HTML; + + $this->triggerError( 'External dependencies', $shortText, $longText, $longHtml ); + } } -} -/** - * Display something vaguely comprehensible in the event of a totally unrecoverable error. - * Does not assume access to *anything*; no globals, no autoloader, no database, no localisation. - * Safe for PHP4 (and putting this here means that WebStart.php and GlobalSettings.php - * no longer need to be). - * - * Calling this function kills execution immediately. - * - * @param string $type Which entry point we are protecting. One of: - * - index.php - * - load.php - * - api.php - * - mw-config/index.php - * - cli - * @param string $mwVersion The number of the MediaWiki version used - * @param string $title HTML code to be put within an

tag - * @param string $shortText - * @param string $longText - * @param string $longHtml - */ -function wfGenericError( $type, $mwVersion, $title, $shortText, $longText, $longHtml ) { - $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; + /** + * Displays an error, if a PHP extension does not exist. + * + * @return $this + */ + function checkExtensionExistence() { + $missingExtensions = array(); + foreach ( $this->functionsExtensionsMapping as $function => $extension ) { + if ( !function_exists( $function ) ) { + $missingExtensions[] = $extension; + } + } + + if ( $missingExtensions ) { + $shortText = "Installing some PHP extensions is required."; + + $missingExtText = ''; + $missingExtHtml = ''; + $baseUrl = 'https://secure.php.net'; + foreach ( $missingExtensions as $ext ) { + $missingExtText .= " * $ext <$baseUrl/$ext>\n"; + $missingExtHtml .= "
  • $ext " + . "(more information)
  • "; + } + + $cliText = "Error: Missing one or more required components of PHP.\n" + . "You are missing a required extension to PHP that MediaWiki needs.\n" + . "Please install:\n" . $missingExtText; + + $longHtml = << + $missingExtHtml + +HTML; + + $this->triggerError( 'Required components', $shortText, $cliText, $longHtml ); + } + } + + /** + * Output headers that prevents error pages to be cached. + */ + function outputHTMLHeader() { + $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; - if ( $type == 'cli' ) { - $finalOutput = $longText; - } else { header( "$protocol 500 MediaWiki configuration Error" ); // Don't cache error pages! They cause no end of trouble... header( 'Cache-control: none' ); header( 'Pragma: no-cache' ); + } - if ( $type == 'index.php' || $type == 'mw-config/index.php' ) { - $pathinfo = pathinfo( $_SERVER['SCRIPT_NAME'] ); - if ( $type == 'mw-config/index.php' ) { - $dirname = dirname( $pathinfo['dirname'] ); - } else { - $dirname = $pathinfo['dirname']; - } - $encLogo = htmlspecialchars( - str_replace( '//', '/', $dirname . '/' ) . - 'resources/assets/mediawiki.png' - ); - $shortHtml = htmlspecialchars( $shortText ); + /** + * Returns an error page, which is suitable for output to the end user via a web browser. + * + * @param $title + * @param $longHtml + * @param $shortText + * @return string + */ + function getIndexErrorOutput( $title, $longHtml, $shortText ) { + $pathinfo = pathinfo( $_SERVER['SCRIPT_NAME'] ); + if ( $this->entryPoint == 'mw-config/index.php' ) { + $dirname = dirname( $pathinfo['dirname'] ); + } else { + $dirname = $pathinfo['dirname']; + } + $encLogo = + htmlspecialchars( str_replace( '//', '/', $dirname . '/' ) . + 'resources/assets/mediawiki.png' ); + $shortHtml = htmlspecialchars( $shortText ); - header( 'Content-type: text/html; charset=UTF-8' ); + header( 'Content-type: text/html; charset=UTF-8' ); - $finalOutput = << - MediaWiki {$mwVersion} + MediaWiki {$this->mwVersion}