Skip to content

Proposing Flex-specific error messages in the controller shortcuts #25133

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
Nov 24, 2017

Conversation

weaverryan
Copy link
Member

Q A
Branch? 4.0
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets none
License MIT
Doc PR not needed

This is to help discoverability when you try to use a feature that's not installed. It's opinionated about Flex being installed, which is why this is done on 4.0.

Two of the options relate to configuration. An alternative (if we don't like the short description) is to include a link instead (which could be some short URL - e.g. http://symfony.com/docs/sessions would be pretty cool).

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

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

Really nice!

@@ -326,7 +326,7 @@ protected function createFormBuilder($data = null, array $options = array()): Fo
protected function getDoctrine(): ManagerRegistry
{
if (!$this->container->has('doctrine')) {
throw new \LogicException('The DoctrineBundle is not registered in your application.');
throw new \LogicException('The DoctrineBundle is not registered in your application. Try running "composer require orm"');
Copy link
Member

Choose a reason for hiding this comment

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

I'd change this one. The error message mentions something about "DoctrineBundle", but then it tells you to install a strange "orm" thing. Could we change it to Try running "composer require doctrine"?

@@ -372,7 +372,7 @@ protected function getUser()
protected function isCsrfTokenValid(string $id, string $token): bool
{
if (!$this->container->has('security.csrf.token_manager')) {
throw new \LogicException('CSRF protection is not enabled in your application.');
throw new \LogicException('CSRF protection is not enabled in your application. Enable it with the "csrf_protection" key in "config/packages/framework.yaml"');
Copy link
Member

Choose a reason for hiding this comment

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

Flex should be auto-enabling it when requiring the security-csrf package, no ? If yes, the right advice is to require it too

Copy link
Member Author

Choose a reason for hiding this comment

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

That seems logical to me, bit I actually don't think it's enabled by default. It looks like it's always disabled unless you explicitly enable it: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php#L107-L116

Copy link
Member

Choose a reason for hiding this comment

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

😢 why making FrameworkBundle auto-enable all components except one ?

Copy link
Member

Choose a reason for hiding this comment

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

Looks like something we need to fix.

Copy link
Member

Choose a reason for hiding this comment

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

Anybody willing to submit a PR on that one? Would be cool to have it for 3.4/4.0 before final.

Copy link
Contributor

@sroze sroze Nov 24, 2017

Choose a reason for hiding this comment

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

@fapbot here you go: #25151

@weaverryan weaverryan force-pushed the controller-trait-helper branch from 8bbf48d to d377b15 Compare November 23, 2017 18:06
Copy link

@20uf 20uf left a comment

Choose a reason for hiding this comment

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

Nice idea.

@@ -372,7 +372,7 @@ protected function getUser()
protected function isCsrfTokenValid(string $id, string $token): bool
{
if (!$this->container->has('security.csrf.token_manager')) {
throw new \LogicException('CSRF protection is not enabled in your application.');
throw new \LogicException('CSRF protection is not enabled in your application. Enable it with the "csrf_protection" key in "config/packages/framework.yaml"');
Copy link
Contributor

Choose a reason for hiding this comment

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

Enable them in config/packages/framework.yaml. vs. Enable it with the "csrf_protection" key in "config/packages/framework.yaml"

always be specific/generic?

@fabpot
Copy link
Member

fabpot commented Nov 24, 2017

Thank you @weaverryan.

@fabpot fabpot merged commit d377b15 into symfony:master Nov 24, 2017
fabpot added a commit that referenced this pull request Nov 24, 2017
… shortcuts (weaverryan)

This PR was merged into the 4.1-dev branch.

Discussion
----------

Proposing Flex-specific error messages in the controller shortcuts

| Q             | A
| ------------- | ---
| Branch?       | 4.0
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | none
| License       | MIT
| Doc PR        | not needed

This is to help discoverability when you try to use a feature that's not installed. It's opinionated about Flex being installed, which is why this is done on 4.0.

Two of the options relate to configuration. An alternative (if we don't like the short description) is to include a link instead (which could be some short URL - e.g. `http://symfony.com/docs/sessions` would be pretty cool).

Commits
-------

d377b15 Proposing Flex-specific error messages in the controller shortcuts
@chalasr
Copy link
Member

chalasr commented Dec 30, 2017

This change is not present on the 4.0 branch. Backport needed?

@weaverryan
Copy link
Member Author

Oh, maybe! If so, can you create a PR?

@chalasr
Copy link
Member

chalasr commented Dec 30, 2017

Sure #25636

fabpot added a commit that referenced this pull request Jan 3, 2018
…tcuts to 3.4 (weaverryan)

This PR was merged into the 3.4 branch.

Discussion
----------

Backport Flex-specific error messages in controller shortcuts to 3.4

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #25133 (comment)
| License       | MIT
| Doc PR        | n/a

Commits
-------

419e934 Proposing Flex-specific error messages in the controller shortcuts
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull request Jan 3, 2018
…tcuts to 3.4 (weaverryan)

This PR was merged into the 3.4 branch.

Discussion
----------

Backport Flex-specific error messages in controller shortcuts to 3.4

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | symfony/symfony#25133 (comment)
| License       | MIT
| Doc PR        | n/a

Commits
-------

419e93465f Proposing Flex-specific error messages in the controller shortcuts
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.

10 participants