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

Skip to content

[Form][FrameworkBundle] Regression with configuration of default CSRF Tokens #59867

Open
@PhilETaylor

Description

@PhilETaylor

Symfony version(s) affected

7.2.4

Description

regression caused by #59728

Symfony\Component\Security\Csrf\CsrfTokenManager::getToken(): Argument #1 ($tokenId) must be of type string, null given, called in /app/vendor/symfony/form/Extension/Csrf/Type/FormTypeCsrfExtension.php on line 80

Seems passing any array to the setAttributes causes this unless you pass csrf_token_id value in that array, there is no sane default applied.

In my case I was passing other attributes in this array, but not the csrf_token_id, as that was not needed before today.

How to reproduce

Minimum reproducer is

$this->createFormBuilder()->setAttributes([/* blank array, or some other key pairs, not including csrf_token_id*/])->getForm()->createView();

Possible Solution

No response

Additional Context

related change https://github.com/symfony/symfony/pull/59728/files#diff-438ae1976074de3d600070f2d02f4e87bcbc847d7826ca8aaeadc4231c5d701f

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions