mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
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.
This commit is contained in:
parent
8a81903e37
commit
4a37ad5637
1 changed files with 4 additions and 4 deletions
|
@ -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'));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue