aboutsummaryrefslogtreecommitdiffstats
path: root/includes/WebStart.php
diff options
context:
space:
mode:
authorOri Livneh <ori@wikimedia.org>2015-04-01 16:16:09 -0700
committerOri Livneh <ori@wikimedia.org>2015-04-01 18:21:26 -0700
commit667fa3e264c6d3c68c5fcf1072d92ad1e6b62d46 (patch)
treec66892e00412fa57aebc5a35698ec7a600beda45 /includes/WebStart.php
parente36a953cc258be1ac909c07065be86ec7b7c68e3 (diff)
downloadmediawikicore-667fa3e264c6d3c68c5fcf1072d92ad1e6b62d46.tar.gz
mediawikicore-667fa3e264c6d3c68c5fcf1072d92ad1e6b62d46.zip
Make WebRequest objects time-aware
* Deprecate $wgRequestTime in favor of $_SERVER['REQUEST_TIME_FLOAT'], which is more accurate. Because $_SERVER['REQUEST_TIME_FLOAT'] is only set for PHP 5.4+, set it to microtime( true ) in WebStart.php for back-compatibility. * Add a 'requestTime' property to WebRequest objects, set to $_SERVER['REQUEST_TIME_FLOAT'] for WebRequest or the instance creation time for FauxRequest instances. * Use that to provide WebRequest::getElapsedTime(), which gets the time since the request was initiated. * In wfLogProfilingData(), get the user and request objects from the context object rather than from global scope. Opportunistic clean-up: move the magic quotes check to WebStart.php and make the error message more helpful. Change-Id: I7e07e22eaf16b5141b80ad9f843285c542a127b7
Diffstat (limited to 'includes/WebStart.php')
-rw-r--r--includes/WebStart.php20
1 files changed, 19 insertions, 1 deletions
diff --git a/includes/WebStart.php b/includes/WebStart.php
index da4bc8792059..9c71f3e1cbce 100644
--- a/includes/WebStart.php
+++ b/includes/WebStart.php
@@ -34,12 +34,30 @@ if ( ini_get( 'register_globals' ) ) {
. '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> '
+ . 'for help on how to disable magic quotes.' );
+}
+
+
# bug 15461: Make IE8 turn off content sniffing. Everybody else should ignore this
# We're adding it here so that it's *always* set, even for alternate entry
# points and when $wgOut gets disabled or overridden.
header( 'X-Content-Type-Options: nosniff' );
-$wgRequestTime = microtime( true );
+# Approximate $_SERVER['REQUEST_TIME_FLOAT'] for PHP<5.4
+if ( !isset( $_SERVER['REQUEST_TIME_FLOAT'] ) ) {
+ $_SERVER['REQUEST_TIME_FLOAT'] = microtime( true );
+}
+
+/**
+ * @var float Request start time as fractional seconds since epoch
+ * @deprecated since 1.25; use $_SERVER['REQUEST_TIME_FLOAT'] or
+ * WebRequest::getElapsedTime() instead.
+ */
+$wgRequestTime = $_SERVER['REQUEST_TIME_FLOAT'];
+
unset( $IP );
# Valid web server entry point, enable includes.