Permalink
Browse files

FIX: Follow internal redirections for cli operations.

  • Loading branch information...
1 parent fd6a161 commit 63778550e5106dff114b8276cb8591ccb2ca63a3 @wilr wilr committed Sep 16, 2013
Showing with 16 additions and 5 deletions.
  1. +16 −5 control/Director.php
View
@@ -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) {

0 comments on commit 6377855

Please sign in to comment.