Twig Template to Handle Null Values

Installation Details:

  • Mautic Version: 6.0.4

  • Apache: 2.4.6

  • PHP version: 8.2.29

  • Database: 10.11.14 (mariadb)

Checking the mautic_prod log there are the following, which searching the forum seems to be related to among other the error I have with the All Emails report:

[2025-09-08T16:44:19.440400+00:00] mautic.CRITICAL: Uncaught PHP Exception Twig\Error\RuntimeError: “An exception has been thrown during the rendering of a template (“Mautic\CoreBundle\Twig\Extension\AssetExtension::makeLinks(): Argument #1 ($text) must be of type string, null given, called in /html/var/tmp/twig/2d/2df6af1e0790f8f9fe30ed8d65a3f626.php on line 132”).” at /html/app/bundles/ReportBundle/Resources/views/Graph/Table.html.twig line 38 {“exception”:“[object] (Twig\Error\RuntimeError(code: 0): An exception has been thrown during the rendering of a template ("Mautic\CoreBundle\Twig\Extension\AssetExtension::makeLinks(): Argument #1 ($text) must be of type string, null given, called in /html/var/tmp/twig/2d/2df6af1e0790f8f9fe30ed8d65a3f626.php on line 132"). at /html/app/bundles/ReportBundle/Resources/views/Graph/Table.html.twig:38)\n[previous exception] [object] (TypeError(code: 0): Mautic\CoreBundle\Twig\Extension\AssetExtension::makeLinks(): Argument #1 ($text) must be of type string, null given, called in /html/var/tmp/twig/2d/2df6af1e0790f8f9fe30ed8d65a3f626.php on line 132 at /html/app/bundles/CoreBundle/Twig/Extension/AssetExtension.php:176)”} {“hostname”:“apch-njrdmbe”,“pid”:1238154}

And saw also some suggestions for patch to search for makeLinks, find the call (e.g., {{ makeLinks(some_variable) }} or {{ assetExtension.makeLinks(some_variable) }}) and change it to handle null:

{{ makeLinks(some_variable | default('') | default(null)) }}

Has this been addressed already?

So let’s get this temporary fixed then - The current line 38 in /html/app/bundles/ReportBundle/Resources/views/Graph/Table.html.twig looks like this:

{{ assetMakeLinks(cell) }}

which I changed to:

{{ cell is not empty ? assetMakeLinks(cell) : ‘’ }}

This ensures that cell exists and is not null before calling assetMakeLinks(cell), and if cell is null, it returns an empty string to prevent a crash. And once again the All Emails report works again.

Hopefully this little patch can be of help for someone else.