Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Abstract voter tweaks#15921

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:2.8fromweaverryan:abstract-voter-tweaks
Sep 27, 2015
Merged

Conversation

weaverryan
Copy link
Member

QA
Bug fix?yes (a little)
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

Based on suggestions from stof in#15870, this simplifies the BC and deprecation throwing code. This also adds a BadMethodCallException in case the user doesn't overrideisGrantedorvoteOnAttribute, because that's just plain wrong (as is callingisGranted() on the parent class directly, since that was formerly abstract).

@wouterj
Copy link
Member

Duplicate of#15886 ?

@weaverryan
Copy link
MemberAuthor

@wouterj it is - do you want to update your PR - i.e. add the trigger_error and remove the reflection stuff? I'm not convinced whether my BadMethodCallException is needed or not.

@stof
Copy link
Member

👍

Status: reviewed

@weaverryan the BadMethodCallException is a good idea: we will makevoteOnAttribute abstract in 3.0 (we cannot yet in 2.8 for BC), so not overwriting anything must fail loudly

@@ -191,7 +178,8 @@ protected function getSupportedAttributes()
*/
protected function isGranted($attribute, $object, $user = null)
{
return false;
// forces isGranted() or voteOnAttribute() to be overridden
throw new \BadMethodCallException(sprintf('You must override either the voteOnAttribute() or isGranted() (deprecated) method in "%s"', get_class($this)));
Copy link
Member

Choose a reason for hiding this comment

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

we can only mentionvoteOnAttribute() here, can't we? No need to talk about overriding a method that shouldn't be used anymore

Copy link
Member

Choose a reason for hiding this comment

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

agreed

@wouterj
Copy link
Member

@weaverryan I think it's easier to finish this PR, I've closed mine.

@weaverryan
Copy link
MemberAuthor

Great - PR updated - thanks!

@@ -191,7 +178,8 @@ protected function getSupportedAttributes()
*/
protected function isGranted($attribute, $object, $user = null)
{
return false;
// forces isGranted() or voteOnAttribute() to be overridden
throw new \BadMethodCallException(sprintf('You must override the voteOnAttribute() method in "%s"', get_class($this)));
Copy link
Member

Choose a reason for hiding this comment

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

very minor: All exceptions end with a full stop in Syfmony

@wouterj
Copy link
Member

I can't make any sense of the AbstractVoterTest.This is how I implemented it in a PR merged yesterday, while the code shown in the branch now (and in your PR) is just a copy of the test in a bad location... (seems like something went wrong in the merge:6f7aae9)

@weaverryan
Copy link
MemberAuthor

@wouterj I don't see it. In this PR, the 2.8 branch and your linked PR, it all looks like its in.../Security/Core/Tests/...

@wouterj
Copy link
Member

@weaverryan yeah, but take a look at the contents. The 2.8 branch (and your PR) has the contents of the tests that was inSecurity/Tests/Core (wrongly), while my linked PR has completely different tests

@weaverryan
Copy link
MemberAuthor

@wouterj Ah, yep - I see the same thing (I thought the path was the problem). You should create a new PR to fix this, then I can rebase after your merged. You better to do that since that's your test code that needs to be re-added.

@Tobion
Copy link
Contributor

As I explained in#15886 (comment) here won't be any deprecation message for voters that don't support any attribute even though they will break in 3.0

@weaverryan
Copy link
MemberAuthor

@Tobion good point - I'd vote to revert back to the Reflection stuff then - since the problem is with theclass itself (not how some code in the class behaves), so it would be most awesome if we added a deprecation warning as soon as the problematic class is used.

@stof
Copy link
Member

@weaverryan can you rebase this branch so that tests of the Security component can actually run ? Your PR was opened at the time where the testsuite of the Security component was triggering a fatal error before reaching voters.

@weaverryan
Copy link
MemberAuthor

done - and thanks for fixing those tests

@wouterj
Copy link
Member

@weaverryan see#15932 for fixing the tests

@fabpot
Copy link
Member

Thank you@weaverryan.

@fabpotfabpot merged commitc03f5c2 intosymfony:2.8Sep 27, 2015
fabpot added a commit that referenced this pull requestSep 27, 2015
This PR was merged into the 2.8 branch.Discussion----------Abstract voter tweaks| Q             | A| ------------- | ---| Bug fix?      | yes (a little)| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aBased on suggestions from stof in#15870, this simplifies the BC and deprecation throwing code. This also adds a BadMethodCallException in case the user doesn't override `isGranted` *or* `voteOnAttribute`, because that's just plain wrong (as is calling `isGranted()` on the parent class directly, since that was formerly abstract).Commits-------c03f5c2 Massively simplifying the BC and deprecated-throwing code thanks to suggestions by stof in#15870
@weaverryanweaverryan deleted the abstract-voter-tweaks branchSeptember 27, 2015 20:47
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@weaverryan@wouterj@stof@Tobion@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp