Problem/Motivation
#2143249: Remove legacy cache_clear_all() in cron removed cache_clear_all() from scheduler_cron(). But in some cases, it is actually useful. For example: you enabled page cache for anonymous users and configured Elysia Cron Module to run system_cron less frequent than scheduler_cron.
Proposed resolution
The same as originally proposed in #2143249: Remove legacy cache_clear_all() in cron: add an option to still call cache_clear_all().
Make it unchecked by default to provide seamless backwards compatibility.
User interface changes
On admin/config/content/scheduler you get a checkbox labeled 'Upon publish or unpublish, clear all expired block and page caches.'.
API changes
A new variable, called scheduler_cache_clear_all.
Comment | File | Size | Author |
---|---|---|---|
#23 | 2377201-23.clear_page_cache_on_scheduler_cron.d7.patch | 7 KB | jonathan1055 |
|
Comments
Comment #1
PieterDCAttaching patch. Includes: test coverage, an admin UI form element, a Drupal variable with a default value and removal at module uninstall.
Comment #3
jonathan1055 CreditAttribution: jonathan1055 commentedI think the testbots are having trouble. I have seen this error on a different project an hour ago. I don't think it's anything to do with your patch.
I will test your patch and review it. Thanks
Comment #4
PieterDCTest fails because of an error reported in #2375345: Dependency on core module results in PHP Fatal error: Cannot redeclare system_requirements().
Set this issue back to 'Needs review' once the blocking issue is fixed.
Comment #5
jonathan1055 CreditAttribution: jonathan1055 commentedAlso, just to let you know, we had a major effort to get all existing 7.x issues and patches committed before we released 7.x-1.3. The one issue remaining which was too dangerous to rush through is #2170353: Reduce memory footprint which is going to be the next commit as it touches the whole of .module. If we commit anything else before that one, then it will need constant re-rolls, so we decided that this will be the first, and any other patches can then be re-rolled.
Comment #6
jonathan1055 CreditAttribution: jonathan1055 commentedJust an idea, are you using the lightweight scheduler cron to have cron run more often than the full cron? If so, we could just add the cache_clear_all() in to function _scheduler_run_cron(). Maybe we should do that anyway, now that it's not done in scheduler_cron()?
Comment #7
PieterDCNo, we're not. We use Elysia cron to configure cron task frequencies. The Scheduler lightweight cron doesn't show up in that list.
But you're right, using the lightweight scheduler might be another use case. So maybe we should extend the description of the provided checkbox to include an explanation that you're advised to use this new feature if you use Scheduler lightweight cron.
Comment #8
jonathan1055 CreditAttribution: jonathan1055 commentedThis looks good.
.install - all ok
.module - need to adjust the text as per #7 above. The checkbox gets a bit lost on the page, having no title, but that's not your fault. However, I can't see it would be better in any other place on the form.
.test - you've done a lot of work here. Particularly, you have changed the way we test for the basic published/unpublished node by going to the node and testing for response 403, instead of asserting that node body text is not on the front page. I like that. Thanks also for documenting the @param descriptions. These early tests were written by neither of the current maintainers - we'd always add descriptions ;-)
I'm not sure we need such an amount of detail about Elysia Cron in the .test file. You can reference this issue to give background for future maintainers.
The above is only one opinion, I'd like Pfrenssen's view on this too.
Comment #17
bertramakers CreditAttribution: bertramakers commentedI reviewed this as part of a bigger (internal) ticket that I'm working on with PieterDC where we work, and the patch seems fine to me as well.
I agree that the example explanation of Elysia cron might be unnecessary, but I'll let you guys decide about that.
But if I understood correctly this will need to be re-rolled after #2170353: Reduce memory footprint is committed, so we'll need to follow this up later.
Not setting this to RTBC so we can await Pfrenssen's opinion if he wants to pitch in.
Comment #18
jonathan1055 CreditAttribution: jonathan1055 commentedHi bertramakers, yes you are right, the code split patch was always going to be the first commit after releasing 7.x-1.3. That has now been done so you can re-roll your patch.
Comment #19
iSoLate CreditAttribution: iSoLate at Randstad Digital for Government of Flanders commentedComment #20
iSoLate CreditAttribution: iSoLate at Randstad Digital for Government of Flanders commentedThis seems to apply and do the trick still.
Comment #21
jonathan1055 CreditAttribution: jonathan1055 commentedHi iSoLate,
The patch applies OK to the release 7.x-1.3 but it no longer applies to the 7.x-dev code, as per the comments in #17 and #18. I cannot find a way to re-queue the existing patch, maybe because testing is no longer done on qa.drupal.org and has been superseded by DrupalCI.
Hence I have re-added the same patch from #1 here, to see what happens.
Comment #23
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedAs expected the existing patch does not apply. Here's a re-rolled version for the latest 7.x-1.x-dev code. I moved the new checkbox into the lightweight cron tab, as it is only really required when not running the full cron.
This feature will have to be added to the 8.x code first.
Comment #24
pfrenssenThis has its use case on Drupal 7. It's a bit of a shotgun approach, and it's not _really_ Scheduler's responsibility and a bit of an edge case, but I can understand that this can be useful in situations such as explained in the issue summary. Since it is disabled by default this does not harm anyone.
In Drupal 8 this should not be needed. Thanks to the adoption of cache tags if a piece of content is published or unpublished, all related cache entries will automatically be invalidated. There is luckily never a need to do a full cache clear on a production instance on Drupal 8.
I would add a warning here that enabling this can have a serious impact on performance.
Comment #25
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThanks @pfrenssen for the explanation about Drupal8 tags. I was hoping that this was not going to be required in 8.x
I added a warning as you suggested. The full description is now
Thank you @PieterDC for the initial patch. Committed and fixed (although the auto-comment for the commit has not shown up yet).