Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DI] Fix Cannot declare class ...\DefinitionDecorator, because the name is already in use#22657
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…me is already in use
ogizanagi commentedMay 7, 2017
Here is the fixed reproducer build on Travis:https://travis-ci.org/ogizanagi/symfony-21369/builds/229639096 |
chalasr left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Preserving autocompletion as well 👍
fabpot commentedMay 7, 2017
Thank you@ogizanagi. |
…ause the name is already in use (ogizanagi)This PR was merged into the 3.3-dev branch.Discussion----------[DI] Fix Cannot declare class ...\DefinitionDecorator, because the name is already in use| Q | A| ------------- | ---| Branch? | 3.3| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#21369| License | MIT| Doc PR | N/AThe `return` trick doesn't seem to work, and php is still trying to declare the `DefinitionDecorator` class, which causes the "Cannot declare class ...\DefinitionDecorator, because the name is already in use" error because of the `class_alias` previously declared in `ChildDefinition.php`.This never happens as soon as the `ChildDefinition` class is used first, as the alias will take hand, but their are some situations, like in some unit test cases it can happen apparently, because `DefinitionDecorator` is used first.Commits-------530849e [DI] Fix Cannot declare class ...\DefinitionDecorator, because the name is already in use
xabbuh commentedMay 7, 2017
Don't we have other places where we follow the same approach? |
ogizanagi commentedMay 7, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@xabbuh : You probably mean the |
ogizanagi commentedMay 7, 2017
I guess it is actually, for the same reasons as here: composer classmap and the |
…sDecisionManager BC layer (ogizanagi)This PR was merged into the 3.3-dev branch.Discussion----------[Security] Fix TraceableAccessDecisionManager / DebugAccessDecisionManager BC layer| Q | A| ------------- | ---| Branch? | 3.3| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#22657 (comment)| License | MIT| Doc PR | N/ASame as#22657 for the renaming of `DebugAccessDecisionManager` into `TraceableAccessDecisionManager`. Indeed, I think we also require to redeclare the old `DebugAccessDecisionManager` for composer `classmap-authoritative` autoloading strategy & classmap dumper.AppVeyor failures unrelated.Edit: Re-thinking about it, it's probably not very common to dump the classmap and use the `classmap-authoritative` strategy when using those classes... That's to say: in debug mode/dev env. So it may be the reason why the class wasn't redeclared on contrary of `DefinitionDecorator`.Commits-------5b123b9 [Security] Fix TraceableAccessDecisionManager / DebugAccessDecisionManager BC layer
This PR was merged into the 1.x branch.Discussion----------Use class_exists instead of requireI think this is required forsymfony/symfony#23073 to pass. It's probably very similar tosymfony/symfony#22657.A simple reproducer:```php<?phpuse Twig\Node\Node;require_once __DIR__ . '/vendor/autoload.php';new Node();new \Twig_Node();```[Without this patch](https://travis-ci.org/symfony/symfony/jobs/239712676#L2100):```phpPHP Fatal error: Cannot declare class Twig_Node, because the name is already in use in vendor/twig/twig/lib/Twig/Node.php on line 20```With, everything works fine, whatever the two calls order.Commits-------2c174e4 Use class_exists instead of require
Uh oh!
There was an error while loading.Please reload this page.
The
returntrick doesn't seem to work, and php is still trying to declare theDefinitionDecoratorclass, which causes the "Cannot declare class ...\DefinitionDecorator, because the name is already in use" error because of theclass_aliaspreviously declared inChildDefinition.php.This never happens as soon as the
ChildDefinitionclass is used first, as the alias will take hand, but their are some situations, like in some unit test cases it can happen apparently, becauseDefinitionDecoratoris used first.