*/
private $ip;
+ /**
+ * The timestamp of the start of the request, with microsecond precision.
+ * @var float
+ */
+ protected $requestTime;
+
/**
* Cached URL protocol
* @var string
protected $protocol;
public function __construct() {
- if ( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ) {
- throw new MWException( "MediaWiki does not function when magic quotes are enabled." );
- }
+ $this->requestTime = isset( $_SERVER['REQUEST_TIME_FLOAT'] )
+ ? $_SERVER['REQUEST_TIME_FLOAT'] : microtime( true );
// POST overrides GET data
// We don't use $_REQUEST here to avoid interference from cookies...
* @return array
*/
public static function detectProtocol() {
- if ( ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) ||
+ if ( ( !empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] !== 'off' ) ||
( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) &&
- $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) ) {
+ $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) ) {
return 'https';
} else {
return 'http';
}
}
+ /**
+ * Get the number of seconds to have elapsed since request start,
+ * in fractional seconds, with microsecond resolution.
+ *
+ * @return float
+ * @since 1.25
+ */
+ public function getElapsedTime() {
+ return microtime( true ) - $this->requestTime;
+ }
+
/**
* Get the current URL protocol (http or https)
* @return string
}
} else {
global $wgContLang;
- $data = isset( $wgContLang ) ? $wgContLang->normalize( $data ) : UtfNormal::cleanUp( $data );
+ $data = isset( $wgContLang ) ? $wgContLang->normalize( $data ) : UtfNormal\Validator::cleanUp( $data );
}
return $data;
}
public function __construct( $data = array(), $wasPosted = false,
$session = null, $protocol = 'http'
) {
+ $this->requestTime = microtime( true );
+
if ( is_array( $data ) ) {
$this->data = $data;
} else {
public function getProtocol() {
return $this->base->getProtocol();
}
+
+ public function getElapsedTime() {
+ return $this->base->getElapsedTime();
+ }
}