1 update.inc update_module_enable(array $modules)

Helper function to install a new module in Backdrop 1.x via hook_update_N().


core/includes/update.inc, line 428
Backdrop database update API.


function update_module_enable(array $modules) {
  foreach ($modules as $module) {
    // Check for initial schema and install it. The schema version of a newly
    // installed module is always 0. Using 1000 here would be inconsistent
    // since $module_update_1000() may involve a schema change, and we want
    // to install the schema as it was before any updates were added.
    $function = $module . '_schema_0';
    if (function_exists($function)) {
      $schema = $function();
      foreach ($schema as $table => $spec) {
        db_create_table($table, $spec);
    // Change the schema version from SCHEMA_UNINSTALLED to 0, so any module
    // updates since the module's inception are executed in a core upgrade.
      ->condition('type', 'module')
      ->condition('name', $module)
      ->fields(array('schema_version' => 0, 'status' => 1))

    // system_list_reset() is in module.inc but that would only be available
    // once the variable bootstrap is done.
    require_once BACKDROP_ROOT . '/core/includes/module.inc';
    // @todo: figure out what to do about hook_install() and hook_enable().