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

Skip to content

CSRF deprecation, upgrade docs do not state how to upgrade CSRF service #14899

Closed
@reecefowell

Description

@reecefowell

The dev bar outputs the following in the tab for "logs".

DEPRECATED - The Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderAdapter class is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.

It is not documented anywhere I can see how to deal with this. I upgraded a project from 2.5 to 2.7 and now I get a lot of these errors. All of which I was able to solve, but the CSRF token issue is a mystery.

The default configuration has this

        <service id="form.csrf_provider" class="Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfTokenManagerAdapter">
            <argument type="service" id="security.csrf.token_manager" />
        </service>

But the file Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfTokenManagerAdapter states

    public function getTokenManager($triggerDeprecationError = true)
    {
        if ($triggerDeprecationError) {
            trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED);
        }

        return $this->tokenManager;
    }

    /**
     * {@inheritdoc}
     */
    public function generateCsrfToken($intention)
    {
        trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED);

        return $this->tokenManager->getToken($intention)->getValue();
    }

Only things I can find online are suggestions to disable warnings in my php.ini etc. Considering I solved the other issues surely there is a way to appropriate fix this issue while upgrading also?

These warnings are incredibly invasive BTW, not good for DX.

https://dl.dropboxusercontent.com/u/18267237/Screenshots/Screen%20Shot%202015-06-07%20at%2005.52.41.png

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions