Add getLastModified() to extensions#4513
Conversation
2b3cd04 to
3a94244
Compare
|
Do we need to add it to the interface ? Could we not simply ignore extensions not implementing this interface ? |
|
Is it a thing to implement the interface without extending the abstract class? Adding this method should not be an issue for the large majority of projects, but it helps keeping the code simple. |
|
Well this may break external extensions in prod ... but you're right:
|
"large majority" is not enough when talking about BC breaks :) Let's add a proper interface as this is a new capability (we've done it in the past with |
036e48b to
36ddfc4
Compare
Ok, interface added. I'll also add automatic detection of |
4fdc4b7 to
d8bc954
Compare
ExtensionInterface::getLastModified()getLastModified() to extensions
d8bc954 to
a6b96ab
Compare
|
@GromNaN LGMT, can you add a note in the CHANGELOG (you will need to rebase as I've just bump the version to 3.19.0)? |
…xtension` to track modification of runtime classes
a6b96ab to
d8fe3bd
Compare
|
Rebased, squashed, changelog updated. |
|
Thank you @GromNaN. |
Give to extensions the ability to set a last modification date for cache invalidation.
Runtime
Currently, the cache is not invalidated when the signature of a runtime method is modified. This is an issue for templates that use named arguments, as argument names have an impact on the generated class.
With this change, extensions using runtime classes can compute a modification date by including the files on which they depend.
By default, the
AbstractExtensionchecks if there is a file for the runtime class with the same name of the extension suffixed by Runtime instead of Extension.This is the convention applied in Symfony and Twig Extra:
MarkdownExtensionhasMarkdownRuntime.Attribute
Contributing to #3916.
The extension class that will get the configuration from attributes will be able to track the classes having attributes to find the last modification date of all this classes.
BC breakIn Twig 4.0, the methodgetLastModifiedwill be added toExtensionInterface. It is extremely rare to implement this interface without extendingAbstractExtension. So adding this method to the interface shouldn't be a problem as the base class has an implementation.