You are here

function features_update_6100 in Features 7.2

Same name and namespace in other branches
  1. 6 features.install \features_update_6100()
  2. 7 features.install \features_update_6100()

Update 6100: Set module on all feature node types to 'features'.

This update can be re-run as needed to repair any node types that are not removed after disabling the associated feature.

Any feature implementing a node component that was exported prior to this version of the features.module will need to have its 'module' declaration in hook_node_info() changed from 'node' to 'features'.

File

./features.install, line 125
Install, update and uninstall functions for the features module.

Code

function features_update_6100() {
  $ret = array();
  foreach (features_get_features(NULL, TRUE) as $feature) {
    if (module_exists($feature->name) && ($types = module_invoke($feature->name, 'node_info'))) {
      foreach ($types as $type => $type_data) {
        $sql = "SELECT COUNT(*) FROM {node_type} WHERE module = 'node' AND type = '%s'";

        // Only update if the hook_node_info() type's module is 'features' and
        // the db type's module is 'node'.
        if ($type_data['module'] == 'features' && db_query($sql, $type)
          ->fetchField()) {
          $ret[] = update_sql("UPDATE {node_type} SET module = 'features' WHERE type = '{$type}'");
        }
      }
    }
  }
  return $ret;
}