Skip to content
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

[TwigBundle] fix broken FilesystemLoader::exists() with Twig 3 #34878

Merged
merged 1 commit into from Dec 11, 2019

Conversation

dpesch
Copy link
Contributor

@dpesch dpesch commented Dec 8, 2019

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #34877
License MIT
Doc PR

This fix adapts the declaration of Twig 3 \Twig\Loader\FilesystemLoader::findTemplate() which expects to return string|null and returns null instead of false.

Returning false breaks \Twig\Loader\FilesystemLoader::exists() which returns true if findTemplate() does not return null.

Twig 2 should not be affected by this patch. The exists() method expects null or false for not found templates: https://github.com/twigphp/Twig/blob/fdb691a424682a524555f73b2c665c06971c4ed5/src/Loader/FilesystemLoader.php#L169

@dpesch dpesch changed the title Fix for Issue34877 [TwigBundle] Fix #34877 Dec 8, 2019
@dpesch dpesch changed the title [TwigBundle] Fix #34877 [TwigBundle] Fix #34877 – TwigBundle FilesystemLoader::exists() breaks with Twig3 Dec 8, 2019
@nicolas-grekas nicolas-grekas changed the title [TwigBundle] Fix #34877 – TwigBundle FilesystemLoader::exists() breaks with Twig3 [TwigBundle] fix broken FilesystemLoader::exists() with Twig 3 Dec 9, 2019
@nicolas-grekas nicolas-grekas added this to the 4.4 milestone Dec 9, 2019
@nicolas-grekas
Copy link
Member

@dpesch can you please squash your PR? I cannot do it as you did allow pushing on your fork.

Twig3 FilesystemLoader::findTemplate() should return `string|null`
instead of Twig2 `string|null|false`: see
<https://github.com/twigphp/Twig/blob/3.x/src/Loader/FilesystemLoader.php#L167>

Returning `null` fixes `exists()` of Twig 3 FilesystemLoader without
breaking Twig 2 (which expected `null` or `false` for not found
templates).

Change the test to assert `null` instead of `false`.
@dpesch
Copy link
Contributor Author

dpesch commented Dec 10, 2019

@nicolas-grekas Thank you for your message. Is it better now? And how could/should I make it better? Should Allow edits from maintainers. be turned off?

@nicolas-grekas
Copy link
Member

Thanks. It should be turned on actually.

@fabpot
Copy link
Member

fabpot commented Dec 11, 2019

Thank you @dpesch.

fabpot added a commit that referenced this pull request Dec 11, 2019
…ig 3 (dpesch)

This PR was merged into the 4.4 branch.

Discussion
----------

[TwigBundle] fix broken FilesystemLoader::exists() with Twig 3

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #34877
| License       | MIT
| Doc PR        |

This fix adapts the declaration of Twig 3 `\Twig\Loader\FilesystemLoader::findTemplate()` which expects to return `string|null` and returns `null` instead of `false`.

Returning `false` breaks `\Twig\Loader\FilesystemLoader::exists()` which returns `true` if `findTemplate()` does not return `null`.

Twig 2 should not be affected by this patch. The `exists()` method expects `null` or `false` for not found templates: <https://github.com/twigphp/Twig/blob/fdb691a424682a524555f73b2c665c06971c4ed5/src/Loader/FilesystemLoader.php#L169>

Commits
-------

ff1d77e bug #34877 [TwigBundle] fix findTemplate() to return `null`
@fabpot fabpot merged commit ff1d77e into symfony:4.4 Dec 11, 2019
This was referenced Dec 19, 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.

None yet

4 participants