Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added return before redirects

As recommended by the Cookbook:
http://book.cakephp.org/2.0/en/development/testing.html#testing-controllers

> When testing actions that contain redirect() and other code following the redirect it is generally a good idea to return when redirecting. The reason for this, is that redirect() is mocked in testing, and does not exit like normal. And instead of your code exiting, it will continue to run code following the redirect.
  • Loading branch information...
commit 4a37ad56370c48664da173b136de9f32cf55970e 1 parent 8a81903
@ravage84 ravage84 authored
View
8 lib/Cake/Console/Templates/default/actions/controller_actions.ctp
@@ -56,7 +56,7 @@
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved'));
- $this->redirect(array('action' => 'index'));
+ return $this->redirect(array('action' => 'index'));
<?php else: ?>
$this->flash(__('<?php echo ucfirst(strtolower($currentModelName)); ?> saved.'), array('action' => 'index'));
<?php endif; ?>
@@ -99,7 +99,7 @@
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved'));
- $this->redirect(array('action' => 'index'));
+ return $this->redirect(array('action' => 'index'));
<?php else: ?>
$this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), array('action' => 'index'));
<?php endif; ?>
@@ -145,7 +145,7 @@
if ($this-><?php echo $currentModelName; ?>->delete()) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'));
- $this->redirect(array('action' => 'index'));
+ return $this->redirect(array('action' => 'index'));
<?php else: ?>
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'), array('action' => 'index'));
<?php endif; ?>
@@ -155,5 +155,5 @@
<?php else: ?>
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'), array('action' => 'index'));
<?php endif; ?>
- $this->redirect(array('action' => 'index'));
+ return $this->redirect(array('action' => 'index'));
}
Please sign in to comment.
Something went wrong with that request. Please try again.