From 3e48d2e082ae6207e0a64841defb870f5f1dba87 Mon Sep 17 00:00:00 2001 From: euromark Date: Sat, 4 Jan 2014 13:18:14 +0100 Subject: [PATCH] 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 5d88d6bcdb2..bdb2c3bee29 100644 --- a/lib/Cake/Console/Command/UpgradeShell.php +++ b/lib/Cake/Console/Command/UpgradeShell.php @@ -500,6 +500,29 @@ public function constants() { $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 @@ public function getOptionParser() { ))->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