2015-04-18 09:37:10 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 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
|
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
|
*
|
|
|
|
|
|
* @file
|
|
|
|
|
|
*/
|
2016-09-13 16:17:11 +00:00
|
|
|
|
|
2018-04-08 19:39:46 +00:00
|
|
|
|
// phpcs:disable Generic.Arrays.DisallowLongArraySyntax,PSR2.Classes.PropertyDeclaration,MediaWiki.Usage.DirUsage
|
2018-08-07 10:39:46 +00:00
|
|
|
|
// phpcs:disable Squiz.Scope.MemberVarScope.Missing,Squiz.Scope.MethodScope.Missing
|
2016-09-13 16:17:11 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Check PHP Version, as well as for composer dependencies in entry points,
|
|
|
|
|
|
* and display something vaguely comprehensible in the event of a totally
|
|
|
|
|
|
* unrecoverable error.
|
2018-10-28 21:12:54 +00:00
|
|
|
|
*
|
|
|
|
|
|
* @note Since we can't rely on anything external, the minimum PHP versions
|
|
|
|
|
|
* and MW current version are hardcoded in this class.
|
|
|
|
|
|
*
|
|
|
|
|
|
* @note This class uses setter methods instead of a constructor so that
|
2022-10-03 12:05:50 +00:00
|
|
|
|
* it can be compatible with PHP 4 through PHP 8 (without warnings).
|
2016-09-13 16:17:11 +00:00
|
|
|
|
*/
|
2016-09-13 15:45:36 +00:00
|
|
|
|
class PHPVersionCheck {
|
2021-01-29 18:11:58 +00:00
|
|
|
|
/** @var string The number of the MediaWiki version used. If you're updating MW_VERSION in Defines.php, you must also update this value. */
|
2023-03-14 02:33:40 +00:00
|
|
|
|
var $mwVersion = '1.41';
|
2018-10-18 17:50:48 +00:00
|
|
|
|
|
2020-07-23 09:41:58 +00:00
|
|
|
|
/** @var string[] A mapping of PHP functions to PHP extensions. */
|
2016-09-13 15:45:36 +00:00
|
|
|
|
var $functionsExtensionsMapping = array(
|
2016-06-14 00:52:51 +00:00
|
|
|
|
'mb_substr' => 'mbstring',
|
2018-04-14 22:31:00 +00:00
|
|
|
|
'xml_parser_create' => 'xml',
|
2016-06-14 00:52:51 +00:00
|
|
|
|
'ctype_digit' => 'ctype',
|
|
|
|
|
|
'json_decode' => 'json',
|
|
|
|
|
|
'iconv' => 'iconv',
|
2017-08-09 18:54:01 +00:00
|
|
|
|
'mime_content_type' => 'fileinfo',
|
2021-03-20 10:06:59 +00:00
|
|
|
|
'intl_is_failure' => 'intl',
|
2016-06-14 00:52:51 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
2016-09-13 15:45:36 +00:00
|
|
|
|
/**
|
2020-04-07 21:38:17 +00:00
|
|
|
|
* @var string The format used for errors. One of "text" or "html"
|
2018-10-28 21:12:54 +00:00
|
|
|
|
*/
|
|
|
|
|
|
var $format = 'text';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-10-28 19:44:09 +00:00
|
|
|
|
* @var string
|
2016-09-13 15:45:36 +00:00
|
|
|
|
*/
|
2018-10-28 21:12:54 +00:00
|
|
|
|
var $scriptPath = '/';
|
2016-09-13 15:45:36 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
2018-10-28 21:12:54 +00:00
|
|
|
|
* Set the format used for errors.
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param string $format One of "text" or "html"
|
2016-09-13 15:45:36 +00:00
|
|
|
|
*/
|
2018-10-28 21:12:54 +00:00
|
|
|
|
function setFormat( $format ) {
|
|
|
|
|
|
$this->format = $format;
|
2016-09-13 15:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-10-28 21:12:54 +00:00
|
|
|
|
* Set the script path used for images in HTML-formatted errors.
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param string $scriptPath
|
|
|
|
|
|
*/
|
|
|
|
|
|
function setScriptPath( $scriptPath ) {
|
|
|
|
|
|
$this->scriptPath = $scriptPath;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-09-13 15:45:36 +00:00
|
|
|
|
/**
|
2018-10-18 17:50:48 +00:00
|
|
|
|
* Displays an error, if the installed PHP version does not meet the minimum requirement.
|
2016-09-13 15:45:36 +00:00
|
|
|
|
*/
|
|
|
|
|
|
function checkRequiredPHPVersion() {
|
2020-08-11 11:06:46 +00:00
|
|
|
|
$minimumVersion = '7.4.3';
|
2018-05-24 18:18:02 +00:00
|
|
|
|
|
2021-01-29 18:11:58 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* This is a list of known-bad ranges of PHP versions. Syntax is like SemVer – either:
|
|
|
|
|
|
*
|
|
|
|
|
|
* - '1.2.3' to prohibit a single version of PHP, or
|
|
|
|
|
|
* - '1.2.3 – 1.2.5' to block a range, inclusive.
|
|
|
|
|
|
*
|
|
|
|
|
|
* Whitespace will be ignored.
|
|
|
|
|
|
*
|
|
|
|
|
|
* The key is not shown to users; use it to prompt future developers as to why this was
|
|
|
|
|
|
* chosen, ideally one or more Phabricator task references.
|
|
|
|
|
|
*
|
|
|
|
|
|
* Remember to drop irrelevant ranges when bumping $minimumVersion.
|
|
|
|
|
|
*/
|
|
|
|
|
|
$knownBad = array(
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$passes = version_compare( PHP_VERSION, $minimumVersion, '>=' );
|
|
|
|
|
|
|
|
|
|
|
|
$versionString = "PHP $minimumVersion or higher";
|
|
|
|
|
|
|
|
|
|
|
|
// Left as a programmatic check to make it easier to update.
|
|
|
|
|
|
if ( count( $knownBad ) ) {
|
|
|
|
|
|
$versionString .= ' (and not ' . implode( ', ', array_values( $knownBad ) ) . ')';
|
|
|
|
|
|
|
|
|
|
|
|
foreach ( $knownBad as $task => $range ) {
|
|
|
|
|
|
// As we don't have composer at this point, we have to do our own version range checking.
|
|
|
|
|
|
if ( strpos( $range, '-' ) ) {
|
|
|
|
|
|
$passes = $passes && !(
|
|
|
|
|
|
version_compare( PHP_VERSION, trim( strstr( $range, '-', true ) ), '>=' )
|
|
|
|
|
|
&& version_compare( PHP_VERSION, trim( substr( strstr( $range, '-', false ), 1 ) ), '<' )
|
|
|
|
|
|
);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$passes = $passes && version_compare( PHP_VERSION, trim( $range ), '<>' );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( !$passes ) {
|
|
|
|
|
|
$cliText = "Error: You are using an unsupported PHP version (PHP " . PHP_VERSION . ").\n"
|
|
|
|
|
|
. "MediaWiki $this->mwVersion needs $versionString.\n\nCheck if you might have a newer "
|
|
|
|
|
|
. "PHP executable with a different name.\n\n";
|
2016-09-13 15:45:36 +00:00
|
|
|
|
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
$web = array();
|
2021-01-29 18:11:58 +00:00
|
|
|
|
$web['intro'] = "MediaWiki $this->mwVersion requires $versionString; you are using PHP "
|
|
|
|
|
|
. PHP_VERSION . ".";
|
2016-09-13 15:45:36 +00:00
|
|
|
|
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
$web['longTitle'] = "Supported PHP versions";
|
2018-04-08 19:39:46 +00:00
|
|
|
|
// phpcs:disable Generic.Files.LineLength
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
$web['longHtml'] = <<<HTML
|
|
|
|
|
|
<p>
|
2018-05-24 18:18:02 +00:00
|
|
|
|
Please consider <a href="https://www.php.net/downloads.php">upgrading your copy of PHP</a>.
|
2021-01-30 00:18:01 +00:00
|
|
|
|
PHP versions less than v7.3.0 are no longer supported by the PHP Group and will not receive
|
2016-09-13 15:45:36 +00:00
|
|
|
|
security or bugfix updates.
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<p>
|
2018-05-24 18:18:02 +00:00
|
|
|
|
If for some reason you are unable to upgrade your PHP version, you will need to
|
|
|
|
|
|
<a href="https://www.mediawiki.org/wiki/Download">download</a> an older version of
|
|
|
|
|
|
MediaWiki from our website. See our
|
|
|
|
|
|
<a href="https://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a>
|
|
|
|
|
|
for details of which versions are compatible with prior versions of PHP.
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
</p>
|
2016-09-13 15:45:36 +00:00
|
|
|
|
HTML;
|
2018-04-08 19:39:46 +00:00
|
|
|
|
// phpcs:enable Generic.Files.LineLength
|
2016-09-13 16:17:11 +00:00
|
|
|
|
$this->triggerError(
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
$web,
|
|
|
|
|
|
$cliText
|
2016-09-13 16:17:11 +00:00
|
|
|
|
);
|
2016-06-14 00:52:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-09-13 15:45:36 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Displays an error, if the vendor/autoload.php file could not be found.
|
|
|
|
|
|
*/
|
|
|
|
|
|
function checkVendorExistence() {
|
|
|
|
|
|
if ( !file_exists( dirname( __FILE__ ) . '/../vendor/autoload.php' ) ) {
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
$cliText = "Error: You are missing some external dependencies. \n"
|
2023-05-20 20:19:53 +00:00
|
|
|
|
. "MediaWiki has external dependencies that need to be installed via Composer\n"
|
2023-05-21 10:00:41 +00:00
|
|
|
|
. "or from a separate repository. Please see\n"
|
|
|
|
|
|
. "https://www.mediawiki.org/wiki/Manual:Installation_requirements#PHP and\n"
|
2017-02-25 21:53:36 +00:00
|
|
|
|
. "https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n"
|
|
|
|
|
|
. "for help on installing the required components.";
|
2016-09-13 15:45:36 +00:00
|
|
|
|
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
$web = array();
|
|
|
|
|
|
$web['intro'] = "Installing some external dependencies (e.g. via composer) is required.";
|
|
|
|
|
|
$web['longTitle'] = 'External dependencies';
|
2018-04-08 19:39:46 +00:00
|
|
|
|
// phpcs:disable Generic.Files.LineLength
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
$web['longHtml'] = <<<HTML
|
|
|
|
|
|
<p>
|
2023-05-20 20:19:53 +00:00
|
|
|
|
MediaWiki has external dependencies that need to be installed via Composer
|
2023-05-21 10:00:41 +00:00
|
|
|
|
or from a separate repository. Please see the
|
|
|
|
|
|
<a href="https://www.mediawiki.org/wiki/Manual:Installation_requirements#PHP">PHP
|
|
|
|
|
|
installation requirements</a> and the
|
2021-11-14 07:05:27 +00:00
|
|
|
|
<a href="https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries">instructions
|
2023-05-21 10:00:41 +00:00
|
|
|
|
for installing PHP libraries</a> on mediawiki.org for help on installing the required components.
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
</p>
|
2016-09-13 15:45:36 +00:00
|
|
|
|
HTML;
|
2018-04-08 19:39:46 +00:00
|
|
|
|
// phpcs:enable Generic.Files.LineLength
|
2016-09-13 15:45:36 +00:00
|
|
|
|
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
$this->triggerError( $web, $cliText );
|
2016-09-13 15:45:36 +00:00
|
|
|
|
}
|
2016-06-14 00:52:51 +00:00
|
|
|
|
}
|
2015-04-18 09:37:10 +00:00
|
|
|
|
|
2016-09-13 15:45:36 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Displays an error, if a PHP extension does not exist.
|
|
|
|
|
|
*/
|
|
|
|
|
|
function checkExtensionExistence() {
|
|
|
|
|
|
$missingExtensions = array();
|
|
|
|
|
|
foreach ( $this->functionsExtensionsMapping as $function => $extension ) {
|
|
|
|
|
|
if ( !function_exists( $function ) ) {
|
|
|
|
|
|
$missingExtensions[] = $extension;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( $missingExtensions ) {
|
|
|
|
|
|
$missingExtText = '';
|
|
|
|
|
|
$missingExtHtml = '';
|
2019-04-12 04:41:14 +00:00
|
|
|
|
$baseUrl = 'https://www.php.net';
|
2016-09-13 15:45:36 +00:00
|
|
|
|
foreach ( $missingExtensions as $ext ) {
|
|
|
|
|
|
$missingExtText .= " * $ext <$baseUrl/$ext>\n";
|
|
|
|
|
|
$missingExtHtml .= "<li><b>$ext</b> "
|
2017-02-25 21:53:36 +00:00
|
|
|
|
. "(<a href=\"$baseUrl/$ext\">more information</a>)</li>";
|
2016-09-13 15:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$cliText = "Error: Missing one or more required components of PHP.\n"
|
2017-02-25 21:53:36 +00:00
|
|
|
|
. "You are missing a required extension to PHP that MediaWiki needs.\n"
|
|
|
|
|
|
. "Please install:\n" . $missingExtText;
|
2016-09-13 15:45:36 +00:00
|
|
|
|
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
$web = array();
|
|
|
|
|
|
$web['intro'] = "Installing some PHP extensions is required.";
|
|
|
|
|
|
$web['longTitle'] = 'Required components';
|
|
|
|
|
|
$web['longHtml'] = <<<HTML
|
|
|
|
|
|
<p>
|
2016-09-13 15:45:36 +00:00
|
|
|
|
You are missing a required extension to PHP that MediaWiki
|
|
|
|
|
|
requires to run. Please install:
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
</p>
|
2016-09-13 15:45:36 +00:00
|
|
|
|
<ul>
|
|
|
|
|
|
$missingExtHtml
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
HTML;
|
|
|
|
|
|
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
$this->triggerError( $web, $cliText );
|
2016-09-13 15:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Output headers that prevents error pages to be cached.
|
|
|
|
|
|
*/
|
|
|
|
|
|
function outputHTMLHeader() {
|
2021-06-07 15:24:11 +00:00
|
|
|
|
$protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
|
2015-04-18 09:37:10 +00:00
|
|
|
|
|
|
|
|
|
|
header( "$protocol 500 MediaWiki configuration Error" );
|
2021-01-29 18:11:58 +00:00
|
|
|
|
// Don't cache error pages! They cause no end of trouble...
|
2015-04-18 09:37:10 +00:00
|
|
|
|
header( 'Cache-control: none' );
|
|
|
|
|
|
header( 'Pragma: no-cache' );
|
2016-09-13 15:45:36 +00:00
|
|
|
|
}
|
2015-04-18 09:37:10 +00:00
|
|
|
|
|
2016-09-13 15:45:36 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Returns an error page, which is suitable for output to the end user via a web browser.
|
|
|
|
|
|
*
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
* @param string $introText
|
|
|
|
|
|
* @param string $longTitle
|
2017-08-11 15:46:31 +00:00
|
|
|
|
* @param string $longHtml
|
2016-09-13 15:45:36 +00:00
|
|
|
|
* @return string
|
|
|
|
|
|
*/
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
function getIndexErrorOutput( $introText, $longTitle, $longHtml ) {
|
2016-09-13 15:45:36 +00:00
|
|
|
|
$encLogo =
|
2018-10-28 21:12:54 +00:00
|
|
|
|
htmlspecialchars( str_replace( '//', '/', $this->scriptPath . '/' ) .
|
2017-02-25 21:53:36 +00:00
|
|
|
|
'resources/assets/mediawiki.png' );
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
|
|
|
|
|
|
$introHtml = htmlspecialchars( $introText );
|
|
|
|
|
|
$longTitleHtml = htmlspecialchars( $longTitle );
|
2015-07-05 12:42:28 +00:00
|
|
|
|
|
2016-09-13 15:45:36 +00:00
|
|
|
|
header( 'Content-type: text/html; charset=UTF-8' );
|
2015-07-05 12:42:28 +00:00
|
|
|
|
|
2016-09-13 15:45:36 +00:00
|
|
|
|
$finalOutput = <<<HTML
|
2015-04-18 09:37:10 +00:00
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
|
<html lang="en" dir="ltr">
|
|
|
|
|
|
<head>
|
|
|
|
|
|
<meta charset="UTF-8" />
|
2016-09-13 15:45:36 +00:00
|
|
|
|
<title>MediaWiki {$this->mwVersion}</title>
|
2019-09-22 10:19:59 +00:00
|
|
|
|
<style media="screen">
|
2015-04-18 09:37:10 +00:00
|
|
|
|
body {
|
|
|
|
|
|
color: #000;
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
font-family: sans-serif;
|
|
|
|
|
|
padding: 2em;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
}
|
2019-09-22 10:19:59 +00:00
|
|
|
|
p, img, h1, h2, ul {
|
2015-04-18 09:37:10 +00:00
|
|
|
|
text-align: left;
|
|
|
|
|
|
margin: 0.5em 0 1em;
|
|
|
|
|
|
}
|
|
|
|
|
|
h1 {
|
|
|
|
|
|
font-size: 120%;
|
|
|
|
|
|
}
|
|
|
|
|
|
h2 {
|
|
|
|
|
|
font-size: 110%;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|
|
|
|
|
|
</head>
|
|
|
|
|
|
<body>
|
2019-09-22 10:19:59 +00:00
|
|
|
|
<img src="{$encLogo}" alt="The MediaWiki logo" />
|
2016-09-13 15:45:36 +00:00
|
|
|
|
<h1>MediaWiki {$this->mwVersion} internal error</h1>
|
2015-04-18 09:37:10 +00:00
|
|
|
|
<p>
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
{$introHtml}
|
2015-04-18 09:37:10 +00:00
|
|
|
|
</p>
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
<h2>{$longTitleHtml}</h2>
|
|
|
|
|
|
{$longHtml}
|
2015-07-05 12:42:28 +00:00
|
|
|
|
</body>
|
|
|
|
|
|
</html>
|
|
|
|
|
|
HTML;
|
|
|
|
|
|
|
2016-09-13 15:45:36 +00:00
|
|
|
|
return $finalOutput;
|
|
|
|
|
|
}
|
2015-07-05 12:42:28 +00:00
|
|
|
|
|
2016-09-13 15:45:36 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 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).
|
|
|
|
|
|
*
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
* This function immediately terminates the PHP process.
|
2016-09-13 15:45:36 +00:00
|
|
|
|
*
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
* @param string[] $web
|
|
|
|
|
|
* - (string) intro: Short error message, displayed on top.
|
|
|
|
|
|
* - (string) longTitle: Title for the longer message.
|
|
|
|
|
|
* - (string) longHtml: The longer message, as raw HTML.
|
|
|
|
|
|
* @param string $cliText
|
2016-09-13 15:45:36 +00:00
|
|
|
|
*/
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
function triggerError( $web, $cliText ) {
|
2018-10-28 21:12:54 +00:00
|
|
|
|
if ( $this->format === 'html' ) {
|
|
|
|
|
|
// Used by index.php and mw-config/index.php
|
|
|
|
|
|
$this->outputHTMLHeader();
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
$finalOutput = $this->getIndexErrorOutput(
|
|
|
|
|
|
$web['intro'],
|
|
|
|
|
|
$web['longTitle'],
|
|
|
|
|
|
$web['longHtml']
|
|
|
|
|
|
);
|
2018-10-28 21:12:54 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
// Used by Maintenance.php (CLI)
|
PHPVersionCheck: Refactor triggerError() to be easier to understand
* Rename $longText to $cliText.
On the web we show a short intro and then a longer message after it.
On the CLI, a single value controls the full output, which used to
be $longText. This is now called $cliText to better reflect that it is
(only) used on the CLI, and to no longer imply that the short text is
also used there, because it isn't.
* Remove <p>-wrapping for $longHtml.
This is now moved to the callers instead. The long message exists for the
purpose of outputting multiple paragraphs and/or other elements (such as
lists or tables). Wrapping this in a <p> created a awkward situation
where the caller would have to close the implicit <p>, and then re-open
it at the end without closing as a way to output two paragraphs.
* Make $title be text instead of raw HTML.
This never made use of actual HTML, and it wasn't marked as such.
It should probably have been called $titleHtml for clarity.
To avoid having to think about this, treat it as text and escape it.
* Combine all web-facing parameters into one array, and declare their
keys in the same order as the output.
Previously, the order of was:
"$title, $shortText (, $longText), $longHtml"
Which suggested that the title is output first, followed by the short
and long messages. In actuality, the $shortText was output first, followed
by $title, and then the $longHtml. The $title parameter was not actually
an overall title. Rather, it was just the title for $longHtml.
The overall title is "Internal error" and not controlled by the caller.
New keys match the presentation order:
'intro', 'longTitle', and 'longHtml'.
* Remove unused "<div class=error>" element.
This had no styling of any kind. Renders identically without it.
Test Plan:
- For each of checkRequiredPHPVersion(), checkVendorExistence() and
checkExtensionExistence(), one at a time, change their main 'if' condition
to be 'if ( true )' and observe that the output renders correctly.
Change-Id: If4331a37c9b62c0061dcec0a1432de320f4c4103
2020-03-02 01:31:21 +00:00
|
|
|
|
$finalOutput = $cliText;
|
2016-09-13 15:45:36 +00:00
|
|
|
|
}
|
2015-07-05 12:42:28 +00:00
|
|
|
|
|
2016-09-13 15:45:36 +00:00
|
|
|
|
echo "$finalOutput\n";
|
|
|
|
|
|
die( 1 );
|
|
|
|
|
|
}
|
2015-04-18 09:37:10 +00:00
|
|
|
|
}
|
2016-06-14 00:52:51 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
2018-10-18 17:50:48 +00:00
|
|
|
|
* Check PHP version and that external dependencies are installed, and
|
2016-09-13 15:45:36 +00:00
|
|
|
|
* display an informative error if either condition is not satisfied.
|
2016-06-14 00:52:51 +00:00
|
|
|
|
*
|
2018-10-28 21:12:54 +00:00
|
|
|
|
* @param string $format One of "text" or "html"
|
|
|
|
|
|
* @param string $scriptPath Used when an error is formatted as HTML.
|
2016-06-14 00:52:51 +00:00
|
|
|
|
*/
|
2018-10-28 21:12:54 +00:00
|
|
|
|
function wfEntryPointCheck( $format = 'text', $scriptPath = '/' ) {
|
2016-09-13 15:45:36 +00:00
|
|
|
|
$phpVersionCheck = new PHPVersionCheck();
|
2018-10-28 21:12:54 +00:00
|
|
|
|
$phpVersionCheck->setFormat( $format );
|
|
|
|
|
|
$phpVersionCheck->setScriptPath( $scriptPath );
|
2016-09-13 15:45:36 +00:00
|
|
|
|
$phpVersionCheck->checkRequiredPHPVersion();
|
|
|
|
|
|
$phpVersionCheck->checkVendorExistence();
|
|
|
|
|
|
$phpVersionCheck->checkExtensionExistence();
|
2016-06-14 00:52:51 +00:00
|
|
|
|
}
|