From 3e48d2e082ae6207e0a64841defb870f5f1dba87 Mon Sep 17 00:00:00 2001 From: euromark Date: Sat, 4 Jan 2014 13:18:14 +0100 Subject: [PATCH 1/2] Add return early statements for redirecting in controllers. --- lib/Cake/Console/Command/UpgradeShell.php | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/Cake/Console/Command/UpgradeShell.php b/lib/Cake/Console/Command/UpgradeShell.php index 5d88d6bcd..bdb2c3bee 100644 --- a/lib/Cake/Console/Command/UpgradeShell.php +++ b/lib/Cake/Console/Command/UpgradeShell.php @@ -500,6 +500,29 @@ class UpgradeShell extends AppShell { $this->_filesRegexpUpdate($patterns); } +/** + * Update controllers. + * + * - Make redirect statements return early. + * + * @return void + */ + public function controllers() { + $this->_paths = App::Path('Controller'); + if (!empty($this->params['plugin'])) { + $this->_paths = App::Path('Controller', $this->params['plugin']); + } + $patterns = array( + array( + '$this->redirect() to return $this->redirect()', + '/\t\$this-\>redirect\(/', + "\t" . 'return $this->redirect(' + ), + ); + + $this->_filesRegexpUpdate($patterns); + } + /** * Update components. * @@ -840,6 +863,9 @@ class UpgradeShell extends AppShell { ))->addSubcommand('constants', array( 'help' => __d('cake_console', "Replace Obsolete constants"), 'parser' => $subcommandParser + ))->addSubcommand('controllers', array( + 'help' => __d('cake_console', 'Update controllers.'), + 'parser' => $subcommandParser ))->addSubcommand('components', array( 'help' => __d('cake_console', 'Update components to extend Component class.'), 'parser' => $subcommandParser From 483cd13a26900b5302b41dea7063b4b7d66e46f2 Mon Sep 17 00:00:00 2001 From: euromark Date: Mon, 6 Jan 2014 20:00:45 +0100 Subject: [PATCH 2/2] rename method --- lib/Cake/Console/Command/UpgradeShell.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Console/Command/UpgradeShell.php b/lib/Cake/Console/Command/UpgradeShell.php index bdb2c3bee..699bcf4e1 100644 --- a/lib/Cake/Console/Command/UpgradeShell.php +++ b/lib/Cake/Console/Command/UpgradeShell.php @@ -501,13 +501,13 @@ class UpgradeShell extends AppShell { } /** - * Update controllers. + * Update controller redirects. * * - Make redirect statements return early. * * @return void */ - public function controllers() { + public function controller_redirects() { $this->_paths = App::Path('Controller'); if (!empty($this->params['plugin'])) { $this->_paths = App::Path('Controller', $this->params['plugin']); @@ -863,8 +863,8 @@ class UpgradeShell extends AppShell { ))->addSubcommand('constants', array( 'help' => __d('cake_console', "Replace Obsolete constants"), 'parser' => $subcommandParser - ))->addSubcommand('controllers', array( - 'help' => __d('cake_console', 'Update controllers.'), + ))->addSubcommand('controller_redirects', array( + 'help' => __d('cake_console', 'Return early on controller redirect calls.'), 'parser' => $subcommandParser ))->addSubcommand('components', array( 'help' => __d('cake_console', 'Update components to extend Component class.'),