Skip to content

Commit

Permalink
Fixed issue phalcon#11324
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyklay committed Jan 19, 2016
1 parent 796d755 commit 6429b5a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Fixed `Phalcon\Translate\Adapter\Gettext::exists` bug[#11310](https://github.com/phalcon/cphalcon/issues/11310) related to the wrong returned value (always true)
- Fixed `Phalcon\Translate\Adapter\Gettext::setLocale` bug[#11311](https://github.com/phalcon/cphalcon/issues/11311) related to the incorrect setting locale
- Added ability to persistent connection in `Phalcon\Queue\Beanstalk::connect`
- Fixed `Phalcon\Http\Response::redirect` bug[#11324](https://github.com/phalcon/cphalcon/issues/11324). Incorrect initialization local array of status codes

# [2.0.9](https://github.com/phalcon/cphalcon/releases/tag/phalcon-v2.0.9) (2015-11-24)
- Fixed bug that double serializes data using Redis adapter
Expand Down
9 changes: 3 additions & 6 deletions phalcon/http/response.zep
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class Response implements ResponseInterface, InjectionAwareInterface
*/
public function redirect(location = null, boolean externalRedirect = false, int statusCode = 302) -> <Response>
{
var header, url, dependencyInjector, matched, message, view;
var header, url, dependencyInjector, matched, view;

if !location {
let location = "";
Expand Down Expand Up @@ -476,13 +476,10 @@ class Response implements ResponseInterface, InjectionAwareInterface
* The HTTP status is 302 by default, a temporary redirection
*/
if statusCode < 300 || statusCode > 308 {
let statusCode = 302,
message = this->_statusCodes[302];
} else {
fetch message, this->_statusCodes[statusCode];
let statusCode = 302;
}

this->setStatusCode(statusCode, message);
this->setStatusCode(statusCode);

/**
* Change the current location using 'Location'
Expand Down
33 changes: 32 additions & 1 deletion tests/unit/Phalcon/Http/Response/HttpResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* PhalconPHP Framework
*
* @copyright (c) 2011-2014 Phalcon Team
* @copyright (c) 2011-2016 Phalcon Team
* @link http://www.phalconphp.com
* @author Andres Gutierrez <andres@phalconphp.com>
* @author Nikolaos Dimopoulos <nikos@phalconphp.com>
Expand Down Expand Up @@ -327,6 +327,37 @@ function () {
);
}

/**
* Tests redirect local with non standard code
*
* @issue 11324
* @author Serghei Iakovlev <serghei@phalconphp.com>
* @since 2016-01-19
*/
public function testHttpResponseRedirectLocalUrlWithNonStandardCode()
{
$this->specify(
"redirect is not redirecting local with non standard code properly",
function () {
$response = $this->getResponseObject();
$response->resetHeaders();
$response->redirect('new/place/', false, 309);

$actual = $response->getHeaders();
$expected = PhResponseHeaders::__set_state(
[
'_headers' => [
'Status' => '302 Found',
'Location' => '/new/place/',
'HTTP/1.1 302 Found' => null,
]
]
);
expect($actual)->equals($expected);
}
);
}

/**
* Tests redirect remotely 301
*
Expand Down

0 comments on commit 6429b5a

Please sign in to comment.