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,12 +147,23 @@ 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:') {
|
||||||
|
$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 = new SS_HTTPResponse();
|
||||||
$response->redirect(substr($result, 9));
|
$response->redirect($url);
|
||||||
$res = Injector::inst()->get('RequestProcessor')->postRequest($req, $response, $model);
|
$res = Injector::inst()->get('RequestProcessor')->postRequest($req, $response, $model);
|
||||||
|
|
||||||
if ($res !== false) {
|
if ($res !== false) {
|
||||||
$response->output();
|
$response->output();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Handle a controller
|
// Handle a controller
|
||||||
} else if($result) {
|
} else if($result) {
|
||||||
if($result instanceof SS_HTTPResponse) {
|
if($result instanceof SS_HTTPResponse) {
|
||||||
|
Loading…
Reference in New Issue
Block a user