redirect problems

Hi, I'm studying the response->redirect; and I encounter 2 strange results:

  1. validation - after redirection, seem like it's going to validate one more time. For example I insert a row that contains unique value, after the redirection it throws me an error. This problem will not occur for forward.
  2. flash session message - similar to validation, a flash message will output twice, and doesn't happen when using forward.

Have any of you encounter this problem?


The strange thing is the same code (haven't change anything, no return) magically produce different result:

  1. validation didn't work yesterday works today.
  2. flash session message still output twice even with return.

they're the simplest code.

    public function testAction(){
        $systemUser           = new SystemUsers();
        $systemUser->username = 'un1'; // this column is unique
            foreach($systemUser->getMessages() as $message){
                $this->flash->error((string) $message);
            return $this->forward('test/success');

note: apparently the same action (testAction) is executed twice (it happens that it executed four times).

related stackoverflow


can you provide an minimal example app with the code? I just tried it on an really simple app and in this, the validation failed everytime and the flash message were only displayed once.

Thanks, Martin


Thanks for your reply Martin. Mine also showed validation fail (message) everytime (yesterday); if

  1. create a row (Phalcon app) -> no problem
  2. delete the row (at phpMyAdmin)
  3. create the same row (Phalcon app) -> row is inserted to database, failure detected and error message shown once
  4. repeat 2. to 3.