Problem/Motivation

When publishing a pending revision, the entity is loaded and cached via entity_load() and then the database is updated in _revisioning_publish_revision(). The entity cache is never reset resulting in future calls to entity_load() returning the previously published revision of the entity that was cached. This became a problem when I expected data in the newly published revision to be indexed by Search API, but because the entity cache is never cleared, Search API loads the previously published revision and indexes that.

Proposed resolution

After updating the database, we should re-load the node resetting the entity cache.

Remaining tasks

  • Review the patch
  • Commit
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jantoine’s picture

Assigned: jantoine » Unassigned
Issue summary: View changes
Status: Active » Needs review
FileSize
935 bytes

The attached patch reloads the node directly after updating the database.

RdeBoer’s picture

Thanks for the patch Jon.
Makes sense.
Rik

vtkachenko’s picture

Call of next code will lead to clearing All node cache.

node_load($node_revision->nid, NULL, TRUE);

https://api.drupal.org/api/drupal/includes!common.inc/function/entity_lo...

SEE:
$reset: Whether to reset the internal cache for the requested entity type.

So, it will clear cache not for specified entity but for all entities of this type.

Leeteq’s picture

Priority: Normal » Major
DamienMcKenna’s picture

Status: Needs review » Needs work

Using the $reset option on nodes doesn't make a huge deal with core, but when you use the EntityCache module it clears the cache for every entity of that type, i.e. it'll clear the entire node cache.

DamienMcKenna’s picture

Status: Needs work » Needs review
FileSize
888 bytes

Would this work? It might also help to add some tests to confirm it doesn't break anything.

DamienMcKenna’s picture

Status: Needs review » Needs work

The last submitted patch, 6: revisioning-n2382331-6.patch, failed testing.

DamienMcKenna’s picture

Status: Needs work » Needs review

The patch failed testing because there are no tests, see #2645590: Ensure that simpletest job doesn't "fail" testing if no tests are present for details.