function install_main in Drupal 5
Same name and namespace in other branches
- 6 install.php \install_main()
The Drupal installation happens in a series of steps. We begin by verifying that the current environment meets our minimum requirements. We then go on to verify that settings.php is properly configured. From there we connect to the configured database and verify that it meets our minimum requirements. Finally we can allow the user to select an installation profile and complete the installation process.
Parameters
$phase: The installation phase we should proceed to.
1 call to install_main()
- install.php in ./
install.php
1 string reference to 'install_main'
- get_t in includes/
bootstrap.inc - Return the name of the localisation function. Use in code that needs to run both during installation and normal operation.
File
- ./
install.php, line 16
Code
function install_main() {
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
// This must go after drupal_bootstrap(), which unsets globals!
global $profile, $install_locale;
require_once './modules/system/system.install';
require_once './includes/file.inc';
// Ensure correct page headers are sent (e.g. caching)
drupal_page_header();
// Check existing settings.php.
$verify = install_verify_settings();
// Drupal may already be installed.
if ($verify) {
// Establish a connection to the database.
require_once './includes/database.inc';
db_set_active();
// Check if Drupal is installed.
if (install_verify_drupal()) {
install_already_done_error();
}
}
// Load module basics (needed for hook invokes).
include_once './includes/module.inc';
$module_list['system']['filename'] = 'modules/system/system.module';
$module_list['filter']['filename'] = 'modules/filter/filter.module';
module_list(TRUE, FALSE, FALSE, $module_list);
drupal_load('module', 'system');
drupal_load('module', 'filter');
// Decide which profile to use.
if (!empty($_GET['profile'])) {
$profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']);
}
elseif ($profile = install_select_profile()) {
install_goto("install.php?profile={$profile}");
}
else {
install_no_profile_error();
}
// Locale selection
if (!empty($_GET['locale'])) {
$install_locale = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['locale']);
}
elseif (($install_locale = install_select_locale($profile)) !== FALSE) {
install_goto("install.php?profile={$profile}&locale={$install_locale}");
}
// Load the profile.
require_once "./profiles/{$profile}/{$profile}.profile";
// Check the installation requirements for Drupal and this profile.
install_check_requirements($profile);
// Change the settings.php information if verification failed earlier.
// Note: will trigger a redirect if database credentials change.
if (!$verify) {
install_change_settings($profile, $install_locale);
}
// Verify existence of all required modules.
$modules = drupal_verify_profile($profile, $install_locale);
if (!$modules) {
install_missing_modules_error($profile);
}
// Perform actual installation defined in the profile.
drupal_install_profile($profile, $modules);
// Warn about settings.php permissions risk
$settings_file = './' . conf_path() . '/settings.php';
if (!drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE)) {
drupal_set_message(st('All necessary changes to %file have been made, so you should now remove write permissions to this file. Failure to remove write permissions to this file is a security risk.', array(
'%file' => $settings_file,
)), 'error');
}
else {
drupal_set_message(st('All necessary changes to %file have been made. It has been set to read-only for security.', array(
'%file' => $settings_file,
)));
}
// Show end page.
install_complete($profile);
}