Hey all,

I've built a module that extends Meta Tag to add AGLS metadata (Reference) (Module).

The module is working properly but unfortunately I cannot implement an uninstall hook because the config data in metadata_config table stores the data in a serialized blob.

Any ideas in how to implement this hook?

Comments

damienmckenna’s picture

You'd have to do something like this (untested):

  $result = db_query("SELECT entity_type, entity_id, data FROM {metatag}");

  foreach ($result as $record) {
    // Remove the unwanted values.
    unset($record->data['somethingorother'];

    // Update the record.
    $num_updated = db_update('metatag')
      ->fields(array(
        'data' => $record->data,
      ))
      ->condition('entity_type', $record->entity_type)
      ->condition('entity_id', $record->entity_id)
      ->execute();
  }
damienmckenna’s picture

Status: Active » Fixed
dave reid’s picture

I would not recommend that you implement an uninstall hook and just allow the data to be "left alone" until the Meta tag module is installed. As long as the module that was responsible for the specific meta tag is not enabled, then that meta tag data should not be displayed, processed, or have anything done with it and the next time config or individual meta tags would be saved, that data will be removed.

rubenspeculis’s picture

Thanks all :-)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

damienmckenna’s picture

FYI due to a bug in the module you'll run into this error as soon as you disable the custom module: #1284794: Error metatag_get_instance() after uninstalling metatag_opengraph