Problem/Motivation

The workflow participants tab does not show up for users who viewed a node immediately prior to being added as a workflow participant. Steps to recreate:
Create a node as user A, who has permission to manage workflow participants for their own content.
Login and view the node as user B, who does not have any permission to manage workflow participants in any capacity.
Logout as user B, and login as User A. Add user B as an editor, and save.
Logout as user A, and visit the node as User B.
The workflow participants tab does not show up, but it should.

Proposed resolution

Provide a definition for getCacheTagsToInvalidate() in the WorkflowParticipants entity, and use the cache tags from the moderated entity as the tags to invalidate.

Remaining tasks

Write a patch, review.

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#4 2876198-04-TEST-ONLY.patch1.39 KBjhedstrom

Comments

mroycroft created an issue. See original summary.

jhedstrom’s picture

That's odd--the entity does implement getCacheTags():

  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {
    return Cache::mergeTags(parent::getCacheTags(), $this->getModeratedEntity()->getCacheTags());
  }
mroycroft’s picture

The proposed fix is to override this function from Entity.php

 /**
   * {@inheritdoc}
   */
  public function getCacheTagsToInvalidate() {
    // @todo Add bundle-specific listing cache tag?
    //   https://www.drupal.org/node/2145751
    if ($this->isNew()) {
      return [];
    }
    return [$this->entityTypeId . ':' . $this->id()];
  }

The idea is that inside the workflow participants entity, to provide the cache tags to invalidate for the workflow participants entity, and the moderated entity in which the workflow participants are attached to. This this data is available on from the getCacheTags() method, it could be as simple as calling that function inside of getCacheTagsToInvalidate()

jhedstrom’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new1.39 KB

I wasn't able to reproduce this. Here is a test that attempts to mimic the steps outlined above, but it is passing. (It's possible this has been fixed elsewhere in the 2.x version).

jhedstrom’s picture

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

Postponing for clarification for the time being.

mroycroft’s picture

Version: 8.x-2.x-dev » 8.x-1.x-dev
Status: Postponed (maintainer needs more info) » Active

Hmm, can't apply patch for the 8.x-1.x version, which is where the issue was originally reported. Tester doesn't allow an appropriate Drupal version to be picked for 8.x-1.x testing. I agree, it does appear to not be an issue in the 8.x-2.x version.

If 8.x-1.x development is halted, this should be probably closed as won't fix. For now, switching the version back to 8.x-1.x.

mroycroft’s picture

I did test this on the 8.x-1.x version and the test does fail at $this->assertSession()->linkExists(t('Workflow participants'));. So it's fixed in 8.2 branch but broken in 8.1.

This might be a handy test to keep, in case there is an issue with cache tags in the future.

  • jhedstrom committed bd1758e on 8.x-2.x
    Issue #2876198 by jhedstrom, mroycroft: Node cache tags aren't...
jhedstrom’s picture

Status: Active » Fixed

Good idea to keep the test! Committed to 2.x. Thanks!

Status: Fixed » Closed (fixed)

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