Commit 479bd2fe authored by drumm's avatar drumm

#73615 by chx, Eaton, and Steven, Provide the full range of Drupal functions to .install files

parent 7645a1f4
......@@ -491,11 +491,16 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
* 1 = Log errors to database and to screen.
*/
function error_handler($errno, $message, $filename, $line) {
// If the @ error suppression operator was used, error_reporting is temporarily set to 0
if (error_reporting() == 0) {
return;
}
if ($errno & (E_ALL ^ E_NOTICE)) {
$types = array(1 => 'error', 2 => 'warning', 4 => 'parse error', 8 => 'notice', 16 => 'core error', 32 => 'core warning', 64 => 'compile error', 128 => 'compile warning', 256 => 'user error', 512 => 'user warning', 1024 => 'user notice', 2048 => 'strict warning');
$entry = $types[$errno] .': '. $message .' in '. $filename .' on line '. $line .'.';
// Note: force display of error messages in update.php
// Force display of error messages in update.php
if (variable_get('error_level', 1) == 1 || strstr($_SERVER['PHP_SELF'], 'update.php')) {
drupal_set_message($entry, 'error');
}
......
......@@ -270,11 +270,50 @@ function drupal_install_profile($profile) {
require_once($profile_file);
// Get a list of modules absolutely required by Drupal.
$bootstrap_list = array('system');
// Get a list of modules required by this profile.
$function = $profile .'_profile_modules';
$module_list = $function();
// If anyone has added modules that we automatically install, filter them out.
$module_list = array_diff($module_list, $bootstrap_list);
// Verify that all required modules exist.
$bootstrap_modules = drupal_find_modules($bootstrap_list);
$profile_modules = drupal_find_modules($module_list);
// Install the essential system modules and bootstrap Drupal.
drupal_install_modules($bootstrap_list);
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Install schemas for profile and all its modules.
$function = $profile .'_install';
if (function_exists($function)) {
$function();
}
drupal_install_modules($module_list);
// Enable the modules required by the profile.
db_query("DELETE FROM {system} WHERE type = 'module'");
$modules = array_merge($bootstrap_modules, $profile_modules);
foreach ($modules as $module) {
db_query("INSERT INTO {system} (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES('%s', '%s', 'module', '', 1, 0, 0, 0)", $module->filename, $module->name);
}
}
/**
* Finds the file paths for a set of modules.
*
* @param module_list
* The modules to locate.
* @return
* An array containing file information for the modules.
*/
function drupal_find_modules($module_list = array()) {
$modules = array();
foreach ($module_list as $current) {
$module = file_scan_directory('./modules', "^$current.module$", array('.', '..', 'CVS'), 0, TRUE, 'name', 0);
......@@ -285,26 +324,22 @@ function drupal_install_profile($profile) {
$modules = array_merge($modules, $module);
}
}
return $modules;
}
/**
* Execute the install scripts for a set of modules.
*
* @param module_list
* The modules to install.
*/
function drupal_install_modules($module_list = array()) {
// Get a list of all .install files.
$installs = drupal_get_install_files($module_list);
// Install schemas for profile and all its modules.
$function = $profile .'_install';
if (function_exists($function)) {
$function();
}
foreach ($installs as $install) {
require_once $install->filename;
module_invoke($install->name, 'install');
}
// Enable the modules required by the profile.
db_query("DELETE FROM {system} WHERE type = 'module'");
foreach ($modules as $module) {
db_query("INSERT INTO {system} (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES('%s', '%s', 'module', '', 1, 0, 0, 0)", $module->filename, $module->name);
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment