Skip to content

[Security] Removed unnecessary statement #14581

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

Conversation

MacDada
Copy link
Contributor

@MacDada MacDada commented May 7, 2015

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets ~
License MIT
Doc PR ~

Removed unnecessary statement from PersistentTokenBasedRememberMeServices.php.

$series comes from $cookieParts and $this->tokenProvider->loadTokenBySeries($series); is supposed to find the token with that value. Doing $persistentToken->getSeries(); should give us exactly the same value, so it is an unnecessary statement.

Why?

  • We don't need it? We won't miss it when it's gone.
  • It confuses a code reader who starts guessing why would that be needed (at least I did and lost time because of that).

Unless…

It actually is needed, as we want TokenProviderInterface implementations to have a possibility to give a PersistentTokenInterface with a different series value than asked… I can make a PR to the testing class so that such requirement is checked upon.

I don't believe that this is BC, as this behaviour isn't documented anywhere and no existing (known to me) implementations return different series than the asked ones (and current tests pass successfully).

@fabpot
Copy link
Member

fabpot commented May 7, 2015

👍

@fabpot
Copy link
Member

fabpot commented May 15, 2015

Thank you @MacDada.

@fabpot fabpot merged commit c7a91f1 into symfony:2.7 May 15, 2015
fabpot added a commit that referenced this pull request May 15, 2015
This PR was merged into the 2.7 branch.

Discussion
----------

[Security] Removed unnecessary statement

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | ~
| License       | MIT
| Doc PR        | ~

Removed unnecessary statement from `PersistentTokenBasedRememberMeServices.php`.

`$series` comes from `$cookieParts` and `$this->tokenProvider->loadTokenBySeries($series);` is supposed to find the token with that value. Doing `$persistentToken->getSeries();` should give us exactly the same value, so it is an unnecessary statement.

Why?

* We don't need it? We won't miss it when it's gone.
* It confuses a code reader who starts guessing why would that be needed (at least I did and lost time because of that).

Unless…

It actually is needed, as we want `TokenProviderInterface` implementations to have a possibility to give a `PersistentTokenInterface` with a different series value than asked… I can make a PR to the testing class so that such requirement is checked upon.

I don't believe that this is BC, as this behaviour isn't documented anywhere and no existing (known to me) implementations return different series than the asked ones (and current tests pass successfully).

Commits
-------

c7a91f1 Removed unnecessary statement from PersistentTokenBasedRememberMeServices.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants