Vote::postSave() overrides ContentEntityBase::postSave() without calling the parent method. Because of that, a couple of things that should run don't. Most importantly the list cache tag for votes is not invalidated, so that views e.g. views of votes are not re-calculated when a new vote is created.

Comments

tstoeckler created an issue. See original summary.

tstoeckler’s picture

Status: Active » Needs review
StatusFileSize
new787 bytes

This fixes the issue for me, simply by calling the parent function.

dunebl’s picture

I think this patch needs to be rerolled:

patching file src/Entity/Vote.php
Hunk #1 FAILED at 256.
Hunk #2 succeeded at 262 (offset -3 lines).
1 out of 2 hunks FAILED -- saving rejects to file src/Entity/Vote.php.rej
idebr’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new792 bytes
rpayanm’s picture

Issue tags: -Needs reroll
hkirsman’s picture

Was going to remove the caching myself until saw this - smarter fix :)

Tx!

hkirsman’s picture

Status: Needs review » Reviewed & tested by the community
pifagor’s picture

Status: Reviewed & tested by the community » Needs work
mrinalini9’s picture

Status: Needs work » Needs review
StatusFileSize
new891 bytes

Rerolled patch #5 for 8.x-3.x branch as it failed to apply, please review.

tr’s picture

Status: Needs review » Needs work
src/Entity/Vote.php ✗ 1 more
line 5	Unused use statement
mrinalini9’s picture

Status: Needs work » Needs review
StatusFileSize
new1.09 KB
new325 bytes

Removed unused use statement as per mentioned in #11, please review.

tr’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!

pifagor’s picture

  • pifagor committed 101b793 on 8.x-3.x authored by mrinalini9
    Issue #2898847 by mrinalini9, tstoeckler, rpayanm, pifagor, TR, hkirsman...
pifagor’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

a.dmitriiev’s picture

Thanks for the fix, when it will be in the stable version?

I would also like to know why these lines were removed:

$cache_tag = $this->getVotedEntityType() . ':' . $this->getVotedEntityId();
 Cache::invalidateTags([$cache_tag]);

Does voted entity already include the vote cache tags? For example, will the page with cache for the node, that I am rating, be updated after the vote is added/updated?

a.dmitriiev’s picture

Maybe it is good idea to keep those tags in the list of the ones that should be invalidated? I also re-rolled the patch for 8.x-3.0-beta2 because the fix is not in a stable version.