Skip to content

Close the Twig include gate when loading a template throws - #1569

Merged
LukeTowers merged 1 commit into
wintercms:wip/1.3from
austinderrick:fix/twig-engine-include-gate
Oct 16, 2026
Merged

LukeTowers merged 1 commit into
wintercms:wip/1.3from
austinderrick:fix/twig-engine-include-gate

Conversation

@austinderrick

Copy link
Copy Markdown
Contributor

Summary

System\Twig\Engine::get() sets Loader::$allowInclude to true while it loads a template, which lets the loader resolve any readable local file path as a template, and sets it back afterward. When loading throws (a missing template or a syntax error), the reset never runs, so local file inclusion stays enabled for the rest of the process. The previous value is now restored in a finally block.

Under PHP-FPM the open gate lasts until the end of the failed request. Under a persistent worker such as Laravel Octane it lasts for every later request the worker serves.

Split out of #1511 so it can be reviewed on its own.

Testing

modules/system/tests/twig/EngineTest.php covers a successful render, a load that throws, a local file that must not resolve after a failed load, and restoring the previous value rather than forcing false. The throw tests fail without the change.

System\Twig\Engine::get() opens Loader::$allowInclude, which lets the loader resolve any readable local path, then closes it after loading the template. A missing template or a syntax error threw before the close, leaving the gate open for the rest of the process. The previous value is now restored in a finally block.
@coderabbitai

coderabbitai Bot commented Oct 15, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e91c303b-543a-457c-819b-1776d857a1cb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@LukeTowers
LukeTowers merged commit c39e979 into wintercms:wip/1.3 Oct 16, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants