--- metatag.module.orig 2013-04-22 16:01:49.000000000 +0200
+++ metatag.module 2013-08-21 15:25:41.000000000 +0200
@@ -520,21 +520,28 @@
* Implements hook_entity_load().
*/
function metatag_entity_load($entities, $entity_type) {
- // Wrap this in a try-catch block to work around occasions when the schema
- // hasn't been updated yet.
- try {
- if (metatag_entity_supports_metatags($entity_type)) {
- $metatags = metatag_metatags_load_multiple($entity_type, array_keys($entities));
+ $entity_ids = array();
+ foreach ($entities as $entity) {
+ list ($entity_id,, $bundle) = entity_extract_ids($entity_type, $entity);
+ if (metatag_entity_supports_metatags($entity_type, $bundle)) {
+ $entity_ids[] = $entity_id;
+ }
+ }
+ if (!empty($entity_ids)) {
+ // Wrap this in a try-catch block to work around occasions when the schema
+ // hasn't been updated yet.
+ try {
+ $metatags = metatag_metatags_load_multiple($entity_type, $entity_ids);
foreach ($entities as $entity_id => $entity) {
$entities[$entity_id]->metatags = isset($metatags[$entity_id]) ? $metatags[$entity_id] : array();
}
}
- }
- catch (Exception $e) {
- watchdog('metatag', 'Error loading meta tag data, do the database updates need to be run? The error occurred when loading record(s) %ids for the %type entity type. The error message was: %error', array('@update' => base_path() . 'update.php', '%ids' => implode(', ', array_keys($entities)), '%type' => $entity_type, '%error' => $e->getMessage()), WATCHDOG_CRITICAL);
- // Don't display the same message twice for Drush.
- if (php_sapi_name() != 'cli') {
- drupal_set_message(t('Error loading meta tag data, do the database updates need to be run?', array('@update' => base_path() . 'update.php')), 'error');
+ catch (Exception $e) {
+ watchdog('metatag', 'Error loading meta tag data, do the database updates need to be run? The error occurred when loading record(s) %ids for the %type entity type. The error message was: %error', array('@update' => base_path() . 'update.php', '%ids' => implode(', ', array_keys($entities)), '%type' => $entity_type, '%error' => $e->getMessage()), WATCHDOG_CRITICAL);
+ // Don't display the same message twice for Drush.
+ if (php_sapi_name() != 'cli') {
+ drupal_set_message(t('Error loading meta tag data, do the database updates need to be run?', array('@update' => base_path() . 'update.php')), 'error');
+ }
}
}
}