Changelog (v4.0.0-alpha1...v4.0.0-beta1)
- bug #5049 Fix arrow functions in the parent expression of
extendsandembedtags (@nicolas-grekas) - bug #5047 Check the sandbox policy before the cache tag coerces its key and tags to strings (@fabpot)
- bug #5046 Include the autoescape strategy and always-allowed sandbox registrations in compiled template keys (@fabpot)
- security #cve-2026-133773 Limit the number of converters kept by html_to_markdown (@nicolas-grekas)
- security #cve-2026-133766 Check __toString() on spread arguments in the sandbox (@nicolas-grekas)
- security #cve-2026-133763 Check __toString() on the result of tests in the sandbox (@fabpot)
- security #cve-2026-133764 Check __toString() on the input of tests in the sandbox (@fabpot)
- security #cve-2026-133767 Check the sandbox policy against dynamic embed parent expressions (@fabpot)
- security #cve-2026-133770 Prevent sandboxed templates from calling the Markup constructor (@fabpot)
- security #cve-2026-133769 Stop html_cva from exposing the properties of objects used as classes (@fabpot)
- security #cve-2026-133765 Check __toString() on the result of assignment expressions in the sandbox (@fabpot)
- security #cve-2026-133768 Stop the join filter from exposing the properties of non-iterable objects (@fabpot)
- bug #5042 Skip caching class lists longer than 2 KB in
html_cva()(@nicolas-grekas) - bug #5043 Don't cache Intl formatters built from long patterns, attributes, or symbols (@nicolas-grekas)
- bug #5044 Fully normalize template names in FilesystemLoader (@nicolas-grekas, @fabpot)
- bug #5039 Fix a variable not being escaped when it has the name of a macro import alias of another scope (@jack-worman)
- bug #4985 Normalize the template name in FilesystemLoader::getSourceContext() (@KalimeroMK)
- bug #4987 Fix compiled templates depending on the directory of their source when debug is disabled (@nicolas-grekas)
- minor #5009 Speed up the
withtag by adding the globals to the new context in place (@nicolas-grekas) - minor #5008 Speed up restoring the context after
forloops that set no variables (@nicolas-grekas, @fabpot) - minor #5007 Speed up
forloops that use theloopvariable without recursing (@nicolas-grekas, @fabpot) - minor #5005 Speed up iterating over the sequence of
forloops that use theloopvariable (@nicolas-grekas) - minor #5006 Speed up reading the attributes of the
loopvariable (@nicolas-grekas) - feature #5004 Speed up
forloops that do not use theloopvariable (@nicolas-grekas, @fabpot) - feature #4995 Allow extending AttributeExtension to declare callables with attributes (@GromNaN)
- bug #5017 Fix html_cva() ignoring a boolean default variant (@fabpot)
- bug #5014 Fix PHP 8.5 deprecation in html_cva() when a recipe value is null (@goba)
- feature #4997 Add the collate function to compare strings in the alphabetical order of a locale (@fabpot)
- feature #4989 [3.x] Allow registering an extension class lazily with
AttributeExtension(@nicolas-grekas) - feature #4991 Allow marking a Markup instance as safe for some escaping strategies only (@fabpot)
- feature #4990 Consider a class safe for html_attr also safe for html_attr_relaxed and html at runtime (@fabpot)
- bug #4992 Fix reading an attribute through its getter initializing a lazy object when the property is not public (@abp002)
- minor #4984 Speed up applying
html_cva()recipes that resolve to classes already seen (@Kocal) - bug #4988 Fix compiled float literals depending on the serialize_precision ini setting (@nicolas-grekas)
- minor #4954 Speed up loading compiled templates that OPcache already holds (@nicolas-grekas)
- minor #4976 Speed up traversing nodes with node visitors (@nicolas-grekas)
- feature #4951 Allow skipping the directory check when adding paths to
FilesystemLoader(@nicolas-grekas) - feature #4971 Always allow the safe built-in tags, filters, and functions in a sandbox (@fabpot)
- bug #4980 Fix the deprecated tag generating invalid PHP for an integer message (@fabpot)
- bug #4974 Fix the loop variable of a for tag being undefined in the sequence of a nested loop (@fabpot)
- bug #4979 Reject the spread operator outside sequences, mappings, and call arguments (@fabpot)
- feature #4966 Always allow the loop variable in sandboxed templates (@fabpot)
- feature #4967 Render the for else clause when the loop condition skips every item (@fabpot)
- bug #4970 Name the IntegrationTestCase data providers provideTests() and provideLegacyTests() like on 3.x (@fabpot)
- bug #4964 Discard what the non-selected branch of a guard tag registers on the parser (@fabpot)
- bug #4960 Reset the escaping state when compiling a new template after a compilation error (@fabpot)
- bug #4961 Reject an autoescape strategy that is neither a string nor false at compile time (@fabpot)
- bug #4959 Reject a Template instance created by another environment when resolving templates (@fabpot)
- bug #4972 Fix the sandbox not reporting the line of a rejected guard tag (@fabpot)
- minor #4965 Rewrite the sandbox documentation around what developers need to know (@fabpot)
- minor #4949 Skip the property checker call and memoize the class constant probe when reading an object attribute (@fabpot)
- bug #4947 Stop looking up a macro twice in its own namespace when it is declared by a parent (@fabpot)
- minor #4950 Fetch the escaper runtime once in the constructor of templates that escape (@fabpot)
- minor #4948 Compare the date formatter prototype pattern with the derived one once per pattern (@fabpot)
- bug #4946 Fix split trailing newline (@fabpot)
- minor #4945 Speed up adding extensions to an environment (@nicolas-grekas)
- feature #4941 Cleanup 4.x - Stop detecting echo and print in compiled nodes (@fabpot)
- minor #4940 Reuse the already resolved callable when compiling call arguments (@fabpot)
- minor #4939 Compile the generator guard as an unreachable yield instead of a yield from (@fabpot)
- feature #4938 Speed up loading a template that the environment has already loaded (@fabpot)
- bug #4937 Stop the escaping safe analysis from retaining every analyzed node (@fabpot)
- feature #4936 Allow to call
TemplateWrapper::unwrap()without arguments (@derrabus) - feature #4934 Expose the escaping strategy a template was compiled with (@fabpot)
- minor #4933 Improve macro call performance (@fabpot)
- bug #4932 Fix IntlExtension inheriting values derived by ICU from a date formatter prototype (@fabpot)
- bug #4931 Fix array access with a Stringable key on subclasses of ArrayObject and ArrayIterator (@fabpot)
- bug #4930 Report a clear error when a string cannot be split into characters (@fabpot)
- feature #4929 Deprecate cloning a Twig environment (@fabpot)
- minor #4928 Report the macro call parentheses deprecation once per call site and name the macro (@fabpot)
- feature #4910 Reject template wrappers from another environment (@fabpot)
- bug #4927 Report a clear error when using macros imported in a template body that was not rendered (@fabpot)
- feature #4926 Allow block chains to be composed of other block chains (@fabpot)
- feature #4925 Resolve block chains against the render context (@fabpot)
- bug #4924 Resolve constant parent templates once instead of on every lookup (@fabpot)
- bug #4923 Fix wrapping the Twig cache pool in a second tag aware adapter (@nicolas-grekas)
- feature #4917 Template runtime and block composition (@fabpot)
- bug #4918 Check that the use tag is allowed before resolving trait templates (@fabpot)
- bug #4922 Wrap dynamic parent expression errors (@fabpot)
- bug #4921 Fix
TemplateWrapper::hasBlock()andTemplateWrapper::getBlockNames()omitting environment globals (@fabpot) - bug #4916 Fix html_attr dropping style declarations whose value is zero (@dylanpulver)
- feature #4912 Cleanup PHPUnit compatibility (@fabpot)
- feature #4913 Fix include node signature (@fabpot)
- bug #4915 Fix the default filter fallback reusing a null-safe temporary variable (@lazerg, @fabpot)
- minor #4908 Remove the documentation comments compilation overhead (@fabpot)
- minor #4904 Release destructuring temporaries after assignment (@fabpot)
- bug #4909 Report regular expression errors from the matches operator (@fabpot)
- bug #4906 Deprecate prefixed macro definedness checks (@fabpot)
- bug #4907 Fix duplicate macro deprecation wording (@fabpot)
- bug #4905 Throw when list formatting fails (@fabpot)
- feature #4902 Remove lazy macro import resolution (@fabpot)
- bug #4900 Honor date formatter prototype calendars (@fabpot)
- bug #4899 Fix Stringable keys for ArrayAccess implementations (@fabpot)
- bug #4901 Evaluate object destructuring expressions once (@fabpot)
- bug #4896 Restore void return type compatibility for extension points (@fabpot)
- bug #4898 Reject destructuring patterns containing no variables (@fabpot)
- feature #4895 Extract
htmlAttrValue()fromhtml_attrfor standalone attribute rendering (@Kocal) - bug #4894 Fix an empty destructuring pattern triggering a PHP fatal error instead of a SyntaxError (@fabpot)
- feature #4893 Fix array destructuring from a Traversable (@iliaal, @fabpot)
- bug #4892 Register the missing extra callables in MissingExtensionSuggestor (@smnandre)
- bug #4891 Fix the empty comment "{##}" being lexed as a documentation comment opening (@Amoifr)
- feature #4871 Attach documentation comments to nodes (@fabpot)
- feature #4434 Add the include_only function (@fabpot)
- feature #4890 Add support for tempest/markdown in markdown-extra (@ker0x)
- feature #4881 Nested macro imports (@fabpot)
- feature #4878 Deprecate using parentheses when testing a macro with the defined test (@fabpot)
- feature #4851 Redesign macro calls and argument handling (@fabpot)
- feature #4854 Make the sandbox a first-class citizen with a dedicated Sandbox class (@fabpot)
- feature #4877 Deprecate macro calls without parentheses (@fabpot)
- feature #4876 Rename macro variable AST nodes (@fabpot)
- feature #4874 Normalize destructuring assignment targets (@fabpot)
- feature #4873 Deprecate duplicate macro definitions (@fabpot)
- bug #4867 Fix PHPStan errors on 4.x (@fabpot)
- bug #4859 Fix IntlExtension ignoring explicit formats when a date formatter prototype is set (@fabpot)
- feature #4852 [Intl] Add format_list filter using PHP 8.5's IntlListFormatter (@BreyndotEchse)
- bug #4856 Fix array access with a Stringable key on ArrayAccess objects using object keys (@fabpot)
- bug #4853 Throw a SyntaxError instead of a PHP fatal error when a macro argument is defined twice (@fabpot)
- bug #4850 Render backed enums using their backing value in the html_attr function (@fabpot)
- minor #4845 Add documention note about variable scope of override blocks in { embed ... only } (@andy-blum)
- minor #4843 Define macros at the template root in the cache macro fixture (@fabpot)
- bug #4841 Fix Markup truthiness in boolean expressions (@xtrime-ru)
- bug #4842 Fix a PHP 8.5 chr() deprecation when decoding octal string escapes (@austinderrick)
- feature #4292 Introduce a CorrectnessNodeVisitor to validate that templates are semantically correct (@fabpot)
- feature #4839 Enforce the sandbox Markup exception for every security policy (@fabpot)
- feature #4840 Mark Markup as final (@fabpot)
- feature #4838 Allow calling a macro with a dynamic name via the dot operator (@fabpot)
- bug #4835 Fix markdown_to_html mangling content that starts with a blank line (@fabpot)
- feature #4819 Add an allow-list for tests to the sandbox security policy (@fabpot)
- minor #4837 Reduce memory usage of the context restoration compiled at the end of for loops (@fabpot)
- feature #4816 Add an always_allowed_in_sandbox flag for filters, functions, and tags (@fabpot)
- feature #4834 Track the source offset of each token and expose it in syntax errors (@fabpot)
- minor #4836 Document how to customize the markdown_to_html converter (@fabpot)
- minor #4662 CoreExtension::getAttribute: small improvement regarding getter/isser/hasser (@gharlan)
- bug #4825 Make the include() function return a Markup object (@fabpot)
- bug #4830 Fix nested block() resolution when a directly rendered block calls parent() (@fabpot)
- minor #4827 Document {#--#} as the replacement for the deprecated spaceless filter (@fabpot)
- bug #4828 Stop reporting a skipped test in IntegrationTestCase when there is no legacy test to run (@fabpot)
- minor #4829 Document storing an enum in a variable to avoid repeating its FQCN (@fabpot)
- bug #4824 Cast printed expressions to string so values that cannot be converted to a string (arrays, non-
Stringableobjects, ...) report a usable stack trace at the print location (@stof, @fabpot) - feature #4826 Make IntegrationTestCase and NodeTestCase compatible with PHPUnit 11 (@fabpot)
- feature #4823 Skip the sandbox
__toStringcheck on arguments whose PHP parameter type cannot implicitly coerce to string (@fabpot) - bug #4822 Fix inconsistent array access with a Stringable key (@fabpot)
- bug #4821 Preserve IteratorAggregate identity in sandbox __toString walker (@fabpot)
- security #558 Fix sandbox filter/tag/function allow-list bypass when sandbox state changes between renders (@fabpot)
- security #cve-2026-48805 Fix sandbox bypass in deprecated internal wrappers (@fabpot)
- security #552 Fix sandbox __toString policy bypass via dynamic mapping keys (@fabpot)
- security #535 Fix sandbox
__toStringbypasses viaTraversableinjoin/replacefilters and thein/not inoperators (@fabpot) - security #534 Fix sandbox bypass in the "column" filter under SourcePolicyInterface (@fabpot)
- feature #4817 Add a strict mode to SecurityPolicy to opt-in to the 4.0 sandbox behavior for the extends/use tags and the parent/block/attribute functions (@fabpot)
- minor #4815 Document transitive behavior of allowed sandbox operations (@fabpot)
- minor #4814 Remove obsolete PHP 8.0 workaround for Closure::__invoke attribute access (@fabpot)
- feature #4813 Deprecate the fact that the
parent,block, andattributefunctions are always allowed in a sandboxed template (@fabpot) - bug #4812 Fix PHP 8.1+ implicit float-to-int deprecation in sandboxed array access (@fabpot)
- minor #4811 Set LANG=en_US.UTF-8 for the extra packages tests (@fabpot)
- minor #4810 Use modern PHPUnit for extra packages (@fabpot)
- minor #4809 Simplify code (@fabpot)
- bug #4807 Escape root profile name in HtmlDumper (@fabpot)
- bug #4808 Restrict allowed classes in Profile::unserialize() (@fabpot)
- feature #4803 Deprecate the "Twig\Sandbox\SourcePolicyInterface" interface (@fabpot)
- minor #4806 Remove Drupal integration tests (@fabpot)
- minor #4805 Replace FQCN with use statements in SandboxTest (@fabpot)
- minor #4805 Replace FQCN with use statements in SandboxTest (@fabpot)
- security #cve-2026-46627 Document that the sandbox doesn't protect against resource exhaustion (@fabpot)
- security #cve-2026-46628 Pre-escape HTML input on the
spacelessfilter (@fabpot) - security #cve-2026-46634 Document template_from_string caveats when used in a sandboxed env (@fabpot)
- security #cve-2026-46635 Fix sandbox bypass in the "column" filter (@alexandre-daubois)
- security #cve-2026-47732 [Sandbox] Fix __toString() support (@fabpot)
- security #cve-2026-47730 [Profiler] Escape template and profile names in
HtmlDumper(@nicolas-grekas) - security #cve-2026-46640 Fix sandbox bypass: PHP code injection via _self / import macro reference (@alexandre-daubois, @fabpot)
- security #cve-2026-46638 Fix sandbox bypass in the
{ sandbox }tag when including a preloaded template (@alexandre-daubois) - security #cve-2026-46633 Fix sandbox bypass: PHP code injection via { use } template name (@alexandre-daubois, @fabpot)
- security #cve-2026-46629 Fix unbounded memoisation of
IntlDateFormatter/NumberFormatter(@alexandre-daubois) - security #cve-2026-46637 Fix XSS and pre-escape input on HTML-emitting filters in the extras (@nicolas-grekas)
- security #cve-2026-46639 Fix sandbox bypass in object destructuring assignment (@alexandre-daubois)
- security #cve-2026-24425 Fix sandbox bypass: propagate Source to checkArrow for source-policy sandboxing (@fabpot)