Ejemplo n.º 1
0
/**
 * Before calling this we need to be bootstrapped to DRUPAL_BOOTSTRAP_SESSION.
 */
function registry_rebuild_rebuild()
{
    // This section is not functionally important. It's just using the
    // registry_get_parsed_files() so that it can report the change. Drupal 7 only.
    if (function_exists('registry_rebuild')) {
        $connection_info = Database::getConnectionInfo();
        $driver = $connection_info['default']['driver'];
        global $include_dir;
        require_once $include_dir . '/database/' . $driver . '/query.inc';
        $parsed_before = registry_get_parsed_files();
    }
    // Separate bootstrap cache exists only in Drupal 7 or newer.
    // They are cleared later again via drupal_flush_all_caches().
    if (function_exists('registry_rebuild')) {
        // D7
        cache_clear_all('lookup_cache', 'cache_bootstrap');
        cache_clear_all('variables', 'cache_bootstrap');
        cache_clear_all('module_implements', 'cache_bootstrap');
        print "Bootstrap caches have been cleared in DRUPAL_BOOTSTRAP_SESSION<br/>\n";
    } elseif (!function_exists('cache_clear_all')) {
        // D8+
        cache('bootstrap')->deleteAll();
        print "Bootstrap caches have been cleared in DRUPAL_BOOTSTRAP_SESSION<br/>\n";
    }
    // We later run system_rebuild_module_data() and registry_update() on Drupal 7 via
    // D7-only registry_rebuild() wrapper, which is run inside drupal_flush_all_caches().
    // It is an equivalent of module_rebuild_cache() in D5-D6 and is normally run via
    // our universal wrapper registry_rebuild_cc_all() -- see further below.
    // However, we are still on the DRUPAL_BOOTSTRAP_SESSION level here,
    // and we want to make the initial rebuild as atomic as possible, so we can't
    // run everything from registry_rebuild_cc_all() yet, so we run an absolute
    // minimum we can at this stage, core specific.
    if (function_exists('registry_rebuild')) {
        // D7 only
        print "Doing registry_rebuild() in DRUPAL_BOOTSTRAP_SESSION<br/>\n";
        registry_rebuild();
    } elseif (!function_exists('registry_rebuild') && function_exists('system_rebuild_module_data')) {
        // D8+
        print "Doing system_rebuild_module_data() in DRUPAL_BOOTSTRAP_SESSION<br/>\n";
        system_rebuild_module_data();
    } else {
        // D5-D6
        print "Doing module_rebuild_cache() in DRUPAL_BOOTSTRAP_SESSION<br/>\n";
        module_list(TRUE, FALSE);
        module_rebuild_cache();
    }
    print "Bootstrapping to DRUPAL_BOOTSTRAP_FULL<br/>\n";
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    // We can run our wrapper now, since we are in a full bootstrap already.
    print "Rebuilding registry via registry_rebuild_cc_all in DRUPAL_BOOTSTRAP_FULL<br/>\n";
    registry_rebuild_cc_all();
    // Extra cleanup available for D7 only.
    if (function_exists('registry_rebuild')) {
        $parsed_after = registry_get_parsed_files();
        // Remove files which don't exist anymore.
        $filenames = array();
        foreach ($parsed_after as $filename => $file) {
            if (!file_exists($filename)) {
                $filenames[] = $filename;
            }
        }
        if (!empty($filenames)) {
            db_delete('registry_file')->condition('filename', $filenames)->execute();
            db_delete('registry')->condition('filename', $filenames)->execute();
            print "Deleted " . count($filenames) . ' stale files from registry manually.';
        }
        $parsed_after = registry_get_parsed_files();
        print "There were " . count($parsed_before) . " files in the registry before and " . count($parsed_after) . " files now.<br/>\n";
        registry_rebuild_cc_all();
    }
    print "If you don't see any crazy fatal errors, your registry has been rebuilt.<br/>\n";
}
Ejemplo n.º 2
0
  module_list(TRUE, FALSE, FALSE, $module_list);
  drupal_load('module', 'system');

  // Reset the module_implements() cache so that any new hook implementations
  // in updated code are picked up.
  module_implements('', FALSE, TRUE);

  // Set up $language, since the installer components require it.
  drupal_language_initialize();

  // Set up theme system for the maintenance page.
  drupal_maintenance_theme();

  // Rebuild the registry to ensure that removed hooks in modules do not result
  // in undefined function errors and that newly defined hooks are called.
  registry_rebuild();

  // Check the update requirements for Drupal.
  update_check_requirements();

  // Redirect to the update information page if all requirements were met.
  install_goto('update.php?op=info');
}

// update_fix_d7_requirements() needs to run before bootstrapping beyond path.
// So bootstrap to DRUPAL_BOOTSTRAP_LANGUAGE then include unicode.inc.

drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE);
include_once DRUPAL_ROOT . '/includes/unicode.inc';

update_fix_d7_requirements();