Skip to content

[Security] don't allow to install the split Security packages #16144

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

Merged
merged 1 commit into from
Oct 28, 2015

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Oct 6, 2015

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

Currently, you would be able to install the Security component fromm
Symfony 2.3 together with one of the split packages from a higher
Symfony vesion like this:

{
    "require": {
        "symfony/symfony": "2.3.*",
        "symfony/security-core": "~2.7"
    }
}

However, you will end up with classes being present twice.

This must be reverted after merging up in the 2.7 branch.

@stof
Copy link
Member

stof commented Oct 6, 2015

Another solution would be to have replace rules for them, saying that we have the equivalent of security-core 2.3 when having this component.

Btw, this is needed at the root too, not only in the component

"conflict": {
"symfony/security-acl": "*",
"symfony/security-core": "*",
"symfony/security-csrf": "*",
Copy link
Member

Choose a reason for hiding this comment

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

this one is wrong. security-csrf was new code, which does not exist in the 2.3 branch

@xabbuh
Copy link
Member Author

xabbuh commented Oct 6, 2015

@stof Which solution is more effective for Composer (i.e. what requires less work for the dependency resolver)? Using replace or conflict?

@xabbuh
Copy link
Member Author

xabbuh commented Oct 7, 2015

I removed the CSRF component and duplicated the config into the root composer.json.

I also talked to @alcohol who pointed my to composer/composer#3754. Isn't that a reason we should use conflict rules here?

@stof
Copy link
Member

stof commented Oct 7, 2015

@xabbuh the advantage of replace is that it would allow people to depend on symfony/security-core even if they support Symfony 2.3, which is the LTS (even though they cannot get this package alone in a 2.3 setup but will always need a replacer package).

If you want to workaround the bug of composer, you would have to use a conflict rule with != self.version for each replacement rule. But I'm not sure it would work fine: this is exactly what replace is doing but optimizations applied in composer broke it.

@xabbuh
Copy link
Member Author

xabbuh commented Oct 7, 2015

Well, my goal of this pull request was to forbid to use a composer.json file like I showed in the description. With the bug being present in Composer a replace rule would not help at all in this case.

@stof
Copy link
Member

stof commented Oct 7, 2015

@xabbuh even without the bug, Composer would not forbid it: symfony/symfony 2.3 does not know anything about symfony/security-core.
and symfony/security-core does not know it should conflict with symfony/symfony (the replace rule is doing things the other way)

@xabbuh
Copy link
Member Author

xabbuh commented Oct 7, 2015

@stof I seem to be missing something. When we add the conflict rule for symfony/security-core to the symfony/symfony package, Composer would forbid to install any version of the Security Core component together with the complete package.

On the other hand, when we tell the full package to replace symfony/security-core Composer should not install both packages as the full package already provides the Security Core package or it should forbid installation when there is a version mismatch (given that the bug did not exist).

@stof
Copy link
Member

stof commented Oct 7, 2015

@xabbuh assuming that the bug does not exist, it should forbid installing any version of the replaced package when the replacer is installed.
But your example above would still not be forbidden without change in Symfony, as symfony/symfony 2.3 is not replacing symfony/security-core

@xabbuh
Copy link
Member Author

xabbuh commented Oct 7, 2015

Sure, that's why I suggest to make this change (once the conflict rule is added, the above described scenario would not install anymore). Or we could add a replace rule like you suggest which requires a fix in Composer to have an effect.

@fabpot
Copy link
Member

fabpot commented Oct 13, 2015

Is this one mergeable as is?

@xabbuh
Copy link
Member Author

xabbuh commented Oct 15, 2015

I think yes, but we can change the conflict rule to replace if that's something the other @symfony/deciders prefer.

@jakzal
Copy link
Contributor

jakzal commented Oct 15, 2015

@xabbuh I think replace is more semantically correct.

@alcohol
Copy link
Contributor

alcohol commented Oct 16, 2015

I would use a replace for self.version and a conflict for !self.version, I think.

@stof
Copy link
Member

stof commented Oct 16, 2015

@alcohol the conflict for !self.version should not be necessary. this should already be done in Composer itself, as it is the meaning of replace (it conflicts with all versions of the replaced package). But one of the solver optimization broke this (and the test submitted to Composer was changed by @Seldaek to make it pass with the buggy code instead of solving the issue)

@alcohol
Copy link
Contributor

alcohol commented Oct 16, 2015

Ideally, it should not, no. But right now it does. Hence why I suggest it. It's harmless to add it yourself, and I doubt the odd behaviour in Composer will get fixed any time soon.

@Seldaek
Copy link
Member

Seldaek commented Oct 21, 2015

You can't easily conflict with !self.version though AFAIK, so I would rather people not attempt to fix composer stuff from the outside. replace is used for everything else in symfony subtree splits, so I don't see why not continuing in that line for this?

Currently, you would be able to install the Security component fromm
Symfony 2.3 together with one of the split packages from a higher
Symfony vesion like this:

```json
{
    "require": {
        "symfony/symfony": "2.3.*",
        "symfony/security-core": "~2.7"
    }
}
```

However, you will end up with classes being present twice.

This must be reverted after merging up in the `2.7` branch.
@xabbuh
Copy link
Member Author

xabbuh commented Oct 27, 2015

I updated the PR to use replace instead.

@fabpot
Copy link
Member

fabpot commented Oct 28, 2015

Thank you @xabbuh.

@fabpot fabpot merged commit 0d14064 into symfony:2.3 Oct 28, 2015
fabpot added a commit that referenced this pull request Oct 28, 2015
…ges (xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

[Security] don't allow to install the split Security packages

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

Currently, you would be able to install the Security component fromm
Symfony 2.3 together with one of the split packages from a higher
Symfony vesion like this:

```json
{
    "require": {
        "symfony/symfony": "2.3.*",
        "symfony/security-core": "~2.7"
    }
}
```

However, you will end up with classes being present twice.

This must be reverted after merging up in the `2.7` branch.

Commits
-------

0d14064 don't allow to install the split Security packages
@xabbuh xabbuh deleted the issue-16134 branch October 28, 2015 08:01
This was referenced Nov 23, 2015
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.

7 participants