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
Twig 1.x interprets whitespace differently under PHP 7.4 #3248
Comments
The template you use seems to have Whichi implementation of |
It might be easier to constrain the problem to vichan-devel/vichan#366, which was closed by vichan-devel/vichan@01538ed, though I suspect vichan-devel/vichan#367 has the same root cause. The entire However, to answer your question lest I appear defensive, we use php-gettext, a pure PHP gettext implementation, and then regular PoEdit-compatible gettext files. |
which exact version of Twig are you using ? |
Sorry for the delay, took me a bit to figure out how to answer that definitively. We use all vendorized dependencies (our software predates Composer by two years). |
I suppose you would have me update Twig to the latest version in the 1.x branch and report back, yes? If that's a hard requirement for getting help I'll do it but the update is not easy, since, as I said, we use all vendorized dependencies with our own patches applied on top. |
(The patches are all in the |
Are you sure that the behaviour changes are not in fact related to your patches? Can you reproduce the same with an unpatched version of Twig? |
btw, why are you using your own patches if they are about registering extensions ? Twig does not require extensions to be part of Twig itself (quite the opposite). |
I hear you guys. I am preparing a minimal example right now. I just need to install PHP 7.3 alongside PHP 7.4 to demonstrate the difference in output. That way you don't need to worry about our hackery. |
OK friends, here you go. Observe:
composer.json{
"require": {
"twig/twig": "1.35.4"
}
} issue3248.php<?php
require_once __DIR__ . '/vendor/autoload.php';
$loader = new \Twig\Loader\ArrayLoader([
'index' => "<span {% if name.boo %}{{name.name}} {% endif %}class=\"name\">\n",
]);
$twig = new \Twig\Environment($loader);
echo $twig->render('index', ['name' => array("name" => 'Fabien')]);
?> |
I can confirm the issue with your example on Twig 1.35.4. But when changing the version constraint to |
@xabbuh I understand. Thank you for your time. I don't know when I'll get a chance to do that. As I see it, the problem is in the interpreter. But they don't like to hear that. |
well, #3004 contains a fix for the compatibility of Twig with PHP 7.4. That's why using the latest Twig version is important when reporting issues (fixes will always be based on top of the latest version anyway, so upgrading would also be necessary to get the fixes). I'm closing this issue as it is already fixed in the latest 1.x version. |
This issue will at least help Googlers, and serve as yet further evidence of the supremely bad decision making being made at the interpreter level. Mission accomplished if you ask me. I'll either cherry pick #3004 on top of 1.35.4, or do an upgrade to 1.4. |
Just wanted to note that for some reason, upgrading to 1.43.1 didn't solve this issue. Applying the minimal example from above to my case, I do get the correct behavior, but in the context of my entire code base, the behavior changes. I don't have enough time right now to follow this up further, I'll revert back to using PHP 7.3 on that specific project and investigate later. My minimal example (which works with php7.4-cli, but not php7.4-fpm:
For cli, this produces
and for fpm, I'm still seeing this in the generated PHP file:
I have restarted |
@kwisatz please open a new issue, providing a reproducing case (your comment does not provide such a case, as your snipped for the php-fpm generated file involves a loop and so it is definitely not the output of compiling your minimal example) |
No, it's not a valid minimal example for my problem, it was just applying the above example to my case (without the loop) and noticing that it's not reproducing the issue. I'll open a new ticket when I get around to producing a valid minimal example that does recreate my issue. I was kinda hoping someone would point out the obvious oversight in what I did and that'd be it. |
See vichan-devel/vichan#366 and vichan-devel/vichan#367
I wonder, is this a known issue?
The text was updated successfully, but these errors were encountered: