Skip to content

[TwigComponent] Restrict anonymous component lookup to Twig files in debug command #1882

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

Conversation

squrious
Copy link
Contributor

@squrious squrious commented Jun 3, 2024

Q A
Bug fix? yes
New feature? no
Issues
License MIT

Hi!

The debug:twig-component command looks for files in the anonymous template directory, but fails if some files are actually not Twig components (like .md).

For example, with a README.md file in templates/components:

$ php bin/console debug:twig-component 
[critical] Error thrown while running command "debug:twig-component". Message: "Unknown component "README.md". And no matching anonymous component template was found."

In ComponentFactory.php line 254:
                                                                                          
  Unknown component "README.md". And no matching anonymous component template was found.  
                                                                                          

debug:twig-component [<name>]

This PR restricts the finder to *.html.twig files, so others are ignored.

@carsonbot carsonbot added Bug Bug Fix TwigComponent Status: Needs Review Needs to be reviewed labels Jun 3, 2024
@@ -0,0 +1 @@
This file should not cause issues with the debug:twig:component command.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a case in TwigComponentDebugTest that check NotAComponent is not listed ?

(like the testWithNoMatchComponent test ?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

Copy link
Member

@smnandre smnandre left a comment

Choose a reason for hiding this comment

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

Thank you @squrious ! 😄

@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Jun 4, 2024
@kbond kbond force-pushed the twig-component/fix-debug-command-with-non-template-files branch from d702a7b to df82b4a Compare June 6, 2024 23:10
@kbond
Copy link
Member

kbond commented Jun 6, 2024

Thank you Nicolas.

@kbond kbond merged commit 673279f into symfony:2.x Jun 6, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix Status: Reviewed Has been reviewed by a maintainer TwigComponent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants