You are here

function update_fix_system_table in Drupal 5

Same name and namespace in other branches
  1. 4 update.php \update_fix_system_table()
1 call to update_fix_system_table()
update.php in ./update.php
Administrative page for handling updates from one Drupal version to another.

File

./update.php, line 587
Administrative page for handling updates from one Drupal version to another.

Code

function update_fix_system_table() {
  drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
  $core_modules = array(
    'aggregator',
    'archive',
    'block',
    'blog',
    'blogapi',
    'book',
    'comment',
    'contact',
    'drupal',
    'filter',
    'forum',
    'help',
    'legacy',
    'locale',
    'menu',
    'node',
    'page',
    'path',
    'ping',
    'poll',
    'profile',
    'search',
    'statistics',
    'story',
    'system',
    'taxonomy',
    'throttle',
    'tracker',
    'upload',
    'user',
    'watchdog',
  );
  foreach ($core_modules as $module) {
    $old_path = "modules/{$module}.module";
    $new_path = "modules/{$module}/{$module}.module";
    db_query("UPDATE {system} SET filename = '%s' WHERE filename = '%s'", $new_path, $old_path);
  }
  $row = db_fetch_object(db_query_range('SELECT * FROM {system}', 0, 1));
  if (!isset($row->weight)) {
    $ret = array();
    switch ($GLOBALS['db_type']) {
      case 'pgsql':
        db_add_column($ret, 'system', 'weight', 'smallint', array(
          'not null' => TRUE,
          'default' => 0,
        ));
        $ret[] = update_sql('CREATE INDEX {system}_weight_idx ON {system} (weight)');
        break;
      case 'mysql':
      case 'mysqli':
        $ret[] = update_sql("ALTER TABLE {system} ADD weight tinyint(2) default '0' NOT NULL, ADD KEY (weight)");
        break;
    }
  }
}