Skip to content
Snippets Groups Projects
Commit 479bd2fe authored by Neil Drumm's avatar Neil Drumm :wave:
Browse files

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

parent 7645a1f4
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -491,11 +491,16 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data = ...@@ -491,11 +491,16 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
* 1 = Log errors to database and to screen. * 1 = Log errors to database and to screen.
*/ */
function error_handler($errno, $message, $filename, $line) { 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)) { 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'); $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 .'.'; $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')) { if (variable_get('error_level', 1) == 1 || strstr($_SERVER['PHP_SELF'], 'update.php')) {
drupal_set_message($entry, 'error'); drupal_set_message($entry, 'error');
} }
......
...@@ -270,11 +270,50 @@ function drupal_install_profile($profile) { ...@@ -270,11 +270,50 @@ function drupal_install_profile($profile) {
require_once($profile_file); 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. // Get a list of modules required by this profile.
$function = $profile .'_profile_modules'; $function = $profile .'_profile_modules';
$module_list = $function(); $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. // 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(); $modules = array();
foreach ($module_list as $current) { foreach ($module_list as $current) {
$module = file_scan_directory('./modules', "^$current.module$", array('.', '..', 'CVS'), 0, TRUE, 'name', 0); $module = file_scan_directory('./modules', "^$current.module$", array('.', '..', 'CVS'), 0, TRUE, 'name', 0);
...@@ -285,26 +324,22 @@ function drupal_install_profile($profile) { ...@@ -285,26 +324,22 @@ function drupal_install_profile($profile) {
$modules = array_merge($modules, $module); $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. // Get a list of all .install files.
$installs = drupal_get_install_files($module_list); $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) { foreach ($installs as $install) {
require_once $install->filename; require_once $install->filename;
module_invoke($install->name, 'install'); 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);
}
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment