From fa4fe8bad8cb093c4a71a30f2ef9206ea279e0df Sat, 17 Dec 2011 21:25:24 +0100
From: Bram Goffings <bramgoffings@gmail.com>
Date: Sat, 17 Dec 2011 21:25:16 +0100
Subject: [PATCH] Switched hook order



diff --git a/core/modules/entity/entity.controller.inc b/core/modules/entity/entity.controller.inc
index 04c1f31..19a4a4d 100644
--- a/core/modules/entity/entity.controller.inc
+++ b/core/modules/entity/entity.controller.inc
@@ -335,11 +335,6 @@
       }
     }
 
-    // Call hook_entity_load().
-    foreach (module_implements('entity_load') as $module) {
-      $function = $module . '_entity_load';
-      $function($queried_entities, $this->entityType);
-    }
     // Call hook_TYPE_load(). The first argument for hook_TYPE_load() are
     // always the queried entities, followed by additional arguments set in
     // $this->hookLoadArguments.
@@ -347,6 +342,11 @@
     foreach (module_implements($this->entityInfo['load hook']) as $module) {
       call_user_func_array($module . '_' . $this->entityInfo['load hook'], $args);
     }
+    // Call hook_entity_load().
+    foreach (module_implements('entity_load') as $module) {
+      $function = $module . '_entity_load';
+      $function($queried_entities, $this->entityType);
+    }
   }
 
   /**
diff --git a/core/modules/entity/tests/entity_crud_hook_test.test b/core/modules/entity/tests/entity_crud_hook_test.test
index 2bb459f..45e23c3 100644
--- a/core/modules/entity/tests/entity_crud_hook_test.test
+++ b/core/modules/entity/tests/entity_crud_hook_test.test
@@ -97,8 +97,8 @@
     $comment = comment_load($comment->cid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_entity_load called for type comment',
       'entity_crud_hook_test_comment_load called',
+      'entity_crud_hook_test_entity_load called for type comment',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
@@ -153,8 +153,8 @@
     $file = file_load($file->fid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_entity_load called for type file',
       'entity_crud_hook_test_file_load called',
+      'entity_crud_hook_test_entity_load called for type file',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
@@ -209,8 +209,8 @@
     $node = node_load($node->nid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_entity_load called for type node',
       'entity_crud_hook_test_node_load called',
+      'entity_crud_hook_test_entity_load called for type node',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
@@ -267,8 +267,8 @@
     $term = taxonomy_term_load($term->tid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_entity_load called for type taxonomy_term',
       'entity_crud_hook_test_taxonomy_term_load called',
+      'entity_crud_hook_test_entity_load called for type taxonomy_term',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
@@ -317,8 +317,8 @@
     $vocabulary = taxonomy_vocabulary_load($vocabulary->vid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_entity_load called for type taxonomy_vocabulary',
       'entity_crud_hook_test_taxonomy_vocabulary_load called',
+      'entity_crud_hook_test_entity_load called for type taxonomy_vocabulary',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
@@ -369,8 +369,8 @@
     $account = user_load($account->uid);
 
     $this->assertHookMessageOrder(array(
-      'entity_crud_hook_test_entity_load called for type user',
       'entity_crud_hook_test_user_load called',
+      'entity_crud_hook_test_entity_load called for type user',
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
