mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-05 02:52:41 +00:00
Making RequestHandler component carry along a passed status code. This fixes issues where RequestHandler hijacks an redirect(). Fixes #658
This commit is contained in:
parent
c48f6d6536
commit
95dbae8acf
2 changed files with 25 additions and 5 deletions
|
@ -262,7 +262,7 @@ class RequestHandlerComponent extends Object {
|
|||
* @param mixed $url A string or array containing the redirect location
|
||||
* @access public
|
||||
*/
|
||||
function beforeRedirect(&$controller, $url) {
|
||||
function beforeRedirect(&$controller, $url, $status = null) {
|
||||
if (!$this->isAjax()) {
|
||||
return;
|
||||
}
|
||||
|
@ -272,6 +272,12 @@ class RequestHandlerComponent extends Object {
|
|||
if (is_array($url)) {
|
||||
$url = Router::url($url + array('base' => false));
|
||||
}
|
||||
if (!empty($status)) {
|
||||
$statusCode = $controller->httpCodes($status);
|
||||
$code = key($statusCode);
|
||||
$msg = $statusCode[$code];
|
||||
$controller->header("HTTP/1.1 {$code} {$msg}");
|
||||
}
|
||||
echo $this->requestAction($url, array('return'));
|
||||
$this->_stop();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue