Commit 2c552193 authored by webchick's avatar webchick

#497118 by chx, catch, pwolanin, JoshuaRogers, and Jacob Singh: Remove the...

#497118 by chx, catch, pwolanin, JoshuaRogers, and Jacob Singh: Remove the function registry. While the hope was that this would result in improved performance for low-end hosts, it comes at the expense of critical development experience problems and less benefit than something like APC. Class registry remains intact to facilitate autoloading.
parent 00280ca9
...@@ -95,8 +95,7 @@ Drupal 7.0, xxxx-xx-xx (development version) ...@@ -95,8 +95,7 @@ Drupal 7.0, xxxx-xx-xx (development version)
contributed modules. contributed modules.
- Added code registry: - Added code registry:
* Using the registry, modules declare their includable files via their .info file, * Using the registry, modules declare their includable files via their .info file,
allowing Drupal to lazy-load code as needed, resulting in significant performance allowing Drupal to lazy-load classes and interfaces as needed.
and memory improvements.
- Theme system: - Theme system:
* Removed the Bluemarine, Chameleon and Pushbutton themes. These themes live * Removed the Bluemarine, Chameleon and Pushbutton themes. These themes live
on as contributed themes (http://drupal.org/project/bluemarine, on as contributed themes (http://drupal.org/project/bluemarine,
......
...@@ -211,7 +211,7 @@ function ajax_form_callback() { ...@@ -211,7 +211,7 @@ function ajax_form_callback() {
// Get the callback function from the clicked button. // Get the callback function from the clicked button.
$ajax = $form_state['clicked_button']['#ajax']; $ajax = $form_state['clicked_button']['#ajax'];
$callback = $ajax['callback']; $callback = $ajax['callback'];
if (drupal_function_exists($callback)) { if (function_exists($callback)) {
$html = $callback($form, $form_state); $html = $callback($form, $form_state);
// If the returned value is a string, assume it is HTML and create // If the returned value is a string, assume it is HTML and create
......
...@@ -654,7 +654,7 @@ function drupal_get_filename($type, $name, $filename = NULL) { ...@@ -654,7 +654,7 @@ function drupal_get_filename($type, $name, $filename = NULL) {
$mask = "/$name\.$type$/"; $mask = "/$name\.$type$/";
} }
if (drupal_function_exists('drupal_system_listing')) { if (function_exists('drupal_system_listing')) {
$matches = drupal_system_listing($mask, $dir, 'name', 0); $matches = drupal_system_listing($mask, $dir, 'name', 0);
if (!empty($matches[$name]->uri)) { if (!empty($matches[$name]->uri)) {
$files[$type][$name] = $matches[$name]->uri; $files[$type][$name] = $matches[$name]->uri;
...@@ -787,6 +787,19 @@ function drupal_page_is_cacheable($allow_caching = NULL) { ...@@ -787,6 +787,19 @@ function drupal_page_is_cacheable($allow_caching = NULL) {
&& $_SERVER['SERVER_SOFTWARE'] !== 'PHP CLI'; && $_SERVER['SERVER_SOFTWARE'] !== 'PHP CLI';
} }
/**
* Call all init or exit hooks without including all modules.
*
* @param $hook
* The name of the bootstrap hook we wish to invoke.
*/
function bootstrap_invoke_all($hook) {
foreach (module_list(TRUE, TRUE) as $module) {
drupal_load('module', $module);
module_invoke($module, $hook);
}
}
/** /**
* Includes a file with the provided type and name. This prevents * Includes a file with the provided type and name. This prevents
* including a theme, engine, module, etc., more than once. * including a theme, engine, module, etc., more than once.
...@@ -1078,6 +1091,13 @@ function drupal_serve_page_from_cache(stdClass $cache) { ...@@ -1078,6 +1091,13 @@ function drupal_serve_page_from_cache(stdClass $cache) {
print $cache->data; print $cache->data;
} }
/**
* Define the critical hooks that force modules to always be loaded.
*/
function bootstrap_hooks() {
return array('boot', 'exit', 'watchdog');
}
/** /**
* Unserializes and appends elements from a serialized string. * Unserializes and appends elements from a serialized string.
* *
...@@ -1469,15 +1489,14 @@ function _drupal_bootstrap($phase) { ...@@ -1469,15 +1489,14 @@ function _drupal_bootstrap($phase) {
// If the skipping of the bootstrap hooks is not enforced, call // If the skipping of the bootstrap hooks is not enforced, call
// hook_boot. // hook_boot.
if (variable_get('page_cache_invoke_hooks', TRUE)) { if (variable_get('page_cache_invoke_hooks', TRUE)) {
require_once DRUPAL_ROOT . '/includes/module.inc'; bootstrap_invoke_all('boot');
module_invoke_all('boot');
} }
header('X-Drupal-Cache: HIT'); header('X-Drupal-Cache: HIT');
drupal_serve_page_from_cache($cache); drupal_serve_page_from_cache($cache);
// If the skipping of the bootstrap hooks is not enforced, call // If the skipping of the bootstrap hooks is not enforced, call
// hook_exit. // hook_exit.
if (variable_get('page_cache_invoke_hooks', TRUE)) { if (variable_get('page_cache_invoke_hooks', TRUE)) {
module_invoke_all('exit'); bootstrap_invoke_all('exit');
} }
// We are done. // We are done.
exit; exit;
...@@ -1504,6 +1523,9 @@ function _drupal_bootstrap($phase) { ...@@ -1504,6 +1523,9 @@ function _drupal_bootstrap($phase) {
case DRUPAL_BOOTSTRAP_VARIABLES: case DRUPAL_BOOTSTRAP_VARIABLES:
// Load variables from the database, but do not overwrite variables set in settings.php. // Load variables from the database, but do not overwrite variables set in settings.php.
$conf = variable_initialize(isset($conf) ? $conf : array()); $conf = variable_initialize(isset($conf) ? $conf : array());
// Load bootstrap modules.
require_once DRUPAL_ROOT . '/includes/module.inc';
module_load_all(TRUE);
break; break;
case DRUPAL_BOOTSTRAP_SESSION: case DRUPAL_BOOTSTRAP_SESSION:
...@@ -1512,8 +1534,7 @@ function _drupal_bootstrap($phase) { ...@@ -1512,8 +1534,7 @@ function _drupal_bootstrap($phase) {
break; break;
case DRUPAL_BOOTSTRAP_PAGE_HEADER: case DRUPAL_BOOTSTRAP_PAGE_HEADER:
require_once DRUPAL_ROOT . '/includes/module.inc'; bootstrap_invoke_all('boot');
module_invoke_all('boot');
if (!$cache && drupal_page_is_cacheable()) { if (!$cache && drupal_page_is_cacheable()) {
header('X-Drupal-Cache: MISS'); header('X-Drupal-Cache: MISS');
} }
...@@ -1751,7 +1772,7 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) { ...@@ -1751,7 +1772,7 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) {
// Load the .install files to get hook_schema. // Load the .install files to get hook_schema.
// On some databases this function may be called before bootstrap has // On some databases this function may be called before bootstrap has
// been completed, so we force the functions we need to load just in case. // been completed, so we force the functions we need to load just in case.
if (drupal_function_exists('module_load_all_includes')) { if (function_exists('module_load_all_includes')) {
// There is currently a bug in module_list() where it caches what it // There is currently a bug in module_list() where it caches what it
// was last called with, which is not always what you want. // was last called with, which is not always what you want.
...@@ -1761,7 +1782,7 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) { ...@@ -1761,7 +1782,7 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) {
// "prime" module_list() here to to values we want, specifically // "prime" module_list() here to to values we want, specifically
// "yes rebuild the list and don't limit to bootstrap". // "yes rebuild the list and don't limit to bootstrap".
// TODO: Remove this call after http://drupal.org/node/222109 is fixed. // TODO: Remove this call after http://drupal.org/node/222109 is fixed.
module_list(TRUE); module_list(TRUE, FALSE);
module_load_all_includes('install'); module_load_all_includes('install');
} }
...@@ -1769,17 +1790,11 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) { ...@@ -1769,17 +1790,11 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) {
// Invoke hook_schema for all modules. // Invoke hook_schema for all modules.
foreach (module_implements('schema') as $module) { foreach (module_implements('schema') as $module) {
$current = module_invoke($module, 'schema'); $current = module_invoke($module, 'schema');
if (drupal_function_exists('_drupal_schema_initialize')) { _drupal_schema_initialize($module, $current);
_drupal_schema_initialize($module, $current);
}
$schema = array_merge($schema, $current); $schema = array_merge($schema, $current);
} }
if (drupal_function_exists('drupal_alter')) { drupal_alter('schema', $schema);
drupal_alter('schema', $schema);
}
// If the schema is empty, avoid saving it: some database engines require // If the schema is empty, avoid saving it: some database engines require
// the schema to perform queries, and this could lead to infinite loops. // the schema to perform queries, and this could lead to infinite loops.
if (!empty($schema) && (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL)) { if (!empty($schema) && (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL)) {
...@@ -1809,52 +1824,11 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) { ...@@ -1809,52 +1824,11 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) {
* @{ * @{
*/ */
/**
* Confirm that a function is available.
*
* If the function is already available, this function does nothing.
* If the function is not available, it tries to load the file where the
* function lives. If the file is not available, it returns false, so that it
* can be used as a drop-in replacement for function_exists().
*
* @param $function
* The name of the function to check or load.
* @return
* TRUE if the function is now available, FALSE otherwise.
*/
function drupal_function_exists($function) {
static $checked = array();
static $maintenance;
if (!isset($maintenance)) {
$maintenance = defined('MAINTENANCE_MODE');
}
if ($maintenance) {
return function_exists($function);
}
if (isset($checked[$function])) {
return $checked[$function];
}
$checked[$function] = FALSE;
if (function_exists($function)) {
$checked[$function] = TRUE;
return TRUE;
}
$checked[$function] = _registry_check_code('function', $function);
return $checked[$function];
}
/** /**
* Confirm that an interface is available. * Confirm that an interface is available.
* *
* This function parallels drupal_function_exists(), but is rarely * This function is rarely called directly. Instead, it is registered as an
* called directly. Instead, it is registered as an spl_autoload() * spl_autoload() handler, and PHP calls it for us when necessary.
* handler, and PHP calls it for us when necessary.
* *
* @param $interface * @param $interface
* The name of the interface to check or load. * The name of the interface to check or load.
...@@ -1868,9 +1842,8 @@ function drupal_autoload_interface($interface) { ...@@ -1868,9 +1842,8 @@ function drupal_autoload_interface($interface) {
/** /**
* Confirm that a class is available. * Confirm that a class is available.
* *
* This function parallels drupal_function_exists(), but is rarely * This function is rarely called directly. Instead, it is registered as an
* called directly. Instead, it is registered as an spl_autoload() * spl_autoload() handler, and PHP calls it for us when necessary.
* handler, and PHP calls it for us when necessary.
* *
* @param $class * @param $class
* The name of the class to check or load. * The name of the class to check or load.
...@@ -1960,8 +1933,8 @@ function _registry_check_code($type, $name = NULL) { ...@@ -1960,8 +1933,8 @@ function _registry_check_code($type, $name = NULL) {
/** /**
* Rescan all enabled modules and rebuild the registry. * Rescan all enabled modules and rebuild the registry.
* *
* Rescans all code in modules or includes directory, storing a mapping of * Rescans all code in modules or includes directories, storing the location of
* each function, file, and hook implementation in the database. * each interface or class in the database.
*/ */
function registry_rebuild() { function registry_rebuild() {
require_once DRUPAL_ROOT . '/includes/registry.inc'; require_once DRUPAL_ROOT . '/includes/registry.inc';
......
...@@ -1219,7 +1219,7 @@ function t($string, array $args = array(), array $options = array()) { ...@@ -1219,7 +1219,7 @@ function t($string, array $args = array(), array $options = array()) {
$string = $custom_strings[$options['langcode']][$options['context']][$string]; $string = $custom_strings[$options['langcode']][$options['context']][$string];
} }
// Translate with locale module if enabled. // Translate with locale module if enabled.
// We don't use drupal_function_exists() here, because it breaks the testing // We don't use function_exists() here, because it breaks the testing
// framework if the locale module is enabled in the parent site (we cannot // framework if the locale module is enabled in the parent site (we cannot
// unload functions in PHP). // unload functions in PHP).
elseif (function_exists('locale') && $options['langcode'] != 'en') { elseif (function_exists('locale') && $options['langcode'] != 'en') {
...@@ -2319,7 +2319,6 @@ function drupal_page_footer() { ...@@ -2319,7 +2319,6 @@ function drupal_page_footer() {
ob_flush(); ob_flush();
} }
module_implements(MODULE_IMPLEMENTS_WRITE_CACHE);
_registry_check_code(REGISTRY_WRITE_LOOKUP_CACHE); _registry_check_code(REGISTRY_WRITE_LOOKUP_CACHE);
drupal_cache_system_paths(); drupal_cache_system_paths();
} }
...@@ -2868,7 +2867,7 @@ function drupal_clear_css_cache() { ...@@ -2868,7 +2867,7 @@ function drupal_clear_css_cache() {
* - 'file': Path to the file relative to base_path(). * - 'file': Path to the file relative to base_path().
* - 'inline': The JavaScript code that should be placed in the given scope. * - 'inline': The JavaScript code that should be placed in the given scope.
* - 'external': The absolute path to an external JavaScript file that is not * - 'external': The absolute path to an external JavaScript file that is not
* hosted on the local server. These files will not be aggregated if * hosted on the local server. These files will not be aggregated if
* JavaScript aggregation is enabled. * JavaScript aggregation is enabled.
* - 'setting': An array with configuration options as associative array. The * - 'setting': An array with configuration options as associative array. The
* array is directly placed in Drupal.settings. All modules should wrap * array is directly placed in Drupal.settings. All modules should wrap
...@@ -3575,14 +3574,6 @@ function _drupal_bootstrap_full() { ...@@ -3575,14 +3574,6 @@ function _drupal_bootstrap_full() {
set_error_handler('_drupal_error_handler'); set_error_handler('_drupal_error_handler');
set_exception_handler('_drupal_exception_handler'); set_exception_handler('_drupal_exception_handler');
if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'simpletest') !== FALSE) {
// Valid SimpleTest user-agent, log fatal errors to test specific file
// directory. The user-agent is validated in DRUPAL_BOOTSTRAP_DATABASE
// phase so as long as it is a SimpleTest user-agent it is valid.
ini_set('log_errors', 1);
ini_set('error_log', file_directory_path() . '/error.log');
}
// Emit the correct charset HTTP header. // Emit the correct charset HTTP header.
drupal_set_header('Content-Type', 'text/html; charset=utf-8'); drupal_set_header('Content-Type', 'text/html; charset=utf-8');
// Detect string handling method // Detect string handling method
...@@ -3593,6 +3584,14 @@ function _drupal_bootstrap_full() { ...@@ -3593,6 +3584,14 @@ function _drupal_bootstrap_full() {
module_load_all(); module_load_all();
// Make sure all stream wrappers are registered. // Make sure all stream wrappers are registered.
file_get_stream_wrappers(); file_get_stream_wrappers();
if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'simpletest') !== FALSE) {
// Valid SimpleTest user-agent, log fatal errors to test specific file
// directory. The user-agent is validated in DRUPAL_BOOTSTRAP_DATABASE
// phase so as long as it is a SimpleTest user-agent it is valid.
ini_set('log_errors', 1);
ini_set('error_log', file_directory_path() . '/error.log');
}
// Let all modules take action before menu system handles the request // Let all modules take action before menu system handles the request
// We do not want this while running update.php. // We do not want this while running update.php.
if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') { if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
...@@ -3767,7 +3766,7 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) ...@@ -3767,7 +3766,7 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1)
$searchdir[] = "$config/$directory"; $searchdir[] = "$config/$directory";
} }
// If the database is not available, we can't use drupal_function_exists(), so // If the database is not available, we can't use function_exists(), so
// we load the file_scan_directory function definition manually. // we load the file_scan_directory function definition manually.
if (!function_exists('file_scan_directory')) { if (!function_exists('file_scan_directory')) {
require_once DRUPAL_ROOT . '/includes/file.inc'; require_once DRUPAL_ROOT . '/includes/file.inc';
...@@ -3957,7 +3956,7 @@ function drupal_render(&$elements) { ...@@ -3957,7 +3956,7 @@ function drupal_render(&$elements) {
// element is rendered into the final text. // element is rendered into the final text.
if (isset($elements['#pre_render'])) { if (isset($elements['#pre_render'])) {
foreach ($elements['#pre_render'] as $function) { foreach ($elements['#pre_render'] as $function) {
if (drupal_function_exists($function)) { if (function_exists($function)) {
$elements = $function($elements); $elements = $function($elements);
} }
} }
...@@ -3991,7 +3990,7 @@ function drupal_render(&$elements) { ...@@ -3991,7 +3990,7 @@ function drupal_render(&$elements) {
// which allows the output'ed text to be filtered. // which allows the output'ed text to be filtered.
if (isset($elements['#post_render'])) { if (isset($elements['#post_render'])) {
foreach ($elements['#post_render'] as $function) { foreach ($elements['#post_render'] as $function) {
if (drupal_function_exists($function)) { if (function_exists($function)) {
$elements['#children'] = $function($elements['#children'], $elements); $elements['#children'] = $function($elements['#children'], $elements);
} }
} }
...@@ -4120,6 +4119,7 @@ function element_info($type) { ...@@ -4120,6 +4119,7 @@ function element_info($type) {
if (!isset($cache)) { if (!isset($cache)) {
$basic_defaults = element_basic_defaults(); $basic_defaults = element_basic_defaults();
$cache = array(); $cache = array();
foreach (module_implements('elements') as $module) { foreach (module_implements('elements') as $module) {
$elements = module_invoke($module, 'elements'); $elements = module_invoke($module, 'elements');
if (isset($elements) && is_array($elements)) { if (isset($elements) && is_array($elements)) {
...@@ -5055,3 +5055,32 @@ function drupal_check_incompatibility($v, $current_version) { ...@@ -5055,3 +5055,32 @@ function drupal_check_incompatibility($v, $current_version) {
} }
} }
} }
/**
* Performs one or more XML-RPC request(s).
*
* @param $url
* An absolute URL of the XML-RPC endpoint.
* Example:
* http://www.example.com/xmlrpc.php
* @param ...
* For one request:
* The method name followed by a variable number of arguments to the method.
* For multiple requests (system.multicall):
* An array of call arrays. Each call array follows the pattern of the single
* request: method name followed by the arguments to the method.
* @return
* For one request:
* Either the return value of the method on success, or FALSE.
* If FALSE is returned, see xmlrpc_errno() and xmlrpc_error_msg().
* For multiple requests:
* An array of results. Each result will either be the result
* returned by the method called, or an xmlrpc_error object if the call
* failed. See xmlrpc_error().
*/
function xmlrpc($url) {
require_once DRUPAL_ROOT . '/includes/xmlrpc.inc';
$args = func_get_args();
return call_user_func_array('_xmlrpc', $args);
}
...@@ -320,7 +320,7 @@ function file_create_url($uri) { ...@@ -320,7 +320,7 @@ function file_create_url($uri) {
return FALSE; return FALSE;
} }
} }
// @todo Implement CDN integration hook stuff in this function. // @todo Implement CDN integration hook stuff in this function.
// @see http://drupal.org/node/499156 // @see http://drupal.org/node/499156
} }
...@@ -1250,7 +1250,7 @@ function file_validate(&$file, $validators = array()) { ...@@ -1250,7 +1250,7 @@ function file_validate(&$file, $validators = array()) {
// Call the validation functions specified by this function's caller. // Call the validation functions specified by this function's caller.
$errors = array(); $errors = array();
foreach ($validators as $function => $args) { foreach ($validators as $function => $args) {
if (drupal_function_exists($function)) { if (function_exists($function)) {
array_unshift($args, $file); array_unshift($args, $file);
$errors = array_merge($errors, call_user_func_array($function, $args)); $errors = array_merge($errors, call_user_func_array($function, $args));
} }
......
...@@ -418,7 +418,7 @@ function drupal_retrieve_form($form_id, &$form_state) { ...@@ -418,7 +418,7 @@ function drupal_retrieve_form($form_id, &$form_state) {
// We first check to see if there's a function named after the $form_id. // We first check to see if there's a function named after the $form_id.
// If there is, we simply pass the arguments on to it to get the form. // If there is, we simply pass the arguments on to it to get the form.
if (!drupal_function_exists($form_id)) { if (!function_exists($form_id)) {
// In cases where many form_ids need to share a central constructor function, // In cases where many form_ids need to share a central constructor function,
// such as the node editing form, modules can implement hook_forms(). It // such as the node editing form, modules can implement hook_forms(). It
// maps one or more form_ids to the correct constructor functions. // maps one or more form_ids to the correct constructor functions.
...@@ -439,7 +439,6 @@ function drupal_retrieve_form($form_id, &$form_state) { ...@@ -439,7 +439,6 @@ function drupal_retrieve_form($form_id, &$form_state) {
} }
if (isset($form_definition['callback'])) { if (isset($form_definition['callback'])) {
$callback = $form_definition['callback']; $callback = $form_definition['callback'];
drupal_function_exists($callback);
} }
} }
...@@ -613,13 +612,13 @@ function drupal_prepare_form($form_id, &$form, &$form_state) { ...@@ -613,13 +612,13 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
$form += array('#tree' => FALSE, '#parents' => array()); $form += array('#tree' => FALSE, '#parents' => array());
if (!isset($form['#validate'])) { if (!isset($form['#validate'])) {
if (drupal_function_exists($form_id . '_validate')) { if (function_exists($form_id . '_validate')) {
$form['#validate'] = array($form_id . '_validate'); $form['#validate'] = array($form_id . '_validate');
} }
} }
if (!isset($form['#submit'])) { if (!isset($form['#submit'])) {
if (drupal_function_exists($form_id . '_submit')) { if (function_exists($form_id . '_submit')) {
// We set submit here so that it can be altered. // We set submit here so that it can be altered.
$form['#submit'] = array($form_id . '_submit'); $form['#submit'] = array($form_id . '_submit');
} }
...@@ -794,7 +793,7 @@ function _form_validate($elements, &$form_state, $form_id = NULL) { ...@@ -794,7 +793,7 @@ function _form_validate($elements, &$form_state, $form_id = NULL) {
// #value data. // #value data.
elseif (isset($elements['#element_validate'])) { elseif (isset($elements['#element_validate'])) {
foreach ($elements['#element_validate'] as $function) { foreach ($elements['#element_validate'] as $function) {
if (drupal_function_exists($function)) { if (function_exists($function)) {
$function($elements, $form_state, $form_state['complete form']); $function($elements, $form_state, $form_state['complete form']);
} }
} }
...@@ -831,7 +830,7 @@ function form_execute_handlers($type, &$form, &$form_state) { ...@@ -831,7 +830,7 @@ function form_execute_handlers($type, &$form, &$form_state) {
} }
foreach ($handlers as $function) { foreach ($handlers as $function) {
if (drupal_function_exists($function)) { if (function_exists($function)) {
// Check to see if a previous _submit handler has set a batch, but // Check to see if a previous _submit handler has set a batch, but
// make sure we do not react to a batch that is already being processed // make sure we do not react to a batch that is already being processed
// (for instance if a batch operation performs a drupal_form_submit()). // (for instance if a batch operation performs a drupal_form_submit()).
...@@ -970,7 +969,7 @@ function form_builder($form_id, $element, &$form_state) { ...@@ -970,7 +969,7 @@ function form_builder($form_id, $element, &$form_state) {
// checkboxes and files. // checkboxes and files.
if (isset($element['#process']) && !$element['#processed']) { if (isset($element['#process']) && !$element['#processed']) {
foreach ($element['#process'] as $process) { foreach ($element['#process'] as $process) {
if (drupal_function_exists($process)) { if (function_exists($process)) {
$element = $process($element, $form_state, $form_state['complete form']); $element = $process($element, $form_state, $form_state['complete form']);
} }
} }
...@@ -1097,7 +1096,7 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) { ...@@ -1097,7 +1096,7 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) {
// If we have input for the current element, assign it to the #value property. // If we have input for the current element, assign it to the #value property.
if (!$form_state['programmed'] || isset($input)) { if (!$form_state['programmed'] || isset($input)) {
// Call #type_value to set the form value; // Call #type_value to set the form value;
if (drupal_function_exists($value_callback)) { if (function_exists($value_callback)) {
$element['#value'] = $value_callback($element, $input, $form_state); $element['#value'] = $value_callback($element, $input, $form_state);
} }
if (!isset($element['#value']) && isset($input)) { if (!isset($element['#value']) && isset($input)) {
...@@ -1112,7 +1111,7 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) { ...@@ -1112,7 +1111,7 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) {
// Load defaults. // Load defaults.
if (!isset($element['#value'])) { if (!isset($element['#value'])) {
// Call #type_value without a second argument to request default_value handling. // Call #type_value without a second argument to request default_value handling.
if (drupal_function_exists($value_callback)) { if (function_exists($value_callback)) {
$element['#value'] = $value_callback($element, FALSE, $form_state); $element['#value'] = $value_callback($element, FALSE, $form_state);
} }
// Final catch. If we haven't set a value yet, use the explicit default value. // Final catch. If we haven't set a value yet, use the explicit default value.
......
...@@ -65,7 +65,7 @@ function image_get_toolkit() { ...@@ -65,7 +65,7 @@ function image_get_toolkit() {
if (!isset($toolkit)) { if (!isset($toolkit)) {
$toolkits = image_get_available_toolkits(); $toolkits = image_get_available_toolkits();
$toolkit = variable_get('image_toolkit', 'gd'); $toolkit = variable_get('image_toolkit', 'gd');
if (!isset($toolkits[$toolkit]) || !drupal_function_exists('image_' . $toolkit . '_load')) { if (!isset($toolkits[$toolkit]) || !function_exists('image_' . $toolkit . '_load')) {
// The selected toolkit isn't available so return the first one found. If // The selected toolkit isn't available so return the first one found. If
// none are available this will return FALSE. // none are available this will return FALSE.
reset($toolkits); reset($toolkits);
...@@ -90,7 +90,7 @@ function image_get_toolkit() { ...@@ -90,7 +90,7 @@ function image_get_toolkit() {
*/ */
function image_toolkit_invoke($method, stdClass $image, array $params = array()) { function image_toolkit_invoke($method, stdClass $image, array $params = array()) {
$function = 'image_' . $image->toolkit . '_' . $method; $function = 'image_' . $image->toolkit . '_' . $method;
if (drupal_function_exists($function)) { if (function_exists($function)) {
array_unshift($params, $image); array_unshift($params, $image);
return call_user_func_array($function, $params); return call_user_func_array($function, $params);
} }
......
...@@ -632,15 +632,16 @@ function drupal_install_system() { ...@@ -632,15 +632,16 @@ function drupal_install_system() {
$system_versions = drupal_get_schema_versions('system'); $system_versions = drupal_get_schema_versions('system');
$system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED; $system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED;
db_insert('system') db_insert('system')
->fields(array('filename', 'name', 'type', 'owner', 'status', 'schema_version')) ->fields(array('filename', 'name', 'type', 'owner', 'status', 'schema_version', 'bootstrap'))
->values(array( ->values(array(
'filename' => $system_path . '/system.module', 'filename' => $system_path . '/system.module',
'name' => 'system', 'name' => 'system',
'type' => 'module', 'type' => 'module',
'owner' => '', 'owner' => '',
'status' => 1, 'status' => 1,
'schema_version' => $system_version 'schema_version' => $system_version,
)) 'bootstrap' => 0,
))
->execute(); ->execute();
// Now that we've installed things properly, bootstrap the full Drupal environment // Now that we've installed things properly, bootstrap the full Drupal environment
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
......
...@@ -115,7 +115,7 @@ function drupal_mail($module, $key, $to, $language, $params = array(), $from = N ...@@ -115,7 +115,7 @@ function drupal_mail($module, $key, $to, $language, $params = array(), $from = N
// Build the e-mail (get subject and body, allow additional headers) by // Build the e-mail (get subject and body, allow additional headers) by
// invoking hook_mail() on this module. We cannot use module_invoke() as // invoking hook_mail() on this module. We cannot use module_invoke() as
// we need to have $message by reference in hook_mail(). // we need to have $message by reference in hook_mail().
if (drupal_function_exists($function = $module . '_mail')) { if (function_exists($function = $module . '_mail')) {
$function($key, $message, $params); $function($key, $message, $params);
} }
......
...@@ -411,9 +411,10 @@ function menu_execute_active_handler($path = NULL) { ...@@ -411,9 +411,10 @@ function menu_execute_active_handler($path = NULL) {
} }
if ($router_item = menu_get_item($path)) { if ($router_item = menu_get_item($path)) {
if ($router_item['access']) { if ($router_item['access']) {
if (drupal_function_exists($router_item['page_callback'])) { if ($router_item['file']) {
return call_user_func_array($router_item['page_callback'], $router_item['page_arguments']); require_once($router_item['file']);
} }
return call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
} }
else { else {
return MENU_ACCESS_DENIED; return MENU_ACCESS_DENIED;
...@@ -516,7 +517,7 @@ function _menu_check_access(&$item, $map) { ...@@ -516,7 +517,7 @@ function _menu_check_access(&$item, $map) {
if ($callback == 'user_access') { if ($callback == 'user_access') {
$item['access'] = (count($arguments) == 1) ? user_access($arguments[0]) : user_access($arguments[0], $arguments[1]); $item['access'] = (count($arguments) == 1) ? user_access($arguments[0]) : user_access($arguments[0], $arguments[1]);
} }
elseif (drupal_function_exists($callback)) { elseif (function_exists($callback)) {
$item['access'] = call_user_func_array($callback, $arguments); $item['access'] = call_user_func_array($callback, $arguments);
} }
} }
...@@ -567,7 +568,7 @@ function _menu_item_localize(&$item, $map, $link_translate = FALSE) { ...@@ -567,7 +568,7 @@ function _menu_item_localize(&$item, $map, $link_translate = FALSE) {
$item['title'] = t($item['title'], menu_unserialize($item['title_arguments'], $map)); $item['title'] = t($item['title'], menu_unserialize($item['title_arguments'], $map));
} }
} }
elseif ($callback && drupal_function_exists($callback)) { elseif ($callback && function_exists($callback)) {
if (empty($item['title_arguments'])) { if (empty($item['title_arguments'])) {
$item['title'] = $callback($item['title']); $item['title'] = $callback($item['title']);
} }
...@@ -1905,7 +1906,7 @@ function menu_cache_clear_all() { ...@@ -1905,7 +1906,7 @@ function menu_cache_clear_all() {
function menu_rebuild() { function menu_rebuild() {
if (!lock_acquire('menu_rebuild')) {