Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By mpdonadio on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.1.x
Introduced in version:
8.1.9
Issue links:
Description:
#2500525: Time ago/hence date/time formatting breaks caching; needs appropriate max age introduced the FormattedDateDiff object. It mistakenly has a method ::getMaxAge() to get the TTL for the render array for this object. Since this object implements CacheableDependencyInterface(), the proper method to implement is ::getCacheMaxAge().
Instead of using
$max_age = $formattedDateDiff->getMaxAge();
use
$max_age = $formattedDateDiff->getCacheMaxAge();
The ::getMaxAge() method has been marked as deprecated in 8.1.9 and will be removed before Drupal 9.0.0.
Impacts:
Module developers