# Update from 7.0.1 to 7.1.12 - includeWithEvent - The site is currently offline due to encountering an error

**URL:** https://forum.mautic.org/t/update-from-7-0-1-to-7-1-12-includewithevent-the-site-is-currently-offline-due-to-encountering-an-error/38334
**Category:** Product Support
**Created:** [July 4, 2026, 7:04pm UTC](https://forum.mautic.org/t/update-from-7-0-1-to-7-1-12-includewithevent-the-site-is-currently-offline-due-to-encountering-an-error/38334 "2026-07-04T19:04:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![alexrm1x](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/alexrm1x/32/2500_2.png) [@alexrm1x](https://forum.mautic.org/u/alexrm1x)
#### Post date: [July 4, 2026, 7:04pm UTC](https://forum.mautic.org/t/update-from-7-0-1-to-7-1-12-includewithevent-the-site-is-currently-offline-due-to-encountering-an-error/38334/1 "2026-07-04T19:04:46Z")

</div>

**Your software**  
My Mautic version is: **7.0.1 updating to 7.1.2**  
My PHP version is: **8.4**  
My Database type and version is: **MariaDB 10.11.14**  
Install method: **Composer (mautic/recommended-project), project root at `<home>/mautic` with `docroot/` inside**

**Your problem**  
My problem is: after a routine Composer minor update from 7.0.1 to 7.1.2, the whole site went offline (“The site is currently offline due to encountering an error”). Every page, including `/s/login`, fails to render, so I cannot even log in.

The cause is a return-type mismatch introduced by Twig. During the update, `composer update --with-dependencies` moved `twig/twig` from `v3.23.0` to `v3.28.0`. In Twig 3.28, `Twig\Extension\CoreExtension::include()` can return a `Twig\Markup` object instead of a plain `string` (see upstream discussion [include() function must return a Markup object instead of a string · Issue #4802 · twigphp/Twig · GitHub](https://github.com/twigphp/twig/issues/4802) ). But `Mautic\CoreBundle\Twig\Extension\OverrideIncludeExtension::includeWithEvent()` is declared with a `: string` return type and returns `CoreExtension::include(...)` directly, so PHP throws a `TypeError` and breaks rendering of any template that uses the overridden `include()` — starting with the login/base templates. Both `return CoreExtension::include(...)` statements in the method (array-handling branch and single-template branch) are affected.

Note: pinning `twig/twig` back to `3.23.0` is not a clean option, because Composer’s `block-insecure` audit rejects it (that range is flagged by security advisories), and `oneup/uploader-bundle` (required by `mautic/core-lib` 7.1.2) allows `^2.4 || ^3.0`, so the resolver lands on a recent Markup-returning Twig anyway. The fix belongs in Mautic’s method signature.

**These errors are showing in the log:**

```auto
mautic.CRITICAL: Uncaught PHP Exception Twig\Error\RuntimeError:
"An exception has been thrown during the rendering of a template
(\"Mautic\CoreBundle\Twig\Extension\OverrideIncludeExtension::includeWithEvent():
Return value must be of type string, Twig\Markup returned\")
in \"@MauticUser/Security/base.html.twig\" at line 12."

[previous exception] TypeError:
Mautic\CoreBundle\Twig\Extension\OverrideIncludeExtension::includeWithEvent():
Return value must be of type string, Twig\Markup returned
at .../docroot/app/bundles/CoreBundle/Twig/Extension/OverrideIncludeExtension.php:65

```

(The same TypeError also surfaces via `@MauticCore/Default/slim.html.twig` at line 3.)

**Steps I have tried to fix the problem:**

1. Cleared the prod cache (`rm -rf var/cache/prod` + `bin/console cache:clear`) — no change, same TypeError.
2. Tried to pin `twig/twig` back to `3.23.0` with `composer require "twig/twig:3.23.0"` — blocked by security advisories (`block-insecure`) and by the `oneup/uploader-bundle` constraint. Reverted.
3. **Workaround that fixed it:** cast both `return CoreExtension::include(...)` statements to `(string)` in `app/bundles/CoreBundle/Twig/Extension/OverrideIncludeExtension.php`, then cleared cache. Site is fully back. Since `Twig\Markup` implements `__toString()`, the rendered HTML is identical.

```auto
// before
return CoreExtension::include($env, $context, $templates, $event->getVars(), $withContext, $ignoreMissing, $sandboxed);
// after
return (string) CoreExtension::include($env, $context, $templates, $event->getVars(), $withContext, $ignoreMissing, $sandboxed);

```

Suggested proper fix: cast to `(string)` in core, or adjust the declared return type to accept `Twig\Markup`. On Composer installs this edit is under `docroot/app/` and gets overwritten by the next `composer update`, so it must be reapplied until an official fix ships.

---

<div class="post-metadata">

### Author: ![alexrm1x](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/alexrm1x/32/2500_2.png) [@alexrm1x](https://forum.mautic.org/u/alexrm1x)
#### Post date: [July 4, 2026, 7:18pm UTC](https://forum.mautic.org/t/update-from-7-0-1-to-7-1-12-includewithevent-the-site-is-currently-offline-due-to-encountering-an-error/38334/2 "2026-07-04T19:18:33Z")

</div>

I reported this bug officially at:

> <https://github.com/mautic/mautic/issues/16468>
>
> \### Mautic Series
> 
> 7.1.x series
> 
> \### Mautic installed version
> 
> 7.1.12
> 
> \### Way o…f installing
> 
> I installed with composer using https://github.com/mautic/recommended-project
> 
> \### PHP version
> 
> 8.4
> 
> \### What browsers are you seeing the problem on?
> 
> Chrome
> 
> \### What happened?
> 
> After a Composer minor update from 7.0.1 to 7.1.2, the whole site goes offline ("The site is currently offline due to encountering an error"). Every page, including /s/login, fails to render, so I cannot even log in.
> 
> Root cause: during the update, composer resolved twig/twig from v3.23.0 to v3.28.0. In Twig 3.28, Twig\\Extension\\CoreExtension::include() can return a Twig\\Markup object instead of a plain string (see upstream https://github.com/twigphp/twig/issues/4802). But Mautic\\CoreBundle\\Twig\\Extension\\OverrideIncludeExtension::includeWithEvent() is declared with a ": string" return type and returns CoreExtension::include(...) directly, so PHP throws a TypeError and breaks rendering of any template using the overridden include() — starting with the login/base templates. Both return CoreExtension::include(...) statements in the method (array-handling branch and single-template branch) are affected.
> 
> The affected statements were introduced in the "Execute the VIEW\_INJECT\_CUSTOM\_TEMPLATE event for all twig sub-templates rendered with the include function" change; the ": string" return type is incompatible with Twig 3.28.
> 
> Note: pinning twig/twig back to 3.23.0 is not a clean option — Composer's block-insecure audit rejects it (that range is flagged by security advisories), and oneup/uploader-bundle (required by mautic/core-lib 7.1.2) allows ^2.4 || ^3.0, so the resolver lands on a recent Markup-returning Twig anyway. The fix belongs in the method signature.
> 
> \### How can we reproduce this issue?
> 
> 1. Composer-based Mautic 7.0.1 (mautic/recommended-project), PHP 8.4.
> 2. Run composer update that lets twig/twig reach 3.28.0 (e.g. bumping mautic/\* to 7.1.2 with --with-dependencies).
> 3. Clear cache and finish the update / run migrations.
> 4. Open any page (e.g. /s/login).
> Expected: page renders. Actual: TypeError / RuntimeError, site offline.
> 
> \*\*Steps tried / Workaround\*\* 
> \- Cleared prod cache: no change.
> \- Tried to pin twig/twig to 3.23.0: blocked by security advisories and the oneup/uploader-bundle constraint.
> \- Fixed by casting both "return CoreExtension::include(...)" statements to (string) in OverrideIncludeExtension.php, then clearing cache. Twig\\Markup implements \_\_toString(), so the rendered HTML is identical.
> 
> Suggested fix: cast to (string) in core, or adjust the declared return type to accept Twig\\Markup. On Composer installs this edit is under docroot/app/ and gets overwritten by the next composer update, so it must be reapplied until an official fix ships.
> 
> \### Relevant log output
> 
> \`\`\`shell
> mautic.CRITICAL: Uncaught PHP Exception Twig\\Error\\RuntimeError:
> "An exception has been thrown during the rendering of a template
> (\\"Mautic\\CoreBundle\\Twig\\Extension\\OverrideIncludeExtension::includeWithEvent():
> Return value must be of type string, Twig\\Markup returned\\")
> in \\"@MauticUser/Security/base.html.twig\\" at line 12."
> 
> \[previous exception\] TypeError:
> Mautic\\CoreBundle\\Twig\\Extension\\OverrideIncludeExtension::includeWithEvent():
> Return value must be of type string, Twig\\Markup returned
> at .../docroot/app/bundles/CoreBundle/Twig/Extension/OverrideIncludeExtension.php:65
> 
> (The same TypeError also surfaces via @MauticCore/Default/slim.html.twig at line 3.)
> \`\`\`
> 
> \### Code of Conduct
> 
> \- \[x\] I confirm that I have read and agree to follow this project's Code of Conduct
> 
> \<br /\>\<hr\>
> Care about this issue? Want to get it resolved sooner? If you are a \<a href='https://www.mautic.org/become-a-member-of-mautic'\>member of Mautic\</a\>, you can add some funds to the \<a href='https://opencollective.com/mautic/projects/bounties'\>Bounties Project\</a\> so that the person who completes this task can claim those funds once it is merged by a member of the core team! Read the docs \<a href='https://contribute.mautic.org/product-team/mautic-bounty-programme'\>here.\</a\>

---

<div class="post-metadata">

### Author: ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)
#### Post date: [July 9, 2026, 10:50am UTC](https://forum.mautic.org/t/update-from-7-0-1-to-7-1-12-includewithevent-the-site-is-currently-offline-due-to-encountering-an-error/38334/3 "2026-07-09T10:50:40Z")

</div>

Thanks!

It’s caused by a BC break in the `twig/twig` package. Such breaking change shouldn’t have happened in the minor version of that package.

The fix is ready here: [Fix TypeError in OverrideIncludeExtension with Twig 3.28 (include() returns Twig\Markup) - Pull Request #16487 - mautic/mautic - GitHub](https://github.com/mautic/mautic/pull/16487)

It needs just a rebase. I was able to replicate and confirmed the fix works. We’ll merge it and release it in Mautic 7.2.0 in the upcoming days.
