Skip to content

[FrameworkBundle][DX] Display a nice error message if an enabled component is missing #25094

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

Conversation

derrabus
Copy link
Member

Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #25093
License MIT
Doc PR N/A

@nicolas-grekas
Copy link
Member

Could you please check if that happens for other components also?

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Nov 22, 2017
@@ -232,6 +232,10 @@ public function load(array $configs, ContainerBuilder $container)
}

if ($this->isConfigEnabled($container, $config['form'])) {
if (!class_exists('Symfony\Component\Form\Form')) {
throw new LogicException('Form support cannot be enabled. Please install the Form component.');
Copy link
Member

Choose a reason for hiding this comment

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

just to match similar messages:
Form support cannot be enabled as the Form component is not installed.

Copy link
Member Author

Choose a reason for hiding this comment

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

@xabbuh
Copy link
Member

xabbuh commented Nov 22, 2017

For other components we did this in 3.3. Should we merge the PR into the 3.3 as a bugfix?

@derrabus
Copy link
Member Author

@nicolas-grekas Serializer is also affected. I can enable the component without having it installed and FrameworkBundle would register the serializer service, but it's impossible to wire it.

@derrabus
Copy link
Member Author

I've also checked the validator: When enabling it, FrameworkExtension complains about the missing Translation component, which is not wrong, but seems a bit odd. However, if the Translation component is present, I get the expected exception about the missing Validator component.

@derrabus derrabus force-pushed the 3.4-fail-on-missing-form-component branch from 4b86116 to e31badc Compare November 22, 2017 10:40
@derrabus derrabus changed the title Display a nice error message if the form component is missing [FrameworkBundle][DX] Display a nice error message if an enabled component is missing Nov 22, 2017
@derrabus
Copy link
Member Author

Do you think, we can remove those lines?

if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['validation'])) {
throw new LogicException('Validation support cannot be enabled as the Translation component is not installed.');
}

Installing Validator without Translation is not possible, enabling validation without the Validator component will be caught elsewhere. So this block just generates a confusing error message.

@derrabus derrabus force-pushed the 3.4-fail-on-missing-form-component branch from e31badc to 127b9de Compare November 22, 2017 10:52
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.

let's go for 3.3

@derrabus derrabus force-pushed the 3.4-fail-on-missing-form-component branch from 127b9de to 2b45805 Compare November 22, 2017 11:31
@derrabus derrabus changed the base branch from 3.4 to 3.3 November 22, 2017 11:32
@derrabus
Copy link
Member Author

3.3 it is, then.

@nicolas-grekas nicolas-grekas modified the milestones: 3.4, 3.3 Nov 22, 2017
@nicolas-grekas
Copy link
Member

Thank you @derrabus.

@nicolas-grekas nicolas-grekas merged commit 2b45805 into symfony:3.3 Nov 22, 2017
nicolas-grekas added a commit that referenced this pull request Nov 22, 2017
…nabled component is missing (derrabus)

This PR was merged into the 3.3 branch.

Discussion
----------

[FrameworkBundle][DX] Display a nice error message if an enabled component is missing

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #25093
| License       | MIT
| Doc PR        | N/A

Commits
-------

2b45805 Display a nice error message if the form/serializer component is missing.
@nicolas-grekas
Copy link
Member

@derrabus about #25094 (comment), you reverted your idea?

@derrabus
Copy link
Member Author

@nicolas-grekas For now, yes. That change conflicted with the 3.3 branch. I will setup a 3.3 app tonight and test again.

@derrabus derrabus deleted the 3.4-fail-on-missing-form-component branch November 22, 2017 12:15
This was referenced Nov 24, 2017
@fabpot fabpot mentioned this pull request Dec 4, 2017
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.

4 participants