Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FormProtectionComponent validationFailureCallback should use $event->setResult() #18750

Open
@markusramsak

Description

@markusramsak

Description

if you return a response (i.e. redirect response) in validationFailureCallback the following deprecation warning occurs:

Since 5.2.0: Returning a value from event listeners is deprecated. Use `$event->setResult()` instead in `Controller.startup` of `App\Controller\UsersController`
/home/wotanabx/webseiten/team_wahlnuss/vendor/cakephp/cakephp/src/Event/EventManager.php, line: 314

the following is part of the startup method in FormProtectionComponent

if (!$isValid) {
                return $this->validationFailure($formProtector);
 }

the solution I guess is simply by change the return to $event->setResult(...)

if (!$isValid) {
                $event->setResult($this->validationFailure($formProtector));
}

CakePHP Version

5.2.4

PHP Version

8.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions