I have just updated twig/twig (v1.37.1 => v1.38.0) via composer and get a fatal error with the following in the Apache error log:
Got error 'PHP message: PHP Fatal error: Declaration of Drupal\\Core\\Template\\TwigTransTokenParser::parse(Twig_Token $token) must be compatible with Twig\\TokenParser\\TokenParserInterface::parse(Twig\\Token $token) in /var/www/html/web/core/lib/Drupal/Core/Template/TwigTransTokenParser.php on line 0\nPHP message: PHP Stack trace:\nPHP message: PHP 1. {main}() /var/www/html/web/index.php:0\nPHP message: PHP 2. Drupal\\Core\\DrupalKernel->handle() /var/www/html/web/index.php:19\nPHP message: PHP 3. Stack\\StackedHttpKernel->handle() /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php:693\nPHP message: PHP 4. Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle() /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php:23\nPHP message: PHP 5. Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle() /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php:52\nPHP message: PHP 6. Asm89\\Stack\\Cors->handle() /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php:47\nPHP message: PHP 7. Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle() /var/www/html/vendor/asm89/stack-cors/src/Asm89/Stack/Cors.php:49\nPHP message: PHP 8. Drupal\\Core\\StackMiddleware\\Session->handle() /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php:47\nPHP message: PHP 9. Symfony\\Component\\HttpKernel\\HttpKernel->handle() /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php:57\nPHP message: PHP 10. Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw() /var/www/html/vendor/symfony/http-kernel/HttpKernel.php:68\nPHP message: PHP 11. Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher->dispatch() /var/www/html/vendor/symfony/http-kernel/HttpKernel.php:156\nPHP message: PHP 12. call_user_func:{/var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php:111}() /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php:111\nPHP message: PHP 13. Drupal\\Core\\EventSubscriber\\MainContentViewSubscriber->onViewRenderArray() /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php:111\nPHP message: PHP 14. Drupal\\Core\\Render\\MainContent\\HtmlRenderer->renderResponse() /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php:90\nPHP message: PHP 15. Drupal\\Core\\Render\\MainContent\\HtmlRenderer->prepare() /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php:117\nPHP message: PHP 16. Drupal\\Core\\Render\\Renderer->executeInRenderContext() /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php:227\nPHP message: PHP 17. Drupal\\Core\\Render\\MainContent\\HtmlRenderer->Drupal\\Core\\Render\\MainContent\\{closure}() /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php:582\nPHP message: PHP 18. Drupal\\Core\\Render\\Renderer->render() /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php:226\nPHP message: PHP 19. Drupal\\Core\\Render\\Renderer->doRender() /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php:195\nPHP message: PHP 20. call_user_func:{/var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php:378}() /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php:378\nPHP message: PHP 21. Drupal\\node\\Controller\\NodeViewController->buildTitle() /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php:378\nPHP message: PHP 22. Drupal\\Core\\Render\\Renderer->render() /var/www/html/web/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php:73\nPHP message: PHP 23. Drupal\\Core\\Render\\Renderer->doRender() /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php:195\nPHP message: PHP 24. Drupal\\Core\\Theme\\ThemeManager->render() /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php:437\nPHP message: PHP 25. twig_render_template() /var/www/html/web/core/lib/Drupal/Core/Theme/ThemeManager.php:384\nPHP message: PHP 26. Drupal\\Core\\Template\\TwigEnvironment->loadTemplate() /var/www/html/web/core/themes/engines/twig/twig.engine:64\nPHP message: PHP 27. Drupal\\Core\\Template\\TwigEnvironment->loadClass() /var/www/html/vendor/twig/twig/src/Environment.php:446\nPHP message: PHP 28. Drupal\\Core\\Template\\TwigEnvironment->compileSource() /var/www/html/vendor/twig/twig/src/Environment.php:482\nPHP message: PHP 29. Drupal\\Core\\Template\\TwigEnvironment->tokenize() /var/www/html/vendor/twig/twig/src/Environment.php:792\nPHP message: PHP 30. Twig\\Lexer->__construct() /var/www/html/vendor/twig/twig/src/Environment.php:692\nPHP message: PHP 31. Twig\\Lexer->getOperatorRegex() /var/www/html/vendor/twig/twig/src/Lexer.php:72\nPHP message: PHP 32. Drupal\\Core\\Template\\TwigEnvironment->getUnaryOperators() /var/www/html/vendor/twig/twig/src/Lexer.php:389\nPHP message: PHP 33. Drupal\\Core\\Template\\TwigEnvironment->initExtensions() /var/www/html/vendor/twig/twig/src/Environment.php:1454\nPHP message: PHP 34. Drupal\\Core\\Template\\TwigEnvironment->initExtension() /var/www/html/vendor/twig/twig/src/Environment.php:1533\nPHP message: PHP 35. Drupal\\Core\\Template\\TwigExtension->getTokenParsers() /var/www/html/vendor/twig/twig/src/Environment.php:1579\nPHP message: PHP 36. spl_autoload_call() /var/www/html/web/core/lib/Drupal/Core/Template/TwigExtension.php:207\nPHP message: PHP 37. Composer\\Autoload\\ClassLoader->loadClass() /var/www/html/web/core/lib/Drupal/Core/Template/TwigExtension.php:207\nPHP message: PHP 38. Composer\\Autoload\\includeFile() /var/www/html/vendor/composer/ClassLoader.php:322\n'
Comment | File | Size | Author |
---|---|---|---|
#103 | 3039408-8.5.x-103.patch | 9.98 KB | alexpott |
#101 | 3039408-83.patch | 6.89 KB | alexpott |
#101 | 3039408-81.patch | 10.32 KB | alexpott |
#99 | 3039408-99.patch | 7.11 KB | pdenooijer |
#98 | 3039408-92-do-not-test.patch | 7.84 KB | kfritsche |
Comments
Comment #2
rmpereira CreditAttribution: rmpereira as a volunteer commentedSame problem, i exec the composer command :
The twig/twig component has been updated from version 1.37.1 to 1.38.0.
I come back temporarily to 1.37.1 version and it's work for me ...
Comment #3
lisagodareI'm also having the same issue. As I have a very limited amount of time to perform maintenance updates, I have temporarily set the twig version in composer to 1.37.1 as a workaround.
Comment #4
tstoecklerHere's an initial patch that updates to 1.38 in composer.lock and fixes the typehints. I'm not sure what this means in terms of backwards compatibility, i.e. I think this patch makes us incompatible with 1.35, but not sure.
Comment #5
Gábor HojtsyWoah, how did this happen in Twig 1.38 in the first place?
Comment #6
Ben25 CreditAttribution: Ben25 commentedrolling back to 1.37.1 is the quickest fix.
Comment #7
rgpublicIt seems they renamed the class name "Twig_Token" to "Twig\Token". Which makes sense to me in some way, because the namespaced variant instead of the prefixed version is more standards-conformant. Or, I guess, they removed the aliasing. The Twig_Token class name seems to be deprecated for some time. Why they changed this in a 1.37 => 1.38 minor version update I dont know. Of course, all code that relied on this is failing now. That's my take on this. If someone as more info on this, I'd be glad to know.
Comment #8
Eli-TSeems relevant: https://github.com/twigphp/Twig/issues/2886
Comment #9
lluisandreu CreditAttribution: lluisandreu commentedHello, how can I rollback Twig in a Composer project Drupal?
Thanks.
Comment #10
matzAB CreditAttribution: matzAB as a volunteer commented@lluisandreu
composer require twig/twig:1.37.1
Comment #11
hkirsman CreditAttribution: hkirsman commented@lluisandreu I did:
composer require twig/twig:1.37.1
and removed if from composer.json
Comment #12
iuana CreditAttribution: iuana at Softescu commentedIndeed, I rolled back the version of twig/twig by running
composer require "twig/twig:1.37.1"
Comment #13
EliasPapa CreditAttribution: EliasPapa as a volunteer commentedYup running
composer require twig/twig:1.37.1
seems to fix the issue by downgrading twig to that version. Lets hope they fix it soon. Thanks for creating the thread, was going crazy there for a sec.Comment #14
huzookaSince the issue is with Twig (see https://github.com/twigphp/Twig/issues/2886 ), the solution is conflicting with twig/twig 1.38.0 IMHO
And since the issue exists in the 8.7.x branch as well (i was working with that), the first step is check that the issue exists in 8.8.x
Comment #15
Gábor Hojtsy@rgpublic well these kind of changes would be perfectly valid in Twig 3 (unreleased). For Twig 1 and 2 (released), backwards compatibility should be kept. Work is happening in this pull request to fix it for Twig 1: https://github.com/twigphp/Twig/pull/2887/commits/65c0559125c5d11b96162b...
Comment #16
hiramanpatil CreditAttribution: hiramanpatil commentedroll back the version "twig/twig:1.37.1" worked...thanks!
Comment #17
ajay547 CreditAttribution: ajay547 as a volunteer and commentedConfirmed #16, its working.
Comment #18
donaldp CreditAttribution: donaldp commentedI can confirm that rolling back to twig 1.37.1 fixes the issue:
The problem seems to this:
In Drupal:
public function parse(\Twig_Token $token) {..}
vs
in twig v1.38.0:
public function parse(Token $token);
in twig v1.37.1: it's defined very differently as :
Comment #19
alunyov CreditAttribution: alunyov at EPAM Systems commentedThat worked for me as temporary fix:
composer require twig/twig:1.37.1
Comment #20
Lukas von BlarerDowngrading Twig to 1.37.1 solves the issue. The patch in #4 doesn't apply to 8.6.10. So if anyone needs a urgent fix go with changing the composer version constraints for twig/twig.
Comment #21
huzookaUntestable patch against 8.8.x.
Comment #22
tstoecklerSorry, my patch was on 8.7.x, not 8.6.x.
I think #21, as well as pinning 1.37, is problematic, because 1.38 is actually a security release per https://github.com/FriendsOfPHP/security-advisories/commit/e5783d3116527...
As a temporary measure I did this for my site as well, but I think we should update as soon as possible in core.
Comment #23
tstoecklerOops, version change was unintended. Although I think 8.6.x is the correct version to target here.
Comment #24
WidgetsBurritos CreditAttribution: WidgetsBurritos at Rackspace commentedLooks like they've just merged and bumped the release that fixes this issue:
https://github.com/twigphp/Twig/pull/2887
Seems to work for me locally.
Comment #25
Ben25 CreditAttribution: Ben25 commentedfixed https://packagist.org/packages/twig/twig#v1.38.1
Comment #26
pstewart CreditAttribution: pstewart commentedI picked up the 1.38.1 twig upgrade but then ran into a different error viewing the previously working homepage of my d8 site:
I'm guessing the template in question has a fault but something may have gone wrong with exception handling following the namespace change that seems to have been introduced with 1.38.0 despite the fix with 1.38.1. I've reverted to 1.37.1 as per earlier comments and everything is now working again for me.
Comment #27
timmillwoodI am seeing the same issue as #26.
Comment #28
kfritscheI can confirm this, with 1.38.1 and the seven core theme I get the same error on the node/add page.
URL: /node/add
Theme: seven
Error:
Comment #29
Gábor HojtsyComment #30
kfritscheThat class (CheckToStringNode ) which throws an error in Twig was introduced with 1.38.0 and was part of the security fix mentioned by #22 (https://github.com/twigphp/Twig/commits/1.x/src/Node/CheckToStringNode.php).
material_admin theme is affected too.
Comment #31
phenaproximaConfirming this is still broken for me as well, with the same error @kfristche reports in #28. In my case, the errors are coming from Views, but I think it's likely the same problem (see https://travis-ci.org/acquia/headless-lightning/jobs/505306749#L2353 for a partial backtrace).
Comment #32
vijaycs85Reported back to upstream https://github.com/twigphp/Twig/issues/2889#issuecomment-472091921
Comment #33
fabpot CreditAttribution: fabpot commentedI would need to debug this issue, I have added some questions on the related Twig issue.
Comment #34
fabpot CreditAttribution: fabpot commentedI would need help to debug this issue, I have added some questions on the related Twig issue.
Comment #35
fabpot CreditAttribution: fabpot commentedCan you tell me how to reproduce? I've checkout-ed Drupal, updated Twig, everything seem to work. I've then updated everything (composer up), and it does not break for me.
Comment #36
Corn696composer create-project drupal-composer/drupal-project:8.x-dev some-dir --stability dev --no-interaction
create database
install drupal following the setup wizard. (I used english as language)
visit page -> get unexpected error
On a existing site with stable as base theme in use the site is accessible. But seven admin theme throws errors on node/add and in the frontend the mini pager of a view as well.
Comment #37
mikelutzPatch against 8.6 for testing.
Comment #38
vijaycs85Not sure what this would break in terms of functionality, but it doesn't throw the exception anymore.
Comment #39
WidgetsBurritos CreditAttribution: WidgetsBurritos at Rackspace commented@vijaycs85 obviously we need to see what happens with the tests, but there is another reference to $args->getAttribute('name') further up in that file. Does that one need a try/catch as well?
Comment #40
fabpot CreditAttribution: fabpot commentedHere is a patch for you to test:
Add
if ($n instanceof \Twig\Node\CheckToStringNode) {
$n = $n->getNode('expr');
}
Before
$args = $n;
in TwigNodeTrans.php at line 116
Comment #41
vijaycs85Here is the patch with composer.lock file changes as well (thanks to @mikelutz).
Comment #42
phenaproximaHere is another possible fix I came up with (calling hasAttribute() before getAttribute()), and another patch that implements @fabpot's solution. Let's see how these do. Lucky 42!
Comment #43
dnebrich CreditAttribution: dnebrich commentedI just tested fabpot's patch from comment #40. It worked for me. I did not apply any other patches referenced in this issue.
I have drupal 8.6.10, I upgraded twig to 1.38.0, saw the issue, then upgraded twig to 1.38.1, got the new exception mentioned in #31, then applied fabpot's patch and all is well now.
Comment #44
ressa CreditAttribution: ressa at Ardea commentedThanks @fabpot, your suggestion in #40 fixed the problem for me.
Comment #45
phenaproximaSounds like 3039408-42-CheckToStringNode.patch in #42 (which implements @fabpot's solution) is tentatively RTBC...
Comment #47
ressa CreditAttribution: ressa at Ardea commentedThanks @phenaproxima, I just tried your patches from #42, and they also work well.
Comment #48
vijaycs85Found few failures for patch in #42(3039408-42-CheckToStringNode.patch):
Checking locally.
Comment #50
vijaycs85Fixed
Drupal\Tests\system\Functional\Theme\TwigRegistryLoaderTest
. All others all locally green, not sure if the errors are because of deprication notices.Comment #52
websiteworkspace CreditAttribution: websiteworkspace commentedI'm seeing this major and critical error/problem too!
composer automatically updated twig to version 1.38.2 and it is breaking all updated Drupal 8 websites!
(thank goodness for nightly automated backups ... )
There is a note in the change log for twig!
The fatal error and thrown exception occurs in the following class and method
{site}/vendor/twig/twig/src/Node/CheckToStringNode.php
Consider the following ...
Thousands of Drupal 8 users ran a routine code update check script and update code script today, and discovered this critical error.
Then each of those thousands of Drupal 8 users each lost and hour, or hours, of their day, tracking down this problem.
... tens of thousands of person work hours squandered, down the drain ...
Comment #53
phenaproximaWe can't always anticipate every possible change that our upstream dependencies might make. The risk of things breaking is part and parcel of software development, but detecting these kinds of problems is exactly why we write tests, and when things do break, we try to fix them as quickly as possible. (That's why this issue is marked critical.) We're all aware of this problem and we're doing our best to fix it, and not all of us are being paid for that work. Please try to be understanding.
Comment #54
Gábor Hojtsy@websiteworkspace: if you are automatically updating to third party dependencies when their new versions come out without testing them, then worse problems could arise. Drupal core includes a composer.lock file that specifies tested dependencies. We are running test suites on them every minute of every day. When we update our composer.lock-ed dependencies, we test them first. Since you are not relying on core's composer.lock, you can also use https://github.com/webflo/drupal-core-strict to achieve the same.
Comment #55
websiteworkspace CreditAttribution: websiteworkspace commentedThe purpose of my comment was/is to express "understanding", as well as empathy, for the likely thousands of people who've found themselves fighting this emergency fire/problem today.
Please try to be understanding.
Comment #56
websiteworkspace CreditAttribution: websiteworkspace commentedHow does one configure a Drupal 8 site's composer.json to "rely on core's composer.lock" file?
Where on drupal.org is there an article about how to implement such a configuration for a Drupal 8 site and its composer.json file?
Might it make sense for the following approach:
to be a standard aspect/component of Drupal 8 deployments, and its associated scripts, requirements, and dependencies?
Please try to be understanding.
Comment #57
vijaycs85after a couple of hours of xdebug, found another missing scenario. automated_tests++
Comment #58
pandaski CreditAttribution: pandaski at govCMS (Australian Government Department of Finance) commented#57 works well, doing more testing now
Comment #60
vijaycs85We got 2 fails left.
I am running locally and getting fails on both, but no error at all. e.g:
Comment #61
vijaycs85Another test fix.
Comment #62
vijaycs85Fixing all 4 depreciation notices.
Comment #64
jibranComment #65
pandaski CreditAttribution: pandaski at govCMS (Australian Government Department of Finance) commentedThe quickest/temp fix is to add the trouble version to the conflict section of `core/composer.json`
Comment #67
vijaycs85Fixing one last fail in #62
#65: worth noting, It might not work, if you use roave/SecurityAdvisories
Comment #68
WidgetsBurritos CreditAttribution: WidgetsBurritos at Rackspace commentedNoticed #67 had a few minor code style issues.
Adding this patch to fix them, to help move this along.
Comment #69
pandaski CreditAttribution: pandaski at govCMS (Australian Government Department of Finance) commentedQuick question:
Do we have a reason to update other packages in `composer.lock` file? Are they required by Twig?
Comment #70
mikelutzUnfortunately, #68 will fail when applied without the composer lock changes, as CheckToStringNode did not exist before twig 1.38.0. The patch needs to work with the current dependencies and future versions of twig. We need passing tests both with and without the composer lock changes.
Comment #71
joelpittet@Joseph Zhao, yes because that is when the CheckToStringNode was introduced.
@mikelutz The tests pass already without the lock changes if you don't update Twig, do we really need to get them passing for when "you don't update Twig" because to get these changes you'd need to update Drupal already and you only run into this problem when you update Twig.
We should bump the minimum version of Twig though for this in composer.json and I assume @vijaycs85 was just doing the lock changes to ensure the testbot was testing the right version of Twig.
Comment #72
WidgetsBurritos CreditAttribution: WidgetsBurritos at Rackspace commentedI don't think the comment in #70 is true. Since CheckToStringNode is only ever being used with instanceof, I don't think the library doesn't actual needs it. See http://php.net/manual/en/internals2.opcodes.instanceof.php#108164
As it would return false in that instance, it will behave like it did already.
Comment #73
WidgetsBurritos CreditAttribution: WidgetsBurritos at Rackspace commentedFor testing purposes, here's the patch without the composer.lock changes.
Comment #74
mikelutzTwig 1.38 was a security update, so maybe the committers and security team will want to force the dependency update with the next release, in which case you do need to bump the minimum version in the composer json and get buy-in from RM/FM/security team folks.
WidgetsBurritos: tricky. USEing a non-existent file will throw an exception in the symfony4 test thread, but it might not here. Curious now if it passes.
Comment #75
WidgetsBurritos CreditAttribution: WidgetsBurritos at Rackspace commented@mikelutz yeah, I dunno for sure. I guess we'll find out soon. :-)
Comment #76
WidgetsBurritos CreditAttribution: WidgetsBurritos at Rackspace commentedIt's not quite done yet, but taking an earlier peak at the test runner, it looks like the changes made to TwigNamespaceTest are going to be problematic as its returning a Twig_Template instance instead of a TemplateWrapper instance.
Comment #77
WidgetsBurritos CreditAttribution: WidgetsBurritos at Rackspace commentedThis patch should resolve the issues with both TwigNamespaceTest and TwigRegistryLoaderTest. For testing purposes, I've included the patch both with and without the composer.lock file updates.
Comment #78
alexpottThanks everyone for jumping on this.
@mikelutz is right we need to update core/composer.json to have
"twig/twig": "^1.38.1",
. We need to change the lock file on this issue too.Comment #79
pandaski CreditAttribution: pandaski at govCMS (Australian Government Department of Finance) commentedLooks like Twig had three releases v1.38.0, v1.38.1 and v1.38.2 this morning (https://github.com/twigphp/Twig/releases)
And v1.38.2 is the latest one (https://github.com/twigphp/Twig/releases/tag/v1.38.2)
Changelog: https://github.com/twigphp/Twig/blob/2.x/CHANGELOG
Comment #80
WidgetsBurritos CreditAttribution: WidgetsBurritos at Rackspace commentedPer @Joseph Zhao's feedback, my last patch actually updated the lock file to 1.38.2 instead of 1.38.1 anyway. Any objections here?
Also should the update to composer.json be based on #68 instead of #77 then?
Comment #81
WidgetsBurritos CreditAttribution: WidgetsBurritos at Rackspace commentedI went ahead and based the patch on #68 as it's a forced dependency here.
Comment #82
alexpottWe're going to need an 8.7.x/8.8.x patch too and they have some changes for Twig 2 compatibility already so the fix might become smaller.
Comment #83
pandaski CreditAttribution: pandaski at govCMS (Australian Government Department of Finance) commented#81,
Shall we leave this line to "phpunit/phpunit-mock-objects" issue?
Comment #84
alexpottHere's a patch for 8.7.x / 8.8.x
@Joseph Zhao nope we should not hand craft our composer.lock file.
Comment #85
alexpottThis changes are not strictly necessary for 8.7.x/8.8.x but keeping them inline with 8.6.x is a good thing and using the namespaced function is a good idea.
Comment #86
Nick Hope CreditAttribution: Nick Hope commentedRe. #81, Composer is telling me it cannot apply https://www.drupal.org/files/issues/2019-03-12/3039408-81.patch to D8.6.10.
Comment #87
jibranPatch looks good now.
Comment #88
jibranComment #89
pandaski CreditAttribution: pandaski at govCMS (Australian Government Department of Finance) commentedWe have another file `TwigExtension.php` containing many usages of `new \Twig_SimpleFunction` and `new \Twig_SimpleFilter`.
Maybe we can put a post-task so we can keep the same style for the functions and styles.
Also tested the patch for 8.8.x in the local instance, looks good to me RTBC +1
Comment #90
dtv_rb CreditAttribution: dtv_rb commentedPatch #81 cannot be applied to my Drupal 8.6.10 core. Updated from Twig 1.37.1 to 1.38.2 a few hours ago.
Comment #91
jurgenhaasAlso 8.6.10 and patch from #81: composer outputs an error message about not being able to apply the patch (same as #86, but when checking the files, the patch got applied correctly and it does solve the problem.
Comment #92
dtv_rb CreditAttribution: dtv_rb commented@jurgenhaas
It's because the changes to the composer.lock and core/composer.json files could not be applied. Mine looked different than these in the patch.
What I did: I saved the patch file #81 to my system and removed the changes to composer.lock and core/composer.json.
Now the patch applies and there are no Twig Errors any more.
Hope that fixes it.
@WidgetsBurritos
It would be great if you could provide a separate patch without the changes to the composer files!
Comment #93
Nick Hope CreditAttribution: Nick Hope commented+1 #91.
However the case of
"email": "BackEndTea@gmail.com"
is failing to change to"email": "backendtea@gmail.com"
, so perhaps that might be triggering the "could not apply" error in Composer.Comment #94
jurgenhaas@dtv_rb thanks for the explanation. In my case, I just ignored the composer error because it did what was necessary and the process doesn't fail. It's just the irritating message but everything else is fine.
Comment #95
xjmComment #96
xjmThis will need a separate patch for the 8.6.x backport, which should resolve a lot of the questions above about it not applying to 8.6. (Composer config changes almost always need separate patches per minor branch.)
Comment #97
pdenooijer CreditAttribution: pdenooijer at Ordina Digital Services for RTL Nieuws commentedRemoved the local composer.lock changes from #81 as this will give the errors about not being able to apply the patch. This assumes that the composer.lock is in the docroot and it should be updated with composer it self not with a patch.
Comment #98
kfritschePatch from #81 seems to work for 8.6.10.
I attach a new patch (as do not test) which should work for people using composer and/or drupal-composer/drupal-scaffold. As there you only have the core directory and do not have the composer.lock. Thats why the patch fails. Its the same as #81 just without the composer.lock changes. For core to commit #81 is still correct.
As I did the work now for myself, just wanted to share for people to use, till 8.6.11(?) is released.
Comment #99
pdenooijer CreditAttribution: pdenooijer at Ordina Digital Services for RTL Nieuws commentedUpdated #97 with the right patch paths.
Comment #100
frondeau CreditAttribution: frondeau commentedTwig 1.38.2 doasn't resolve issue in Drupal 8. My version is back to 1.37.1.
Comment #101
alexpottThanks everyone for supplying patches for your local sites but doing so creates problems because then the rtbc retest is not going to be testing the correct thing. Also it make the issue super confusing. Another solution is to create another issue and link to it from here - mark in a duplicate but still use it.
Uploading the correct patches again so they are last on the issue.
Comment #102
alexpott@informaid after applying the patch you have to run
composer update twig/twig
- if you are not using composer to manager your code then you need to wait for a release.Comment #103
alexpottHere's a patch for 8.5.x as well.
Comment #104
dtv_rb CreditAttribution: dtv_rb commented@alexpott Patch #81 doesn't apply correctly for people with different composer.json or composer.lock files than in the patch. I was upgrading from Twig 1.37.1 to 1.38.2. The patch relies on upgrading from 1.35.4 to 1.38.2 in core/composer.json. So it can't really be marked as RTBC.
Comment #105
alexpott@dtv_rb the patch changes our root composer.lock if you have made customisations to your root composer.json which will result in a new composer.lock then it is on you to manage applying the patch. We have to update the composer.lock in this or Drupal's tarball will be not be updated. In an ideal world we would not ship a composer.lock file but that's for a completely separate issue and has a whole initiative involved in trying to resolve it. You can apply patches with git and use the
--exclude=composer.lock
option and then runcomposer update twig/twig
and everything will work for you.Comment #106
dtv_rb CreditAttribution: dtv_rb commented@alexpott Thanks for the clarification! :)
Comment #109
catchCommitted/pushed and cherry-picked to 8.8.x, 8.7.x, 8.6.x and 8.5.x, thanks!
Comment #112
nerdsteinIs there any way this can get added into previous released versions? This is causing sites on simplytest.me to not provision properly.
Comment #113
xjm@nerdstein: It's impossible to add anything to a release that's already been tagged.
There will be new patch releases soon with these fixes and they will also be included in 8.7.0-alpha1.
Comment #114
nor sairi CreditAttribution: nor sairi as a volunteer and commentedcan i ask question? where location i need to put this patch and apply patch.
Comment #115
severin-bruhat CreditAttribution: severin-bruhat commentedWill you create 8.6.11 for this? If so, can you communicate the delay?
Thanks
Comment #116
Eli-T@nor sairi see https://www.drupal.org/patch/apply for help on how to apply patches
Comment #117
mikelutz@nor sari also see alexpott's comments in #105 about applying this specific patch.
@severin-bruhat - Xjm is a release manager and just said there will be new patch releases soon, this means 8.6.11. There is no delay, these releases require tests and signoffs and coordination and take a little time, but it is coming.
Comment #118
severin-bruhat CreditAttribution: severin-bruhat commented@mikelutz, thank you
Comment #119
Ben25 CreditAttribution: Ben25 commentedCan anyone access `/admin/modules/uninstall` when using twig 1.38.2 ?
Comment #120
WidgetsBurritos CreditAttribution: WidgetsBurritos at Rackspace commented@Ben25,
With the patched code from above, yes I can access /admin/modules/uninstall.
Comment #121
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedSorry to report back
Still, we do have issues after 1.38.2 as we need a patch
but it's not only node, media and other entity types
The following is a temp to keep going until the release
composer require twig/twig:1.37.1
Comment #122
huzookaApply the matching patch instead of downgrading, see https://symfony.com/blog/twig-sandbox-information-disclosure
Comment #123
carma03 CreditAttribution: carma03 commentedI was getting this error on 8.5.11 version:
Twig\Error\SyntaxError: An exception has been thrown during the compilation of a template ("Attribute "name" does not exist for Node "Twig\Node\CheckToStringNode".") in "core/themes/classy
..and #103 patch worked for me.
Thanks!
Comment #124
xjmHi everyone,
The above update to Drupal's
composer.json
Twig requirement was included in today's Drupal 8.6.11 and 8.5.12 releases, which should help sites avoid this error. I recommend you update Drupal core rather than trying to apply a patch to an existing Composer-built site. Thanks!Comment #125
dtv_rb CreditAttribution: dtv_rb commented@xjm Thank you! The update to 8.6.11 fixed the whole issue!
Comment #126
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot for Vardot commentedThank you for your hard work!! :)
Updating to Drupal 8.6.11
Comment #127
hctomBe aware, that there might be an issue with Twig 1.38.2, when using
{% embed %}
tags in your template:https://github.com/twigphp/Twig/issues/2898
Follow that issue to get updates/clarifications for it.
See also: #3040210: Updating twig/twig to v1.38.2 (included in Drupal 8.6.11) causes fatal error when embed tags are used in templates
Comment #128
scott_euser CreditAttribution: scott_euser as a volunteer and at Soapbox Communications Ltd commentedIf anyone is having issues related to this with devel (eg,
devel_breakpoint()
/kint()
), issue open here:https://www.drupal.org/project/devel/issues/3040310#comment-13024326
Comment #129
nor sairi CreditAttribution: nor sairi as a volunteer and commentedwhere is twig directory to apply patch?
Comment #130
yuseferi CreditAttribution: yuseferi commentedRunning
resolved it for me
Comment #131
scott_euser CreditAttribution: scott_euser as a volunteer and at Soapbox Communications Ltd commentedFor the benefit of anyone who stumbles on this issue, as per https://www.drupal.org/project/drupal/issues/3039408#comment-13018250 please instead update your Drupal Core to the latest which fixes this issue; do not force Twig 1.37.1 as that has a security issue.
Comment #132
micheljp CreditAttribution: micheljp commentedGetting this error when upgrading to security release 8.6.13
[Wed Mar 20 17:31:31.347132 2019] [php7:notice] [pid 1597] [client 192.168.33.1:56457] Uncaught PHP Exception Twig\\Error\\SyntaxError: "An exception has been thrown during the compilation of a template ("Attribute "name" does not exist for Node "Twig\\Node\\CheckToStringNode".") in "core/themes/classy/templates/views/views-mini-pager.html.twig"." at /var/www/public/drupal8/vendor/twig/twig/src/Environment.php line 797,
Comment #133
a-fro CreditAttribution: a-fro commentedThis bug also brought our site down when deploying the 8.6.13 security release.
We fixed it by removing the twig translate tag
{% trans %}String translation works if not rendering a {{ variable }}{% endtrans %}
as a hotfix.Comment #134
cilefen CreditAttribution: cilefen as a volunteer commented@micheljp Some of you may actually have #3040269: Twig\Error\SyntaxError: An exception has been thrown during the compilation of a template ("Attribute "name" does not exist for Node "Twig\Node\CheckToStringNode".
Comment #135
sitepioneers CreditAttribution: sitepioneers as a volunteer commentedI was able to fix the issue by updating core to the latest release.
Comment #136
guardiola86 CreditAttribution: guardiola86 commentedI'm getting this error as well when updating core to 8.6.13
Comment #137
cilefen CreditAttribution: cilefen as a volunteer commented@guardiola86 Please provide some detail about the upgrade process followed, and the context in which the error occurs, or we have nothing to go on.
Comment #138
guardiola86 CreditAttribution: guardiola86 commentedI've upgraded to core 8.6.13 and twig version 1.38.4. That's pretty much all I've done and I'm getting this error:
Comment #139
cilefen CreditAttribution: cilefen as a volunteer commented@guardiola86 That is a different error message #3040269: Twig\Error\SyntaxError: An exception has been thrown during the compilation of a template ("Attribute "name" does not exist for Node "Twig\Node\CheckToStringNode"
Comment #141
Andy_D CreditAttribution: Andy_D commentedUpdated core to latest release and got this...
Drupal version : 8.6.15
The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Twig\Error\SyntaxError</em>: An exception has been thrown during the compilation of a template ("Attribute "name" does not exist for Node "Twig\Node\CheckToStringNode"."). in <em class="placeholder">Twig\Environment->compileSource()</em> (line <em class="placeholder">1</em> of <em class="placeholder">themes/custom/focusrite/components/_patterns/03-organisms/_node.twig</em>). <pre class="backtrace">Project_trans_Node->compileString(Object) (Line: 34)
Comment #142
guardiola86 CreditAttribution: guardiola86 commentedTry this @Andy_D: https://www.drupal.org/project/drupal/issues/3040269#comment-13030254