Skip to content

Fixed the has_role() deprecation #866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 5, 2018
Merged

Fixed the has_role() deprecation #866

merged 1 commit into from
Oct 5, 2018

Conversation

javiereguiluz
Copy link
Member

@javiereguiluz javiereguiluz commented Oct 5, 2018

This is a deprecation introduced by the upgrade to Symfony 4.2 in #865.

14x: Using the "has_role()" function in security expressions is deprecated since Symfony 4.2, use "is_granted()" instead.
    2x in BlogControllerTest::testAdminNewPost from App\Tests\Controller\Admin
    2x in BlogControllerTest::testAdminEditPost from App\Tests\Controller\Admin
    2x in BlogControllerTest::testAdminDeletePost from App\Tests\Controller\Admin
    2x in UserControllerTest::testAccessDeniedForAnonymousUsers from App\Tests\Controller
    2x in UserControllerTest::testEditUser from App\Tests\Controller
    2x in UserControllerTest::testChangePassword from App\Tests\Controller
    1x in BlogControllerTest::testAdminBackendHomePage from App\Tests\Controller\Admin
    1x in BlogControllerTest::testAdminShowPost from App\Tests\Controller\Admin

@javiereguiluz javiereguiluz merged commit 51b5135 into symfony:master Oct 5, 2018
javiereguiluz added a commit that referenced this pull request Oct 5, 2018
This PR was merged into the master branch.

Discussion
----------

Fixed the has_role() deprecation

This is a deprecation introduced by the upgrade to Symfony 4.2 in #865.

```
14x: Using the "has_role()" function in security expressions is deprecated since Symfony 4.2, use "is_granted()" instead.
    2x in BlogControllerTest::testAdminNewPost from App\Tests\Controller\Admin
    2x in BlogControllerTest::testAdminEditPost from App\Tests\Controller\Admin
    2x in BlogControllerTest::testAdminDeletePost from App\Tests\Controller\Admin
    2x in UserControllerTest::testAccessDeniedForAnonymousUsers from App\Tests\Controller
    2x in UserControllerTest::testEditUser from App\Tests\Controller
    2x in UserControllerTest::testChangePassword from App\Tests\Controller
    1x in BlogControllerTest::testAdminBackendHomePage from App\Tests\Controller\Admin
    1x in BlogControllerTest::testAdminShowPost from App\Tests\Controller\Admin
```

Commits
-------

51b5135 Fixed the has_role() deprecation
@@ -33,7 +33,7 @@
* See http://knpbundles.com/keyword/admin
*
* @Route("/admin/post")
* @Security("has_role('ROLE_ADMIN')")
* @Security("is_granted('ROLE_ADMIN')")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even better would be to migrate to the @IsGranted annotation of FrameworkExtraBundle rather than @Security for all these @Security("is_granted(...)") cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants