Skip to content

Rename DebugAccessDecisionManager to TraceableAccessDecisionManager #21088

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

Closed
wants to merge 10 commits into from

Conversation

Jean85
Copy link
Contributor

@Jean85 Jean85 commented Dec 29, 2016

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #21085
License MIT

[EDIT] No longer WIP, test passing. Also, test added to preserve BC with the SecurityBundle.

@wouterj
Copy link
Member

wouterj commented Dec 29, 2016

Tests seem to pass on Travis. So maybe a local problem? I think you're correct about not having to care about BC here as it's @internal.

status: reviewed

(btw, you can ignore fabbot.io's coding style error)

Copy link
Member

@xabbuh xabbuh left a comment

Choose a reason for hiding this comment

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

We need to keep the old class name (possibly through a class alias). Otherwise, older versions of the SecurityBundle would break when being used with 3.3/3.4 versions of the Security Core component. We should probably add a test case (the fact that the build suite passed indicates that we are not testing anything/the right thing here).

@Jean85
Copy link
Contributor Author

Jean85 commented Dec 29, 2016

Well, it was not a local error but a fail of the Travis build on my fork, here: https://travis-ci.org/Jean85/symfony/builds/187412622

If we need a BC class, I will add it. In fact, mixing versions of the bundles may break stuff like in my build, you're right!

*/
class DebugAccessDecisionManager implements AccessDecisionManagerInterface
class DebugAccessDecisionManager extends TraceableAccessDecisionManager
Copy link
Member

Choose a reason for hiding this comment

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

What about using the same approach that @nicolas-grekas used in #20967 instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice! Doing it RN!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test failing locally... Maybe I'm missing something, but how is it supposed to work like that? It's defining the alias before declaring the class, it says that the Traceable class is missing!

Copy link
Member

Choose a reason for hiding this comment

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

Can you push your latest commit so we can take a look at it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed!


use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;

class_alias(TraceableAccessDecisionManager::class, DebugAccessDecisionManager::class);
Copy link
Member

Choose a reason for hiding this comment

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

moving this line after the class definition should make tests green

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've chosen a different approach: I've removed the class_exist (since it seems useless to me) and I've moved it into the deprecated file, which seems the right place to me.

@Jean85 Jean85 changed the title [WIP] Rename DebugAccessDecisionManager to TraceableAccessDecisionManager Rename DebugAccessDecisionManager to TraceableAccessDecisionManager Dec 29, 2016
@Jean85
Copy link
Contributor Author

Jean85 commented Dec 30, 2016

Latests commits are coming from the discussion with @nicolas-grekas in #21096.

@xabbuh
Copy link
Member

xabbuh commented Dec 30, 2016

@Jean85 In your test, the DebugAccessDecisionManager class was already loaded in line 47.

@Jean85
Copy link
Contributor Author

Jean85 commented Dec 30, 2016

You're right; I've tested locally and it works even if I launch the single tests method, so it's just a test issue, to avoid future regressions.

Maybe it's better if I move the tests to the top of the class, and I use a simple class_exist, to avoid this issue?

@xabbuh
Copy link
Member

xabbuh commented Dec 30, 2016

@Jean85 Not sure I completely understood what you meant with your last question. I suggest to simply follow the approach from #20967 though.

@Jean85
Copy link
Contributor Author

Jean85 commented Dec 30, 2016

I've reverted to the suggested approach, an rewrote the test to avoid triggering the autoload of the deprecated class.

Sorry if I was so stubborn @xabbuh , now I've rewritten the test to show how my approach was flawed. PHPUnit's assertInstanceOf was doing a class_exist behind the scene, triggering the autoload and hiding my mistake.

@@ -40,4 +41,16 @@ public function provideObjectsAndLogs()
yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => $x = array(), 'result' => false)), $x);
yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => $object, 'result' => false)), $object);
}

/**
* @group this
Copy link
Member

Choose a reason for hiding this comment

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

should be removed

@xabbuh
Copy link
Member

xabbuh commented Dec 30, 2016

@Jean85 Don't worry about that. Renaming is actually not so easy and it's always good to think about the approaches we use.

@Jean85
Copy link
Contributor Author

Jean85 commented Dec 30, 2016

Thanks! I've removed the annotation that I left behind by mistake!

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

👍 with minor changes

* about the security voters and the decisions made by them.
*
* @author Javier Eguiluz <javier.eguiluz@gmail.com>
* @author Alessandro Lai <alessandro.lai85@gmail.com>
Copy link
Member

Choose a reason for hiding this comment

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

you should remove this line, there is no authorship to claim here: git will record your contribution

*
* @internal
* @deprecated The DebugAccessDecisionManager class is deprecated since version 3.3 and will be removed in 4.0. Use the Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager class instead.
Copy link
Member

Choose a reason for hiding this comment

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

the namespace could be removed

{
$adm = new TraceableAccessDecisionManager(new AccessDecisionManager());

if (! $adm instanceof DebugAccessDecisionManager) {
Copy link
Member

Choose a reason for hiding this comment

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

extra space to be removed after !

$adm = new TraceableAccessDecisionManager(new AccessDecisionManager());

if (! $adm instanceof DebugAccessDecisionManager) {
$this->fail('Doesn\'t work, BC with SecurityBundle broken, see PR #21088');
Copy link
Member

Choose a reason for hiding this comment

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

we don't reference github, git blame is used instead to look for historical things. I propose:
$this->fail('For BC, TraceableAccessDecisionManager must be an instance of DebugAccessDecisionManager');

@nicolas-grekas nicolas-grekas added this to the 3.3 milestone Jan 2, 2017
@Jean85
Copy link
Contributor Author

Jean85 commented Jan 2, 2017

Fixes committed! The style checker is having some false positive I think...

*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Copy link
Member

Choose a reason for hiding this comment

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

This should IMO not be removed.

@Jean85
Copy link
Contributor Author

Jean85 commented Jan 3, 2017

@xabbuh done!

@xabbuh
Copy link
Member

xabbuh commented Jan 3, 2017

👍

Status: Reviewed

@nicolas-grekas
Copy link
Member

Thank you @Jean85.

nicolas-grekas added a commit that referenced this pull request Jan 3, 2017
…sionManager (Jean85)

This PR was squashed before being merged into the 3.3-dev branch (closes #21088).

Discussion
----------

Rename DebugAccessDecisionManager to TraceableAccessDecisionManager

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21085
| License       | MIT

[EDIT] No longer WIP, test passing. Also, test added to preserve BC with the SecurityBundle.

Commits
-------

c5e0e59 Rename DebugAccessDecisionManager to TraceableAccessDecisionManager
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.

5 participants