If you recently upgraded your Mautic from 7.0.1 to 7.1.2 and suddenly found your entire site offline with a message like “The site is currently offline due to encountering an error,” you’re not alone. The culprit comes down to a subtle but critical mismatch in how Mautic handles Twig’s include() function after the update.
Here’s the quick scoop: Twig, the template engine Mautic uses, released a change starting in version 3.28 where its include() function can return a Twig\Markup object instead of a plain string. Mautic’s override method includeWithEvent() in OverrideIncludeExtension.php is still declaring it returns a string, which causes a PHP error because it literally expected a string but got an object instead.
This mismatch breaks rendering everywhere templates use that overridden include, including your login page—meaning you can’t even get into your site to fix anything. Adding insult to injury, pinning Twig back to an older version isn’t a clean option because security advisories block those older Twig versions and other dependencies prevent locking down strictly to 3.23 (the last “string only” version).
The good news? A neat workaround that’s been confirmed by community members is to cast the return to a string explicitly. By editing OverrideIncludeExtension.php to wrap the include calls like this:
return (string) CoreExtension::include(...);
you bypass the PHP type error while keeping the rendering intact, thanks to Twig\Markup implementing __toString(). Just remember—this manual fix gets overwritten every time you update Mautic with Composer, so it’s a temporary workaround until an official fix drops.
What should happen eventually is that Mautic updates the method signature to accept Twig\Markup objects or consistently cast them to string internally.
If you’re running a Composer-based install, keep this patch handy in your toolbox after updates or consider holding off on the minor Twig bumps until Mautic reacts. This is a classic example of what happens when dependencies move faster than CMS ecosystems can adapt, and it’s a reminder of the care needed when pushing updates in production.
For self-hosters comfortable with code, the fix is simple and keeps your site alive. For folks who’d rather avoid these fiddly low-level bugs, that’s exactly what platforms like Mailertizer exist for—updating Mautic safely, with zero downtime, and all the technical headaches handled for you.
You can follow the full user discussion and ongoing updates on this issue in the Mautic Community Forum.