Merge pull request #2423 from wilr/cliredirects

FIX: Follow internal redirections for cli operations.
This commit is contained in:
Ingo Schommer 2013-09-16 01:59:00 -07:00
commit f07ce0b25e

View File

@ -147,12 +147,23 @@ class Director implements TemplateGlobalProvider {
// Return code for a redirection request
if(is_string($result) && substr($result,0,9) == 'redirect:') {
$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(substr($result, 9));
$response->redirect($url);
$res = Injector::inst()->get('RequestProcessor')->postRequest($req, $response, $model);
if ($res !== false) {
$response->output();
}
}
// Handle a controller
} else if($result) {
if($result instanceof SS_HTTPResponse) {