Skip to content

Commit

Permalink
bug #48032 [SecurityBundle] Set UserValueResolver's priority higher…
Browse files Browse the repository at this point in the history
… than `EntityValueResolver` (kbond)

This PR was merged into the 6.2 branch.

Discussion
----------

[SecurityBundle] Set `UserValueResolver`'s priority higher than `EntityValueResolver`

| Q             | A
| ------------- | ---
| Branch?       | 6.2
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | n/a
| License       | MIT
| Doc PR        | n/a

`UserValueResolver`'s priority is currently `40` and `EntityValueResolver`'s priority is `110` (configured in doctrine-bundle).

Currently, to use the `CurrentUser` attribute and `MapEntity` (when `auto_mapping` is enabled), you need to do the following to have it work:

```php
public function postAction(
  #[CurrentUser]
  #[MapEntity(disabled: true)]
  User $user,
  Post $post
)
```

This removes this need for `#[MapEntity(disabled: true)]` but I'm not sure the larger impact of increasing the priority of `UserValueResolver`. Here is some context as to why the priorities are they way they are:
- doctrine/DoctrineBundle#1554 (comment)
- symfony/symfony#18510

Commits
-------

48499b99c4 Set `UserValueResolver`'s priority higher than `EntityValueResolver`
  • Loading branch information
nicolas-grekas committed Nov 9, 2022
2 parents 706d8cc + 6357d23 commit 17cf5da
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Resources/config/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
->args([
service('security.token_storage'),
])
->tag('controller.argument_value_resolver', ['priority' => 40])
->tag('controller.argument_value_resolver', ['priority' => 120])

// Authentication related services
->set('security.authentication.trust_resolver', AuthenticationTrustResolver::class)
Expand Down

0 comments on commit 17cf5da

Please sign in to comment.