# Die if register_globals is enabled (PHP <=5.3)
# This must be done before any globals are set by the code
if ( ini_get( 'register_globals' ) ) {
- die( 'MediaWiki does not support installations where register_globals is enabled. '
- . 'Please see <a href="https://www.mediawiki.org/wiki/register_globals">mediawiki.org</a> '
+ die( 'MediaWiki does not support installations where register_globals is enabled. Please see '
+ . '<a href="https://www.mediawiki.org/wiki/register_globals">mediawiki.org</a> '
. 'for help on how to disable it.' );
}
if ( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ) {
- die( 'MediaWiki does not function when magic quotes are enabled. '
- . 'Please see the <a href="https://php.net/manual/security.magicquotes.disabling.php">PHP Manual</a> '
+ die( 'MediaWiki does not function when magic quotes are enabled. Please see the '
+ . '<a href="https://php.net/manual/security.magicquotes.disabling.php">PHP Manual</a> '
. 'for help on how to disable magic quotes.' );
}
require_once "$IP/vendor/autoload.php";
}
+# Assert that composer dependencies were successfully loaded
+# Purposely no leading \ due to it breaking HHVM RepoAuthorative mode
+# PHP works fine with both versions
+# See https://github.com/facebook/hhvm/issues/5833
+if ( !interface_exists( 'Psr\Log\LoggerInterface' ) ) {
+ $message = (
+ 'MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging ' .
+ "library</a> to be present. This library is not embedded directly in MediaWiki's " .
+ "git repository and must be installed separately by the end user.\n\n" .
+ 'Please see <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
+ '#Fetch_external_libraries">mediawiki.org</a> for help on installing ' .
+ 'the required components.'
+ );
+ echo $message;
+ trigger_error( $message, E_USER_ERROR );
+ die( 1 );
+}
+
if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
# Use a callback function to configure MediaWiki
call_user_func( MW_CONFIG_CALLBACK );
if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] === 'POST' ) {
ignore_user_abort( true );
}
+
+if ( !defined( 'MW_API' ) &&
+ RequestContext::getMain()->getRequest()->getHeader( 'Promise-Non-Write-API-Action' )
+) {
+ header( 'Cache-Control: no-cache' );
+ header( 'Content-Type: text/html; charset=utf-8' );
+ HttpStatus::header( 400 );
+ $error = wfMessage( 'nonwrite-api-promise-error' )->escaped();
+ $content = <<<EOT
+<!DOCTYPE html>
+<html>
+<head><meta charset="UTF-8" /></head>
+<body>
+$error
+</body>
+</html>
+
+EOT;
+ header( 'Content-Length: ' . strlen( $content ) );
+ echo $content;
+ die();
+}