Return a cacheable response from TimezoneController
1 unresolved thread
Closes #3514879
Merge request reports
Activity
added 1 commit
- ea8d303e - Updates tests to validate cacheable response
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 It is addressing a different issue, but it's somewhat a prerequisite to get caching to work.
Without this,
$is_daylight_saving_time
can beNULL
when it is passed totimezone_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 toMessenger
which will trigger the page cacheKillSwitch
(seeMessenger::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