Problem/Motivation

In the past, an extensive piece of code was introduced, mainly to circumvent the 'page_cache' page caching for Anonymous users.
The 'page_cache' module expects a page to be valid forever, and setting a 'max_age' variable, to indicate the life-time of a page/block/... , was discarded.
From page_cache-help: 'On the Performance page, you can configure how long browsers and proxies may cache pages based on the Cache-Control header; this setting is ignored by the Internal Page Cache module, which caches pages permanently until invalidation, unless they carry an Expires header. There is no other configuration.'

In the mean time, in office_hours module, the 'status' subfield was introduced in #3501772: Add computed subfield "status" and use it in Views Filter.
Testing shows that the old code is not needed anymore.
Note: It could also be that some core improvement was done in D11.1 or earlier.
- Page Cache module's response headers improved Introduced in version: 11.1.0, 10.4.0
- The DynamicPageCacheSubscriber weight has changed from 100 to 7 Introduced in version: 11.1.0, 10.4.0
- New variation cache for caching something with cache contexts (replaces render cache) Introduced in version: 10.2.0

Steps to reproduce

Case 1: Node view page
- Have core module "Internal Page Cache" (machine name = 'page_cache') enabled.
- Create a content type with office_hours,
-- use the 'Table select list' formatter which displays the open/closed status
-- or use the 'Table' formatter, and enable 'current status' in its settings
- As an authenticated user, edit a node with office_hours, with closing time in the near future; Save
- Refresh the node page, until the closing time is reached. The formatter now changes correctly from 'currently open' to 'currently closed'.
- Repeat above, but refresh the node page as an Anonymous user. In an older version of office_hours, the formatter would not update if the closing time passes. In newer version, the 'office_hours.status_update' was triggered, and JS does a second calculation of the field value, each time the page is refreshed.

Case 1: Views view page
- Create a Views display page with office_hours field with formatter as above (2 cases)
- Set the cache settings to none/tage/time, as required.
- Also add a 'status' field as a new column.
- Test as above, with and without the status field

Proposed resolution

Apply attached patch to test if above presumptions are correct.
The patch disables the active code for 'status_update'. Check if above test still works, and report back.

Remaining tasks

- get response from user base, from older issues
- remove all related code

User interface changes

None.

API changes

- The controller class StatusUpdateController.php will be removed
- The formatter will not call the 'status_update' anymore (as implemented in OfficeHoursFormatterBase.php)
- The js-file js/office_hours_status_update.js will be removed, and its declaration in office_hours.libraries.yml
- The routing office_hours.status_update will be removed from office_hours.routing.yml
- In theme hooks, a varaible will be removed.

Data model changes

Comments

johnv created an issue. See original summary.

johnv’s picture

Issue summary: View changes
johnv’s picture

Please downloaded dev version or latest active version, apply patch and report back.

johnv’s picture

Issue summary: View changes

Hmm, after some testing, in Views, both Field formatter and subfield stay unchanged :-(
Even on node page, the data is not updated.
Need to investigate more, why it worked before. (It was checked that no js file was loaded, using [F12] developer options.)

socialnicheguru’s picture

Status: Active » Needs work
johnv’s picture

Issue summary: View changes
johnv’s picture

I understand now why sometimes the caching test have the proper results. When executing dpm(), a KillSwitch is triggered by the dvel devel.dumper. That way , the page is NEVER cached, and fresh data is always served.

function dpm(...): mixed {
  Drupal::service('devel.dumper')->message(..);
}
johnv’s picture

Title: Eliminate 'status_update', since the Open/Closed status is now Computed, and page cache is no hurdle anymore » Eliminate 'status_update', since the Open/Closed status is now Computed, and page cache for anymymous usersis no hurdle anymore
Issue summary: View changes
Status: Needs work » Postponed

OK, so I was mislead by my test artefacts...
Let us postpone this until better times come.
ITMT, I will keep an eye on :
- #3506462: Fix field cache for anonymous users by implementing a hook/listener
- page_cache issues