Skip to content
Snippets Groups Projects

Return a cacheable response from TimezoneController

1 unresolved thread

Closes #3514879

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
39 44 $is_daylight_saving_time = min(1, max(-1, intval($is_daylight_saving_time)));
40 45 // Catch if out of boundary.
41 46 if ($original !== $is_daylight_saving_time) {
42 return new JsonResponse(FALSE);
47 return (new CacheableJsonResponse(FALSE))->addCacheableDependency($cacheable_metadata);
43 48 }
44 49 }
50 else {
51 // If no daylight saving time indicator was specified, default to -1
  • This part is the only thing I'm not sure about, seems to be addressing another issue maybe?

  • It is addressing a different issue, but it's somewhat a prerequisite to get caching to work.

    Without this, $is_daylight_saving_time can be NULL when it is passed to timezone_name_from_abbr. As of PHP 8, this will generate a deprecation notice. And, depending on the current settings, a PHP notice will add a message to Messenger which will trigger the page cache KillSwitch (see Messenger::addMessage).

    So, while the controller can return a cacheable response without this change, the response will likely not end up getting cached due to the PHP notice.

  • Please register or sign in to reply
  • Stephen Mustgrave left review comments

    left review comments

  • Please register or sign in to reply
    Loading