Calling redirect() throws an sfStopException [1] to stop the execution, as it is not needed anymore after you have redirected.
http://trac.symfony-project.org/browser/branches/1.4/lib/action/sfAction.class.php#L204 On Tue, Mar 30, 2010 at 17:14, NOOVEO - Christophe Brun <[email protected]> wrote: > I want to catch some exceptions in my actions and to display nice and > informative messages for my users. > > class utilisateursActions extends autoUtilisateursActions { > public function executeDelete(sfWebRequest $request) { > try { > // do stuff... > sfContext::getInstance()->getLogger()->err(__METHOD__." ligne > ".__LINE__); // line 50 > return $this->redirect('@avalidroute'); > } > catch(Exception $x) { > sfContext::getInstance()->getLogger()->err(__METHOD__." ligne > ".__LINE__); // line 54 > $this->getUser()->setFlash('error', 'KO'); > } > } > } > > Unfortunately, the flash and the log tells me that the code goes through 50, > redirects to the required route, AND goes on to line 54 + flashes the error. > > I already knew that $action->redirect() has the side effect (very > unfortunate as all side effects are IMHO) to break the standard flow of > code, that's why you must return $action-redirect() instead. > But what if return $obj->redirect() also breaks the flow ? > Or am I missing some elephant hidden in my kitchen ? > > -- > If you want to report a vulnerability issue on symfony, please send it to > security at symfony-project.com > > You received this message because you are subscribed to the Google > Groups "symfony users" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/symfony-users?hl=en > > To unsubscribe from this group, send email to > symfony-users+unsubscribegooglegroups.com or reply to this email with the > words "REMOVE ME" as the subject. > -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en To unsubscribe from this group, send email to symfony-users+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
