To reproduce:

- start with a site with no user flags (such as on initial install of Flag)
- add a view of users
- notice there is no 'user flag' relationship, because there are no user flags yet
- add a user flag
- go back to the view and add a relationship: there is still no 'user flag' relationship, even though there is a user flag now.
- clear caches
- user flag relationship is now visible

Adding or deleting a flag should therefore clear Views data caches. For bonus points, only clear them when we're adding a flag of a type that doesn't exist yet / deleting the last flag of its type.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

zahord’s picture

zahord’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 2629180-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

zahord’s picture

zahord’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: 2926180-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

socketwench’s picture

There is an older patch for this which contains the fixes for the Flag entity: https://www.drupal.org/project/flag/issues/2851054#comment-12412982

+++ b/tests/src/FunctionalJavascript/FlagContextualLinksTest.php
@@ -157,6 +157,7 @@ public function setUp() {
+    $this->container->get('views.views_data')->clear();

I'm still concerned about this line, though. Why are we clearing the views cache in a test?

andypost’s picture

This issue should be focused on adding tests cos I failed to write ajax tests for views relation in #2851054-12: Cannot add Flags relationship to views. Getting AJAX error

+++ b/tests/src/FunctionalJavascript/FlagContextualLinksTest.php
@@ -157,6 +157,7 @@ public function setUp() {
+    $this->container->get('views.views_data')->clear();

this no longer needed cos flags do clear cache on save/delete now

andypost’s picture

Title: adding a flag should clear the Views data cache » adding a test that makes sure cache cleared when flag added deleted

case for test still valid in IS

socketwench’s picture

Priority: Normal » Critical

Bumping status since this is holding up other views improvements.

arunkumark’s picture

Status: Needs work » Needs review
FileSize
1.93 KB

I have re-rolled the patch to resolve the issue with the suggestion from the comment #10

Status: Needs review » Needs work

The last submitted patch, 12: 2926180-12.patch, failed testing. View results

socketwench’s picture

Thanks for the patch @arunkumark, but the postSave() and postDelete() are already part of the Flag entity.

@andypost Do we still need the views clears in the tests?

andypost’s picture

If was commited as I remember, here we should add a test and remove manual cleaning from otger tests

andypost’s picture

Berdir’s picture

Title: adding a test that makes sure cache cleared when flag added deleted » Add a test to ensure that views data cache is cleared when flag added/deleted
Category: Bug report » Task
Priority: Critical » Normal
Issue tags: -Needs tests

That sounds like a normal task and not a critical bug then now? Also can't find any manual views data cache clears in test, being able to remove those would have been easy test coverage.