I set a scheduled site alert and it wouldn't appear at the time until I cleared drupal cache or go away after the end time until I cleared drupal cache or delete the alert.

Steps to reproduce:

Schedule a timed alert
At that time go to the homepage - should not be there
Clear drupal cache
Now it should show up.

After the expire time
Alert should still be there
Clear drupal cache
Now it should be gone.

Comments

ntaylor1994 created an issue. See original summary.

ntaylor1994’s picture

Issue summary: View changes
chrissnyder’s picture

Can you confirm that you are using version 1.3? As there was a fix that included in 1.3 for scheduled alerts.

In addition, do you have any other caching plugins or frontend caches you are using (varnish, Nginx, etc)?

ntaylor1994’s picture

StatusFileSize
new3.01 KB

I can confirm 1.3 version, it's on my local environment so no varnish or anything.

I need to time it for, lets say 11:00am - 11:10am.

at 11:01am, I notice it's not showing up. So I run a drush cr. About halfway through the drush cr, the site alert shows up. (So the ajax is working)

Same for after 11:10am. It's still there, I clear drupal cache, and it goes away.

ntaylor1994’s picture

UPDATE:

When I remain logged in, the site alert will appear, and stay when I log out. The problem is when I set the timed alert then log out before that time, I need to clear cache in order to see it.

ntaylor1994’s picture

And for removing it, if it's passed the time, if I log in, the site alert will disappear to authenticated users, but not to the public. To me, it has sometime to do with like caching or permissions. Anonymous users will still see the alert if an authenticated user has not logged in and cleared cache once the alert is scheduled to come down, or someone runs drush cr command.

chrissnyder’s picture

chrissnyder’s picture

Status: Active » Needs review
StatusFileSize
new2.72 KB

I have added additional information to the response to allow Drupal's page cache to invalidate the alerts in the cache when the next scheduled alert is due to be removed as Drupal core's Page Cache module does not respect the max age on the response header.

  • chrissnyder committed 2b63c5d on 8.x-1.x
    Issue #3154620 by chrissnyder, ntaylor1994: Timed site alerts aren't...
chrissnyder’s picture

Status: Needs review » Fixed
chrissnyder’s picture

Note... if using redis as a cache backend, there may still be an issue. This may be related https://www.drupal.org/project/redis/issues/2877893 I am investigating.

chrissnyder’s picture

Status: Fixed » Needs work
chrissnyder’s picture

Patching the redis module with the patch from this comment corrected the issue when using Redis as the cache backend.

chrissnyder’s picture

Version: 8.x-1.3 » 8.x-1.x-dev
StatusFileSize
new12.13 KB

Additional patch to account for scheduled alerts that are not yet visible. This patch was made against the 1.4 version

  • chrissnyder committed 05fa052 on 8.x-1.x
    Issue #3154620 by chrissnyder, ntaylor1994: Timed site alerts aren't...
chrissnyder’s picture

Status: Needs work » Needs review
chrissnyder’s picture

Version: 8.x-1.x-dev » 8.x-1.4

chrissnyder’s picture

Additional patch to account for feedback from @bradleyfmash. See https://git.drupalcode.org/project/sitewide_alert/-/commit/05fa05206b46c...

  • chrissnyder committed 5f4d0e3 on 8.x-1.x
    Issue #3154620 by chrissnyder, ntaylor1994, bradleyfmash: Timed site...
chrissnyder’s picture

The latest changes have been made to the 8.x-1.x (dev) branch.

chrissnyder’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.