Error when inserting component through twig
Winter CMS Build
Other (please specify below)
PHP Version
8.0
Database engine
MySQL/MariaDB
Plugins installed
No response
Issue description
My local website is down after today's update (Winter CMS 1.2)
The error is caused by the code inserted into the file \plugins\webvpf\acme\components\item\default.htm:
{% component 'ShareButtons' %}

Steps to replicate
updated today
Workaround
No response
If I remove string {% component 'ShareButtons' %}, then the site starts working.
@WebVPF could you provide the full stack trace for us?
@bennothommo like this?
74 | ReflectionClass->__toString() | ~/vendor/twig/twig/src/Node/Expression/CallExpression.php | 303
73 | Twig\Node\Expression\CallExpression->reflectCallable(…) | ~/vendor/twig/twig/src/Node/Expression/CallExpression.php | 30
72 | Twig\Node\Expression\CallExpression->compileCallable(…) | ~/vendor/twig/twig/src/Node/Expression/FilterExpression.php | 38
71 | Twig\Node\Expression\FilterExpression->compile(…) | ~/vendor/twig/twig/src/Compiler.php | 74
70 | Twig\Compiler->subcompile(…) | ~/vendor/twig/twig/src/Node/PrintNode.php | 35
69 | Twig\Node\PrintNode->compile(…) | ~/vendor/twig/twig/src/Node/Node.php | 86
68 | Twig\Node\Node->compile(…) | ~/vendor/twig/twig/src/Node/Node.php | 86
67 | Twig\Node\Node->compile(…) | ~/vendor/twig/twig/src/Compiler.php | 74
66 | Twig\Compiler->subcompile(…) | ~/vendor/twig/twig/src/Node/ForNode.php | 84
65 | Twig\Node\ForNode->compile(…) | ~/vendor/twig/twig/src/Node/Node.php | 86
64 | Twig\Node\Node->compile(…) | ~/vendor/twig/twig/src/Node/Node.php | 86
63 | Twig\Node\Node->compile(…) | ~/vendor/twig/twig/src/Compiler.php | 74
62 | Twig\Compiler->subcompile(…) | ~/vendor/twig/twig/src/Node/ModuleNode.php | 310
61 | Twig\Node\ModuleNode->compileDisplay(…) | ~/vendor/twig/twig/src/Node/ModuleNode.php | 84
60 | Twig\Node\ModuleNode->compileTemplate(…) | ~/vendor/twig/twig/src/Node/ModuleNode.php | 65
59 | Twig\Node\ModuleNode->compile(…) | ~/vendor/twig/twig/src/Compiler.php | 60
58 | Twig\Compiler->compile(…) | ~/vendor/twig/twig/src/Environment.php | 505
57 | Twig\Environment->compile(…) | ~/vendor/twig/twig/src/Environment.php | 516
56 | Twig\Environment->compileSource(…) | ~/vendor/twig/twig/src/Environment.php | 348
55 | Twig\Environment->loadTemplate(…) | ~/vendor/twig/twig/src/Environment.php | 309
54 | Twig\Environment->load(…) | ~/modules/cms/classes/Controller.php | 1060
53 | Cms\Classes\Controller->renderPartial(…) | ~/modules/cms/classes/Controller.php | 1192
52 | Cms\Classes\Controller->renderComponent(…) | ~/modules/cms/twig/Extension.php | 102
51 | Cms\Twig\Extension->componentFunction(…) | ~/storage/cms/twig/8e/8e6a4ebbf5c6874b0c64ef63b2f9ec09404785b46f8c4d505179b996f62cbb0d.php | 75
50 | __TwigTemplate_4e36c5a555ed739cf6de28dd809543095609bace7b3c374e0f28ce952c2c23e9->doDisplay(…) | ~/vendor/twig/twig/src/Template.php | 394
49 | Twig\Template->displayWithErrorHandling(…) | ~/vendor/twig/twig/src/Template.php | 367
48 | Twig\Template->display(…) | ~/vendor/twig/twig/src/Template.php | 379
47 | Twig\Template->render(…) | ~/vendor/twig/twig/src/TemplateWrapper.php | 40
46 | Twig\TemplateWrapper->render(…) | ~/modules/cms/classes/Controller.php | 1061
45 | Cms\Classes\Controller->renderPartial(…) | ~/modules/cms/classes/Controller.php | 1192
44 | Cms\Classes\Controller->renderComponent(…) | ~/modules/cms/twig/Extension.php | 102
43 | Cms\Twig\Extension->componentFunction(…) | ~/storage/cms/twig/ef/ef294c58c9a7c76bb4f374c1a5f60e6453f8c4a9e5eaae84b17ff395ea170246.php | 40
42 | __TwigTemplate_2c60529af6d6cebfb6837bb47e74f2a2b9a673dd02d4a9fe8fce43fb23082d5d->doDisplay(…) | ~/vendor/twig/twig/src/Template.php | 394
41 | Twig\Template->displayWithErrorHandling(…) | ~/vendor/twig/twig/src/Template.php | 367
40 | Twig\Template->display(…) | ~/vendor/twig/twig/src/Template.php | 379
39 | Twig\Template->render(…) | ~/vendor/twig/twig/src/TemplateWrapper.php | 40
38 | Twig\TemplateWrapper->render(…) | ~/modules/cms/classes/Controller.php | 422
37 | Cms\Classes\Controller->runPage(…) | ~/modules/cms/classes/Controller.php | 217
36 | Cms\Classes\Controller->run(…) | ~/modules/cms/classes/CmsController.php | 50
35 | Cms\Classes\CmsController->run(…) | ~/vendor/laravel/framework/src/Illuminate/Routing/Controller.php | 54
34 | Illuminate\Routing\Controller->callAction(…) | ~/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php | 45
33 | Illuminate\Routing\ControllerDispatcher->dispatch(…) | ~/vendor/laravel/framework/src/Illuminate/Routing/Route.php | 261
32 | Illuminate\Routing\Route->runController() | ~/vendor/laravel/framework/src/Illuminate/Routing/Route.php | 204
31 | Illuminate\Routing\Route->run() | ~/vendor/laravel/framework/src/Illuminate/Routing/Router.php | 725
30 | Illuminate\Routing\Router->Illuminate\Routing\{closure}(…) | ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php | 141
29 | Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…) | ~/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php | 50
28 | Illuminate\Routing\Middleware\SubstituteBindings->handle(…) | ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php | 180
27 | Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…) | ~/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php | 49
26 | Illuminate\View\Middleware\ShareErrorsFromSession->handle(…) | ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php | 180
25 | Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…) | ~/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php | 121
24 | Illuminate\Session\Middleware\StartSession->handleStatefulRequest(…) | ~/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php | 64
23 | Illuminate\Session\Middleware\StartSession->handle(…) | ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php | 180
22 | Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…) | ~/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php | 37
21 | Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(…) | ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php | 180
20 | Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…) | ~/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php | 67
19 | Illuminate\Cookie\Middleware\EncryptCookies->handle(…) | ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php | 180
18 | Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…) | ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php | 116
17 | Illuminate\Pipeline\Pipeline->then(…) | ~/vendor/laravel/framework/src/Illuminate/Routing/Router.php | 726
16 | Illuminate\Routing\Router->runRouteWithinStack(…) | ~/vendor/laravel/framework/src/Illuminate/Routing/Router.php | 703
15 | Illuminate\Routing\Router->runRoute(…) | ~/vendor/laravel/framework/src/Illuminate/Routing/Router.php | 667
14 | Illuminate\Routing\Router->dispatchToRoute(…) | ~/vendor/winter/storm/src/Router/CoreRouter.php | 20
13 | Winter\Storm\Router\CoreRouter->dispatch(…) | ~/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php | 167
12 | Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(…) | ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php | 141
11 | Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…) | ~/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php | 86
10 | Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(…) | ~/vendor/winter/storm/src/Foundation/Http/Middleware/CheckForMaintenanceMode.php | 25
9 | Winter\Storm\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(…) | ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php | 180
8 | Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…) | ~/vendor/winter/storm/src/Foundation/Http/Middleware/CheckForTrustedProxies.php | 56
7 | Winter\Storm\Foundation\Http\Middleware\CheckForTrustedProxies->handle(…) | ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php | 180
6 | Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…) | ~/vendor/winter/storm/src/Http/Middleware/TrustHosts.php | 46
5 | Winter\Storm\Http\Middleware\TrustHosts->handle(…) | ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php | 180
4 | Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(…) | ~/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php | 116
3 | Illuminate\Pipeline\Pipeline->then(…) | ~/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php | 142
2 | Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(…) | ~/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php | 111
1 | Illuminate\Foundation\Http\Kernel->handle(…) | ~/index.php | 43
Thanks @WebVPF.
That's strange though - there hasn't been any edits to the Twig functionality in a little while (bar a very minor change to a return type, which should have no effect on your code), so it's puzzling to me that it would only break today.
Could you try clearing the cache with php artisan cache:clear and see if that helps?
@bennothommo I already tried clearing the cache. This code worked for several years until this day. The website is down today after an update. Broke on those pages where there is this code. Winter CMS 1.2
@bennothommo Here is my component file {% component 'ShareButtons' %} https://github.com/WebVPF/wn-share-plugin/blob/master/components/buttons/default.htm
Does it have any error?
@WebVPF what does your Component class file look like?
@LukeTowers there he is https://github.com/WebVPF/wn-share-plugin/blob/master/components/Buttons.php
@bennothommo, @LukeTowers This twig is causing the error
{{ ('webvpf.share::lang.buttons.' ~ btnId )|trans }}
@WebVPF so just to clarify, the issue is occurring when you include the component within another component? Or is it happening anywhere where you include the ShareButtons component?
I've just tested your plugin out on my current Winter 1.2 project, and it seems to be working fine for me. The only difference - as far as I can tell - is that I'm including the component within a layout.
@bennothommo When I include in another component
Ah right. I just tested that too and I didn't encounter the error.
Just to note, I don't believe we support components within components. While it may be possible to hack together, it's probably likely to break.
@bennothommo In Winter 1.2 the system markup filter |trans was removed? I don't see it in the documentation https://wintercms.com/docs/markup/filter-app
{{ "acme.demo::lang.string.example"|trans }}
It is he who is causing the error. I insert this filter into the layout and get an error. Just a filter without a plugin.
@WebVPF @bennothommo I think this is not related to Winter 1.2.0, I also got this error today when doing simple composer update on Winter 1.1.8 installation so my guess is that problem is one of the updated dependencies.
I am not 100% sure but this may be related to:
- https://github.com/twigphp/Twig/pull/3704
- https://github.com/twigphp/Twig/issues/3703
So the fix is already deployed and should be fine soon..., I will let you know later.
@bennothommo Ok, looks like problem still persists. Same happens when I tried to update (composer update) my Winter 1.1.8 dev installation.
@arvislacis are you using the same components as @WebVPF?
@LukeTowers No, I am using mostly my own, custom components and some from Winter CMS plugins, not the ones @WebVPF mentioned.
@arvislacis are you able to isolate the issue to a single specific component or does it affect every single component?
Something a bit weird is going on... because I did composer update once again today and it works fine now (so far no error in pages), without any changes in my code although yesterday I did some server management work and cache cleaning etc and reconfiguration, maybe cache was the issue...
@WebVPF could comment on this..., form my side everything looks fine now.
Here is additional update on this issue:
My coworker experienced same issue after setting up the same project I used with clean composer update.
After a little investigation we found out that |trans filter was also the main cause for this problem like @WebVPF initally mentioned. We didn't dig deeper into this but we fixed it by doing composer install on stable composer.lock file (from my previous working setup), and it worked fine.
I attached files of stable (working) and unstable (new but problematic) composer.lock files:
stable-composer.txt unstable-composer.txt
If anyone is facing the same problem then I probably would recommend to install previous composer.lock and then try to do composer update again.
Differences between those files:
- doctrine/cache: 2.1.1 vs 2.2.0
- monolog/monolog: 2.5.0 vs 2.6.0
- scssphp/scssphp: 1.10.2 vs 1.10.3
- twig/twig: 2.14.13 vs 2.15.1
- winter/wn-backend-module: 95351e0c6bf1b12b60ee867bc3f6eab81ec1a9c9 vs 80c7c022c230fdad08099b7c6d5cd99754554f74
- winter/wn-system-module: 64611047694291d60dc26b68996867efbde8877b vs a51317638412a769654186916ff31801e16b73db
@LukeTowers My guess it's issue with doctrine/cache or twig/twig...
Yeah, looking at https://github.com/twigphp/Twig/compare/v2.14.13...v2.15.1 it would look like those two issues that you linked were indeed the problem.
But it's interesting that sometimes also doing composer update on the stable .lock file doesn't causes problems anymore and everything works fine also with latest Twig etc. versions.
@arvislacis could be there was a commit that was tagged as 1.15.1 and your first update got it (the "unstable" composer.lock) and then reverting your lock file to the old version told Composer to download it again.
Anyways, going to close this for now.
Winter CMS Build
Latest : (dev-wip/1.2)
winter/storm dev-wip/1.2 91993e2
winter/wn-backend-module dev-wip/1.2 0258f85
winter/wn-cms-module dev-wip/1.2 a998ed7
winter/wn-system-module dev-wip/1.2 c5295ca
PHP Version
8.0.20
Database engine
MariaDB : 10.3.10
Plugins installed
- winter/wn-pages-plugin
winter/wn-pages-plugin dev-wip/1.2 62c6003
Issue description
Unable to add a twig tag containing the | trans filter
Steps to replicate
composer create-project wintercms/winter winter12 "dev-wip/1.2 as 1.2"
php artisan winter:install
php artisan winter:env
php artisan winter:up
composer require winter/wn-pages-plugin
php artisan winter:up
=> Site working.
Add twig tag with trans filter in layout : {{ 'winter.pages::lang.plugin.description' | trans }}
=> Site down with exception:
Object of class Winter\Storm\Foundation\Application could not be converted to string
P:\_Sites\_Labs\winter12\vendor\twig\twig\src\Node\Expression\CallExpression.php line 304
The corresponding line is the same as the issue above :
$callableName = $class.'::'.$r->name;
Do a dump of the line variables dd($class, $r->name);:
ReflectionClass {
+name: "Illuminate\Support\Facades\Facade"
modifiers: "abstract"
implements: []
constants: []
properties: array:3 [▶]
methods: array:19 [▶]
extra: {▶}
}
"get"
Complete stack trace : system.log
Workaround
No response
@damsfx @LukeTowers @bennothommo
I was able to reproduce this using the above procedure.
Note: no need to install extra plugin. Just adding {{ 'anything' | trans }} triggers the bug.
Interesting: I switched this vhost to PHP 8.1, launched composer update and the problem disappears.