mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #2423 from wilr/cliredirects
FIX: Follow internal redirections for cli operations.
This commit is contained in:
commit
f07ce0b25e
@ -147,11 +147,22 @@ class Director implements TemplateGlobalProvider {
|
|||||||
|
|
||||||
// Return code for a redirection request
|
// Return code for a redirection request
|
||||||
if(is_string($result) && substr($result,0,9) == 'redirect:') {
|
if(is_string($result) && substr($result,0,9) == 'redirect:') {
|
||||||
$response = new SS_HTTPResponse();
|
$url = substr($result, 9);
|
||||||
$response->redirect(substr($result, 9));
|
|
||||||
$res = Injector::inst()->get('RequestProcessor')->postRequest($req, $response, $model);
|
if(Director::is_cli()) {
|
||||||
if ($res !== false) {
|
// on cli, follow SilverStripe redirects automatically
|
||||||
$response->output();
|
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
|
// Handle a controller
|
||||||
} else if($result) {
|
} else if($result) {
|
||||||
|
Loading…
Reference in New Issue
Block a user