Problem/Motivation

"Flush views caches" is the submenu of main "Flush all caches" menu. But when you click "Flush all caches" button the Views cache don't flush that is really confused:

Flush views cache

It happends because the drupal_flush_all_caches() function don't trigger views_invalidate_cache()

Steps to reproduce

To clear the cache of views uses the method views_invalidate_cache() so here the steps how to check that this method not triggers while clearing ALL site caches:

  1. Enable views module
  2. Open web/core/modules/views/views.module and set breakpoint to the views_invalidate_cache():
    Breakpoint
  3. Go to admin/config/development/performance
  4. Enable debugging and press "Clear all caches"
  5. Check that debug session was finished without being paused on views_invalidate_cache() function

Proposed resolution

Add hook_cache_flush() to views module that will be fired by drupal_flush_all_caches().

CommentFileSizeAuthor
#9 Screenshot_6.png93.83 KBfromme
#3 3370975-3.patch473 bytesfromme
flush_views_cache.png44.16 KBfromme

Comments

fromme created an issue. See original summary.

fromme’s picture

Issue summary: View changes
fromme’s picture

StatusFileSize
new473 bytes

Here patch that add hook_cache_flush() to views module. This solves the problem.

fromme’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

As a bug will need a test case to show the problem.

norman.lol’s picture

Category: Bug report » Feature request
norman.lol’s picture

Title: Views caches don't flush after click on "Flush all caches" button » Implement hook_cache_flush() in Views module to be picked up by drupal_flush_all_caches()
longwave’s picture

Status: Needs work » Postponed (maintainer needs more info)

In the steps to reproduce it says "Check that view cache not flushed" - can you explain in more detail (or with a concrete example) how you check this?

views_invalidate_cache() repeats some of the work that is done by drupal_flush_all_caches() so it would be better to diagnose and fix the exact issue if possible.

fromme’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Needs work
StatusFileSize
new93.83 KB

@longwave, i updated steps to reproduce

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

nicxvan’s picture

Status: Needs work » Closed (works as designed)

@fromme I think you may have missed @longwave's point.

We don't need to do this, drupal_flush_all_caches does everything views_invalidate_cache does except invoke hook_views_invalidate_cache.

views_invalidate_cache

  1. Sets route rebuild
  2. Resets views route subscriber
  3. Clears block plugin cache
  4. Invokes views_invalidate_cache

drupal_flush_all_caches

  1. Invokes hook_cache_flush
  2. Invalidates cache tags
  3. Deletes caches
  4. Deletes CSS
  5. Deletes JS
  6. Resets asset query string
  7. Static reset
  8. Extension related resets except modules
  9. Container rebuild
  10. Module reset
  11. Invoke hook_rebuild
  12. Clear all plugin caches (step 3 above)
  13. Rebuild routes (step 1 and 2 above)

I don't think that drupal_flush_all_caches should invoke views_invalidate_cache but that is the only thing that doesn't happen.
Just because that function doesn't execute when it's clicked doesn't mean that the actions don't take place.

I am going to close this as works as designed since views caches are cleared when flush all caches is clicked even if this specific function does not run.

If I missed something else, feel free to reopen this.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.