Update from Mautic 7.0.1 to 7.1.2 Breaks Site Due to Twig Return Type Change — Here’s What’s Happening

If you recently tried updating your Mautic from 7.0.1 to 7.1.2 and found your whole site offline with the dreaded error “The site is currently offline due to encountering an error,” you’re not alone. This isn’t just some random glitch — it’s a direct result of changes in the underlying Twig templating library that Mautic uses.

Here’s the deal: The update involved bumping Twig from version 3.23.0 to 3.28.0. Twig introduced a small but critical change in its core include() function. Before, include() always returned a plain string. Now, it can return a Twig\Markup object instead. This improves how Twig manages HTML safely behind the scenes, but it clashes with Mautic’s own overridden method includeWithEvent(), which still expects a string return type.

Because PHP enforces strict return types, this mismatch throws a fatal error whenever a Twig template is rendered, including your login page. The upshot? You can’t even get into your Mautic dashboard, and every page fails to load.

Tinkering with a quick fix is possible. One user shared a handy workaround: force-casting Twig’s return value to a string inside OverrideIncludeExtension.php. Since Twig\Markup implements __toString(), this safely converts the output back to a string, restoring functionality immediately. Just remember, if you update Mautic with Composer again, your change will be overwritten.

Reverting Twig to the old version isn’t a clean option either because of security advisories and dependency constraints — especially the oneup/uploader-bundle requiring a newer Twig version.

The proper fix has to come from Mautic itself: either the return type declaration on includeWithEvent() needs updating to accept Twig\Markup, or the team needs to explicitly cast the return value. This ensures compatibility with the newer Twig without hacks.

What does this mean for you if you’re managing your own Mautic instance? If you’re on 7.0.1 and planning to update, be forewarned — you might run into this PHP return type error that bricks your site. Until an official fix drops, the best approach is to patch the method manually or hold off on updating.

At Mailertizer, we handle all this under the hood for you with our hosted Mautic service. No messy Composer updates, no broken login pages, just smooth upgrades and continuous uptime.

For a deep dive into the forum discussion and the user’s workaround, check out the original thread here.

Share the Post: