Skip to content

[TwigBridge] lint all templates from configured Twig paths if no argument was provided #33446

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
Sep 3, 2019

Conversation

yceruto
Copy link
Member

@yceruto yceruto commented Sep 3, 2019

Q A
Branch? 4.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #33443
License MIT
Doc PR -

All details in PR title and related issue #33443.

@fabpot
Copy link
Member

fabpot commented Sep 3, 2019

Thank you @yceruto.

fabpot added a commit that referenced this pull request Sep 3, 2019
…aths if no argument was provided (yceruto)

This PR was merged into the 4.4 branch.

Discussion
----------

[TwigBridge] lint all templates from configured Twig paths if no argument was provided

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

All details in PR title and related issue #33443.

Commits
-------

baddf1d lint all templates from configured Twig paths if no argument was provided
@fabpot fabpot merged commit baddf1d into symfony:4.4 Sep 3, 2019
@yceruto yceruto deleted the lint_twig branch September 3, 2019 16:15
@nicolas-grekas
Copy link
Member

nicolas-grekas commented Sep 5, 2019

There's a conflict here: when no argument was provided, the command also reads from STDIN.
So now, it reads from STDIN, and if there is nothing there, reads from the default template.
This has been caught in php/php-src#4672

This creates an ambiguous situation - maybe one did pipe nothing but doesn't expect the default template dir to be linted.

I'd suggest resolving the ambiguity by reading from STDIN only when explicitly asked for. Passing - as argument could the way. And we could trigger a deprecation for now.

@nicolas-grekas
Copy link
Member

I think we should revert this and trigger the deprecation instead...
Then in 5.0 we would introduce this behavior.

@yceruto
Copy link
Member Author

yceruto commented Sep 5, 2019

Maybe resolved by php/php-src#4684 ?

Not sure also if reverting is the solution... because before these changes this statement 0 !== ftell(STDIN) is always called if no dir or file was provided, the difference from now on is that you have a test case. If there is something to fix, I guess it should be target to 3.4 branch?

@nicolas-grekas
Copy link
Member

Ok cool. Thanks for having a look.

@nikic
Copy link
Contributor

nikic commented Sep 6, 2019

How is this code actually supposed to work? Under what circumstances do you want to use the stdin input and when not? Should it be used only with < or also with |? The aforementioned php-src commit will make it so the stdin codepath is only used for the < case, but not for | or tty. Previously (I think) stdin would have been read for | as well, and ttys on Windows.

@nikic
Copy link
Contributor

nikic commented Sep 6, 2019

Test is still hanging despite the change: https://dev.azure.com/phpazuredevops/PHP/_build/results?buildId=2477

@nikic
Copy link
Contributor

nikic commented Sep 6, 2019

Unfortunately I'm not able to reproduce this issue locally. I've tried various variations of what to attach to stdin, but nothing produces the hang we see on azure.

Possibly this just needs a @group tty on the test.

@nicolas-grekas
Copy link
Member

tty group added in #33490

nicolas-grekas added a commit that referenced this pull request Sep 6, 2019
…olas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[Bridge/Twig] use tty group on testLintDefaultPaths

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #33446 (comment)
| License       | MIT
| Doc PR        | -

Note that I still think we should deprecate reading from STDIN when not explicitly asked for, as explained in #33446 (comment)

Commits
-------

3c59bb5 [Bridge/Twig] use tty group on testLintDefaultPaths
fabpot added a commit that referenced this pull request Sep 8, 2019
…ds (yceruto)

This PR was merged into the 4.4 branch.

Discussion
----------

Deprecated not passing dash symbol (-) to STDIN commands

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #33446 (comment)
| License       | MIT
| Doc PR        | -

Follow-up #33446

> There's a conflict here: when no argument was provided, the command also reads from STDIN.
So now, it reads from STDIN, and if there is nothing there, reads from the default template.
This has been caught in php/php-src#4672

> This creates an ambiguous situation - maybe one did pipe nothing but doesn't expect the default template dir to be linted.

> I'd suggest resolving the ambiguity by reading from STDIN only when explicitly asked for. Passing - as argument could the way. And we could trigger a deprecation for now.

For consistency, the other 2 lint commands (`lint:yaml` and `lint:xliff`) have been touched as well.

The plan for 5.0 is read from the STDIN only when `-` is given.

/cc @nicolas-grekas

Commits
-------

586f299 deprecated not passing dash symbol (-) to STDIN commands
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
This was referenced Nov 12, 2019
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.

5 participants