Skip to content
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

Continuation : Add messages and score on votes #58107

Open
wants to merge 6 commits into
base: 7.2
Choose a base branch
from

Conversation

eltharin
Copy link
Contributor

Q A
Branch? 7.2
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #27995, #26343, #35592, #43147
License MIT

This PR continue the work started by @maidmaid and @noniagriconomie in #35592, continued by @yellow1912 in #43147 continued by @alamirault in #46493.

I rebase on 7.2 and remove deprecation as suggested by nicolas-grekas for not causing backward compatiblity breaks.

It allow to have informations about AccessDecisionManager and Voters (And understand why we have an AccessDeniedException with clear infos).
170878112-f93f8d90-97b7-42f8-8494-603d6b2019e2

I add possibility to respond a voter with a score and create a Scoring strategy, looks like consensus but with ponderation.

@eltharin eltharin force-pushed the add_messages_and_score_on_votes branch 8 times, most recently from 6e67169 to 71d7744 Compare August 27, 2024 21:41
@94noni
Copy link
Contributor

94noni commented Aug 28, 2024

@eltharin hi 👋🏻

nice to see that you are willing to take over this amount of work, incremented overtime by different coders and reviewers :)

i am still interested in such feature even though now I rarely use voter, still thinking that this can be a great addition in core (like workflow transition blocker message is available)

to be honest, I think I would probable split this in 2 separates PRs, just to ease review and reduce the friction already existing around such feature, as it needs to arrive on a simple/BC/evolutive/maintainable way in core

  • add the feature of a voter message (main issue feature that seem to have lot of traction over the year regarding all PRs reactions)
  • add the feature of a new decision strategy alone (perhaps even before the voter message)

in any way, I will add a reminder to make a review on this PR as well :)

( PS: @noniagriconomie is one old account of mine no more used since )

@eltharin
Copy link
Contributor Author

@94noni

you and other are the firsts to thank for the start of this work,

For the 2 PR's I thought about it but it's absolutlly linked, both needs Vote Object so getVote function so GetDecision functions,

Remove first or second feature but keep other one will only touch few files compared with all files changed.

At start, i saw your PR's without really needed, but when I wrote myine for scoring, I saw I made the same work as you, so I included your work in these to not have conflict when one will be accepted.

As it's a big update to add all these functions in symfony core I add a new benefit to this to have more chance to see this PR passed :)

@eltharin eltharin force-pushed the add_messages_and_score_on_votes branch from 46b15e0 to e9f63ce Compare August 30, 2024 08:51
@kevinpapst
Copy link

Did anyone ever run performance checks on these changes? Considering that Voters can be called hundreds of times per request, any overhead created by hundreds of new Vote() instances or checks for existing methods should imo be avoided (e.g. add new interfaces so I can opt-in to the new approach, instead of forcing the code upon everyone).

@eltharin eltharin force-pushed the add_messages_and_score_on_votes branch from e9f63ce to 278f259 Compare September 9, 2024 06:25
@@ -40,29 +43,38 @@ public function __construct(

public function decide(\Traversable $results): bool
{
return $this->getDecision(new \ArrayIterator(array_map(fn ($vote) => new Vote($vote), iterator_to_array($results))))->isGranted();
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps create a trait to avoid copy/past such internal ?

@eltharin eltharin force-pushed the add_messages_and_score_on_votes branch from 278f259 to 84f75b9 Compare September 9, 2024 10:29
@eltharin
Copy link
Contributor Author

eltharin commented Sep 10, 2024

Did anyone ever run performance checks on these changes? Considering that Voters can be called hundreds of times per request, any overhead created by hundreds of new Vote() instances or checks for existing methods should imo be avoided (e.g. add new interfaces so I can opt-in to the new approach, instead of forcing the code upon everyone).

I look with Symfony Profiler, with 3000 voters With 7.2 actual version VoteListener take 120MiB in 8ms with this PR, 118MiB for 8.4ms.
I don't made more performance test with a performance tool

@eltharin
Copy link
Contributor Author

friendly ping @chalasr as default reviewer

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.

[Security][DX] Be able to know why exactly SecurityVoter returns false
5 participants