mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Fixed superglobal masquerading in Director::test()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60393 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
eb9e66808c
commit
3b1a6293a2
@ -153,12 +153,30 @@ class Director {
|
|||||||
list($url, $getVarsEncoded) = explode('?', $url, 2);
|
list($url, $getVarsEncoded) = explode('?', $url, 2);
|
||||||
parse_str($getVarsEncoded, $getVars);
|
parse_str($getVarsEncoded, $getVars);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$session) $session = new Session(null);
|
if(!$session) $session = new Session(null);
|
||||||
|
|
||||||
|
// Back up the current values of the superglobals
|
||||||
|
$existingRequestVars = $_REQUEST;
|
||||||
|
$existingGetVars = $_GET;
|
||||||
|
$existingPostVars = $_POST;
|
||||||
|
$existingSessionVars = $_SESSION;
|
||||||
|
|
||||||
|
// Replace the superglobals with appropriate test values
|
||||||
|
$_REQUEST = array_merge((array)$getVars, (array)$post);
|
||||||
|
$_GET = (array)$getVars;
|
||||||
|
$_POST = (array)$post;
|
||||||
|
$_SESSION = $session ? $session->inst_getAll() : array();
|
||||||
|
|
||||||
$req = new HTTPRequest($httpMethod, $url, $getVars, $postVars, $body);
|
$req = new HTTPRequest($httpMethod, $url, $getVars, $postVars, $body);
|
||||||
if($headers) foreach($headers as $k => $v) $req->addHeader($k, $v);
|
if($headers) foreach($headers as $k => $v) $req->addHeader($k, $v);
|
||||||
$result = Director::handleRequest($req, $session);
|
$result = Director::handleRequest($req, $session);
|
||||||
|
|
||||||
|
// Restore the superglobals
|
||||||
|
$_REQUEST = $existingRequestVars;
|
||||||
|
$_GET = $existingGetVars;
|
||||||
|
$_POST = $existingPostVars;
|
||||||
|
$_SESSION = $existingSessionVars;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user