Heads up if you’re running Mautic and planning to upgrade from 7.0.1 to 7.1.2 — a nasty bug is causing the whole site to go offline right after the update. The culprit? A subtle but critical mismatch in how Mautic handles Twig’s include function return type. This one’s showing up as “The site is currently offline due to encountering an error” on every page, including your login screen.
Here’s the deal: Mautic 7.1.2 updated Twig from version 3.23.0 to 3.28.0. The latest Twig version changed the return type of include() to sometimes return a Twig\Markup object instead of a plain string. But Mautic’s code in OverrideIncludeExtension::includeWithEvent() still expects a string return type. PHP 8.4 enforces strict typing here, so it throws a fatal error and kills the page rendering.
Why not just pin Twig back to 3.23.0 to fix it? That’s not a clean option. First, security advisories flag that version as insecure, so Composer blocks it. Plus, oneup/uploader-bundle (a Mautic dependency) allows newer Twig versions anyway, so you’re stuck with this mismatch unless the core is fixed.
If you find yourself locked out post-upgrade, a quick workaround is to cast the return value of Twig’s include to string inside OverrideIncludeExtension.php. This works because Twig\Markup implements __toString(), so the output doesn’t change, just the type does. Clear the cache afterward, and your site should come back online.
Of course, this fix is manual and gets overwritten when you run composer update next time. The proper solution: Mautic needs to either loosen the return type declaration to accept Twig\Markup or cast it internally in the method. Hopefully, you’ll see an official patch soon to avoid this headache.
This issue highlights how tightly software updates are intertwined. Updating libraries like Twig without checking type compatibility can break things in ways that aren’t immediately obvious. If you’re managing your own Mautic instance, tread carefully and watch the community channels for these kinds of gotchas after upgrades.
Want the full thread and discussion on the Mautic forum? Check it out here.
And if hassle-free upgrades and zero downtime sound good to you, Mailertizer offers a hosted Mautic platform with proactive maintenance so you don’t have to wrestle with these backend quirks.