You are here

function metatag_update_7006 in Metatag 7

Remove {metatag} records that were added by old versions of the module.

This is for entities that don't actually support Metatag. A more complete version of this will be added later on after it's (hopefully) guaranteed that all modules have updated to the correct API usage.

File

./metatag.install, line 955
Install, update, and uninstall functions for the metatag module.

Code

function metatag_update_7006() {
  $entity_types = array(
    // Core.
    'comment',
    'menu_link',
    'taxonomy_vocabulary',
    // Some contrib entities.
    'mailchimp_list',
    'profile2',
    'profile2_type',
    'redirect',
    'rules_config',
    'wysiwyg_profile',
  );
  foreach ($entity_types as $entity_type) {
    $num_deleted = db_delete('metatag')
      ->condition('entity_type', $entity_type)
      ->execute();
    if ($num_deleted > 0) {
      drupal_set_message(t('Removed @count meta tag record(s) for the @type entity type, it does not support meta tags.', array(
        '@count' => $num_deleted,
        '@type' => $entity_type,
      )));
    }
  }
}