diff --git a/entitycache.module b/entitycache.module index bbc39b8..a9763eb 100644 --- a/entitycache.module +++ b/entitycache.module @@ -341,6 +341,20 @@ function poll_entitycache_node_load($nodes) { } /** + * Implements hook_entitycache_node_load(). + * + * This forces translation information to be added on each request, to avoid + * expensive cache clears. + */ +function translation_entitycache_node_load($nodes) { + $result = db_query("SELECT * FROM {node} n WHERE n.nid IN (:nids)", array(':nids' => array_keys($nodes)), array('fetch' => PDO::FETCH_ASSOC)); + foreach ($result as $record) { + $nodes[$record['nid']]->tnid = $record['tnid']; + $nodes[$record['nid']]->translate = $record['translate']; + } +} + +/** * Implements hook_comment_publish(). * * @todo: core should not call this hook outside of a comment_save(). diff --git a/entitycache.test b/entitycache.test index 1f97374..7cca337 100644 --- a/entitycache.test +++ b/entitycache.test @@ -1378,6 +1378,23 @@ class EntityCacheUserValidationTestCase extends UserValidationTestCase { } /** + * Copy of TranslationTestCase. + */ +class EntityCacheTranslationTestCase extends TranslationTestCase { + public static function getInfo() { + return array( + 'name' => 'Copy of TranslationTestCase', + 'description' => 'Copy of TranslationTestCase', + 'group' => 'Entity cache' + ); + } + function setUp() { + parent::setup(); + module_enable(array('entitycache')); + } +} + +/** * Test comments on nodes. */ class EntityCacheCommentNodeTestCase extends DrupalWebTestCase {