- Issue created by @Jons
Can we get the exception message and the stack trace added to this report? š
I am adding the "needs steps to reproduce" tag because the current steps are a common action.
- š¬š§United Kingdom Jons
The error text is seen in the AJAX response and has no stack trace and is similar in the php error log:
"The website encountered an unexpected error. Try again later.Exception: Object of type Drupal\system\Entity\Menu cannot be printed. in Drupal\Core\Template\TwigExtension->escapeFilter() (line 459 of core/lib/Drupal/Core/Template/TwigExtension.php)."
Reproduce: It occurs in the module nd_megamenu using module nd_visualshortcodes which at some point includes a template with the twig processing. Some code would be needed to mock this up - but the core code: (core/lib/Drupal/Core/Template/TwigExtension.php)
it expects there to be a toRenderable() or __toString() or toString() method on any Object that's passed - so why not just add it? (see patch file) Could you provide links to those modules needed to reproduce the bug so we can better understand the context of making this change to core?
- š¬š§United Kingdom Jons
The main module is https://www.drupal.org/project/tb_megamenu ā
nd_visualshortcodes is a custom module - part of a theme package.
The menu is in a block and when edited looks like the attached image (menu_issue.png). You click the edit icon in the + Menu strip to get the problem.
Hopefully all Entities will have a toString() method if there is any chance they will be used in Twig templates. Maybe a change the interface or the Twig filter to add a method to get the Entity metadata ('configuration entity class')?
eg in core/modules/system/src/Entity/Menu.php* @ConfigEntityType( * id = "menu", * label = @Translation("Menu"), ...
- š³šæNew Zealand quietone
Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies ā .
Can we get the stack trace and direct and simple steps to reproduce added to the issue summary please?
- š¬š§United Kingdom Jons
@cilefen the background is explained above - but if you really want a stack trace just pass a Menu entity to a twig template and you'll get one, eg In a controller:
use Drupal\system\Entity\Menu; .... $m = new Me
nu(['id'=>'mymenuid', 'label'=>'mymenulabel'], 'menu');
$renderable = [
'#theme' => 'my_template',
'#test_var' => $m,
];
return \Drupal::service('renderer')->renderPlain($renderable);
I have reviewed this issues as part of the Drupal South (Melbourne) code sprint and I can not reproduce the reported issue without the steps to reproduce. Please provide step to reproduce.
- š®š³India shivam_tiwari
This issue found for me also after adding controller as described on #9. Created MR 11629 to resolve this issue. After adding this MR as a patch issue is resolved but pipeline is failing for PHP static analysis, so need to work on this.
- š§š·Brazil charlliequadros
I fixed the PHPStan error, but now I'm encountering an issue with Nightwatch. Iām not sure how to test it locally to resolve it. If anyone can help me with the steps I need to take, Iād be happy to fix it as well.