$wgLocalTZoffset = date( 'Z' ) / 60;
}
-# Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
-$wgRequest = new WebRequest;
-
# Useful debug output
global $wgCommandLineMode;
if ( $wgCommandLineMode ) {
+ $wgRequest = new FauxRequest( array() );
+
wfDebug( "\n\nStart command line script $self\n" );
} else {
+ # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
+ $wgRequest = new WebRequest;
+
$debug = "Start request\n\n{$_SERVER['REQUEST_METHOD']} {$wgRequest->getRequestURL()}";
if ( $wgDebugPrintHttpHeaders ) {
class FauxResponse extends WebResponse {
private $headers;
private $cookies;
+ private $code;
/**
* Stores a HTTP header
* @param $http_response_code null|int Forces the HTTP response code to the specified value.
*/
public function header( $string, $replace = true, $http_response_code = null ) {
- list( $key, $val ) = explode( ":", $string, 2 );
+ $match = array();
+ if ( preg_match( '~^HTTP/1.\d (\d+)\D*$~', $string, $match ) ) {
+ $this->code = intval( $match[1] );
+ } else {
+ list( $key, $val ) = explode( ":", $string, 2 );
- if( $replace || !isset( $this->headers[$key] ) ) {
- $this->headers[$key] = $val;
+ if( $replace || !isset( $this->headers[$key] ) ) {
+ $this->headers[$key] = $val;
+ }
+ }
+
+ if ( $http_response_code !== null ) {
+ $this->code = intval( $http_response_code );
}
}
return $this->headers[$key];
}
+ /**
+ * Get the HTTP response code, null if not set
+ *
+ * @return Int or null
+ */
+ public function getStatusCode() {
+ return $this->code;
+ }
+
/**
* @param $name String: name of cookie
* @param $value String: value to give cookie