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
Comment | File | Size | Author |
---|---|---|---|
#6 | revisioning-n2382331-6.patch | 888 bytes | DamienMcKenna |
Comments
Comment #1
jantoine CreditAttribution: jantoine commentedThe attached patch reloads the node directly after updating the database.
Comment #2
RdeBoerThanks for the patch Jon.
Makes sense.
Rik
Comment #3
vtkachenko CreditAttribution: vtkachenko commentedCall 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.
Comment #4
Leeteq CreditAttribution: Leeteq commentedComment #5
DamienMcKennaUsing 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.
Comment #6
DamienMcKennaWould this work? It might also help to add some tests to confirm it doesn't break anything.
Comment #7
DamienMcKennaComment #9
DamienMcKennaThe 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.