Views with Open/Closed status are not updated (for anonymous users)

Created on 5 April 2024, 9 months ago
Updated 19 September 2024, 3 months ago

I encounter the following problem in one of our projects.
I made a view (block) from my customer office hours and displayed that on their website as status option. When they are open or closed the status doesn’t change from “currently open” or “currently closed” for not logged in users (anonymous). When you clear the cache the status is correct for all user. It seems that the problem is only for anonymous users.

Our configuration :

D10.2.4
PHP 8.2.16
Office Hours 8.x-1.17

Can someone give us some tips where we can find any solution to solve that problem?

🐛 Bug report
Status

Active

Version

1.17

Component

Code

Created by

🇧🇪Belgium Mav_fly

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Mav_fly
  • 🇧🇪Belgium Mav_fly

    I did some more tests and saw that also the problem exist with authenticatd users.
    The status is only updated after clearing the cache.

  • 🇳🇱Netherlands johnv

    OK, I was surprised, since the new version explicitly addressed the caching.
    Please uncheck the caching in your view. It is hidden under the 'Advanced' section in the third column of the View configuration screen.

  • Status changed to Active 9 months ago
  • 🇳🇱Netherlands johnv

    changing to a normal bug. Also, 'Needs work' is only to be used if a patch is applied an reviewed.

  • 🇧🇪Belgium Mav_fly

    @johnv I followed your advice and uncheck “caching” in my view (see the attachment).
    And did some more research as result :

    - When you visit the website form a new browser the status is correct.
    - When you already visited the website and open the website in a new tab without closing your browser, or refresh the page then the status is incorrect.
    This is for anonymous users.
    - When you visited the website as authenticated user and you refresh the page or open the website in a new tab the status is correct.
    - After clearing the cache the status is for everyone correct authenticated and anonymous user

  • 🇳🇱Netherlands johnv

    Please check if the patch from 🐛 Views filter 'current open/closed status' does not work Needs review helps.

  • 🇧🇪Belgium Mav_fly

    I tried the patch #6 but it didn't solved my problem.
    I saw also that it failed for "PHP 8.1 & MySQL 5.7, D10.2.1 Patch Failed to Apply".

    And our configuration is :
    D10.2.4
    PHP 8.2.16

  • 🇳🇱Netherlands johnv

    You state that the problem is in views.
    Let's verify your basic behaviour. Please test with a normal entity page view with the formatter setting 'Current status/Current status position' set to before or after the hours.
    Both for anonymous and authenticated users.

  • 🇧🇪Belgium Mav_fly

    As you asked I made a normal entity page view with the formatter setting 'Current status/Current status position' set to before or after the hours.
    In attachement you the results after refreshing the page when the customer was closed.

  • 🇳🇱Netherlands johnv

    Hmm, it seems there is a problem with public function getNextDay(int $time), which receives a Unix timestamp, and calls $status = $item->getStatus($time), that expects a HHMM time.

    • johnv committed 9e32b80f on 8.x-1.x
      Issue #3438820: Views with Open/Closed status are not updated
      
  • 🇳🇱Netherlands johnv

    Please test the new -dev version and report back.
    The problem was that the Season~isInRange() function was not correct. Therefor, the time wat replaced by a date early in the process, corrupting the isOpen() status.

    • johnv committed 21734d90 on 8.x-1.x
      Issue #3438820: UnitTest - You have requested a non-existent service...
    • johnv committed 6dfa2458 on 8.x-1.x
      Issue #3438820: UnitTest - You have requested a non-existent service...
  • Status changed to Needs review 8 months ago
  • 🇧🇪Belgium Mav_fly

    Is it correct that today 19/4 there is a new release of the dev version ?

  • 🇳🇱Netherlands johnv

    Indeed, but please do not use it . I am in the middle of a development.

  • 🇧🇪Belgium Mav_fly

    Ok but we have now installed the dev version of 19/4 but leave it now like that until you give further instructions.

  • 🇳🇱Netherlands johnv

    You can now use the most recent dev-version.

  • 🇧🇪Belgium Mav_fly

    We updated to the latest dev version (see attachment) but the problem isn't solved.

  • 🇮🇳India aman1248

    Hello @johnv, the latest development version does not have such an error; it's working absolutely fine on my project.

  • 🇮🇳India aman1248

    "@Mav_fly, could you please provide detailed steps to reproduce the error that's occurring on your end?"

  • 🇧🇪Belgium Mav_fly

    @Amandeep123 how to reproduce :

    - We made a new content type “contact”
    - In this content type we made a field “opening hours “ from office hours, in which we put the hours of our customer.
    - Create a view block from fields content type “opening hours” where we get the field office hours.
    Specifications block
    Format of the field office hours --> “Status”
    Caching --> “no”
    - And then put this block in the leaderboard.

  • 🇮🇳India aman1248

    Hy @Mav_fly , I followed the step to reproduce the error and encounter the same error that you are facing .

  • 🇧🇪Belgium Mav_fly

    Hi, Amandeep123 thanks for the feedback!

    @johnv, you have any idea what the problem problem could be ?

  • 🇳🇱Netherlands johnv

    @Mav_fly, no I don't,
    I can test again. I have a test system with only Drupal, and the 2 standard caching modules (for authenticated and anonymous users - the latter gives me many headaches)

    Do you have any other caching services in place, like Varnish or 'reverse proxy'?

  • 🇧🇪Belgium Mav_fly

    @johnv I don't have this kind of cashing services.

    • johnv committed 7e9f7bed on 8.x-1.x
      Issue #3438820: status field cache time status is calculated incorrect
      
  • 🇳🇱Netherlands johnv

    The caching time was calculated incorrectly. Please test dev version.

  • Status changed to Fixed 7 months ago
  • 🇳🇱Netherlands johnv

    A fix was committed in 🐛 Views filter 'current open/closed status' does not work Needs review . There is still a problem with caching for anonymous users. please disable the view's caching.

  • Status changed to Active 7 months ago
  • 🇳🇱Netherlands johnv

    Hmm, disabling the cache does not help refreshing for anonymous users. Perhaps filtering must move from _pre_render to _post_render.

  • 🇧🇪Belgium Mav_fly

    @johnv we installed the latest dev version as asked, but the problem stil exist :(

    @Amandeep123 Did you test already the lastest dev version ?

  • 🇧🇪Belgium Mav_fly

    There have already been new developments for this issue ?
    Because I still have this problems in one of my projects.

    Thanks in advance

  • 🇳🇱Netherlands johnv

    No, maintainer is out of options to resolve this problem.

Production build 0.71.5 2024