Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DX] Remove default match from AbstractConfigCommand::findExtension#17456
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
kix commentedJan 20, 2016
The build failure seems unrelated to this PR:https://travis-ci.org/symfony/symfony/jobs/103599240#L3252 |
wouterj commentedJan 20, 2016
What about rewriting this like: $bundles =$this->initializeBundles();foreach ($bundlesas$bundle) {if ($name ===$bundle->getName()) {return$bundle->getContainerExtension(); }$extension =$bundle->getContainerExtension();if ($extension &&$name ===$extension->getAlias()) {return$extension; } }if ('Bundle' !==substr($name -6)) {$message =sprintf('No extensions with configuration available for "%s"',$name); }else {$message =sprintf('No extension with alias "%s" is enabled',$name); }thrownew \LogicException($message);} |
kix commentedJan 20, 2016
@wouterj, good idea, will update the PR. I just thought it could be better if less code was rewritten, but now I have to agree your code looks better :) |
7fd1d07 tof797e12ComparePreviously, findExtension would return the first extension that mightnot even match the $name parameter.
stof commentedJan 20, 2016
👍 |
wouterj commentedJan 20, 2016
Status: reviewed |
fabpot commentedJan 21, 2016
Thank you@kix. |
…Extension (kix)This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes#17456).Discussion----------[DX] Remove default match from AbstractConfigCommand::findExtension| Q | A| ------------- | ---| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | none| License | MIT| Doc PR | nonePreviously, `findExtension` would return the first extension that might not even match the `$name` parameter, which would quite confuse the user:```$ app/console config:debug TotallyNonExistentBundle# Current configuration for "TotallyNonExistentBundle"knp_paginator: default_options: sort_field_name: sort sort_direction_name: direction filter_field_name: filterField filter_value_name: filterValue page_name: page distinct: true template: pagination: 'KnpPaginatorBundle:Pagination:sliding.html.twig' filtration: 'KnpPaginatorBundle:Pagination:filtration.html.twig' sortable: 'KnpPaginatorBundle:Pagination:sortable_link.html.twig' page_range: 5```Same problem goes for the `config:dump` command. When you dumped the config for a bundle you thought you've registered, but, for example, you'd use a name that's not exactly matching, you'd get confusing output for a different bundle's configuration.The problem was, an `Extension` [was always fetched in the finder method](https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php#L51), and name/alias misses were ignored.Commits-------b85059a Remove default match from AbstractConfigCommand::findExtension
kix commentedJan 21, 2016
Thanks for merging! |
Previously,
findExtensionwould return the first extension that might not even match the$nameparameter, which would quite confuse the user:Same problem goes for the
config:dumpcommand. When you dumped the config for a bundle you thought you've registered, but, for example, you'd use a name that's not exactly matching, you'd get confusing output for a different bundle's configuration.The problem was, an
Extensionwas always fetched in the finder method, and name/alias misses were ignored.