Skip to content

Commit

Permalink
FIX: Follow internal redirections for cli operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr committed Sep 16, 2013
1 parent fd6a161 commit 6377855
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions control/Director.php
Expand Up @@ -147,11 +147,22 @@ public static function direct($url, DataModel $model) {

// Return code for a redirection request
if(is_string($result) && substr($result,0,9) == 'redirect:') {
$response = new SS_HTTPResponse();
$response->redirect(substr($result, 9));
$res = Injector::inst()->get('RequestProcessor')->postRequest($req, $response, $model);
if ($res !== false) {
$response->output();
$url = substr($result, 9);

if(Director::is_cli()) {
// on cli, follow SilverStripe redirects automatically
return Director::direct(
str_replace(Director::absoluteBaseURL(), '', $url),
DataModel::inst()
);
} else {
$response = new SS_HTTPResponse();
$response->redirect($url);
$res = Injector::inst()->get('RequestProcessor')->postRequest($req, $response, $model);

if ($res !== false) {
$response->output();
}
}
// Handle a controller
} else if($result) {
Expand Down

0 comments on commit 6377855

Please sign in to comment.