Commit ef09cf93 authored by Dries's avatar Dries

- Patch #517542 by David Strauss: renamed functions for clarity. We say 'yay' to clarity!

parent 942f63b4
......@@ -391,9 +391,9 @@ function conf_path($require_settings = TRUE, $reset = FALSE) {
}
/**
* Initialize variables needed for the rest of the execution.
* Initialize PHP environment.
*/
function drupal_initialize_variables() {
function drupal_environment_initialize() {
if (!isset($_SERVER['HTTP_REFERER'])) {
$_SERVER['HTTP_REFERER'] = '';
}
......@@ -454,7 +454,7 @@ function drupal_valid_http_host($host) {
* Loads the configuration and sets the base URL, cookie domain, and
* session name correctly.
*/
function conf_init() {
function drupal_settings_initialize() {
global $base_url, $base_path, $base_root;
// Export the following settings.php variables to the global namespace
......@@ -605,7 +605,7 @@ function drupal_get_filename($type, $name, $filename = NULL) {
* with variable_set() as well as those explicitly specified in the configuration
* file.
*/
function variable_init($conf = array()) {
function variable_initialize($conf = array()) {
// NOTE: caching the variables improves performance by 20% when serving cached pages.
if ($cached = cache_get('variables', 'cache')) {
$variables = $cached->data;
......@@ -1322,11 +1322,11 @@ function _drupal_bootstrap($phase) {
switch ($phase) {
case DRUPAL_BOOTSTRAP_CONFIGURATION:
drupal_initialize_variables();
drupal_environment_initialize();
// Start a page timer:
timer_start('page');
// Initialize the configuration
conf_init();
// Initialize the configuration, including variables from settings.php.
drupal_settings_initialize();
break;
case DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE:
......@@ -1366,8 +1366,8 @@ function _drupal_bootstrap($phase) {
break;
case DRUPAL_BOOTSTRAP_VARIABLES:
// Initialize configuration variables, using values from settings.php if available.
$conf = variable_init(isset($conf) ? $conf : array());
// Load variables from the database, but do not overwrite variables set in settings.php.
$conf = variable_initialize(isset($conf) ? $conf : array());
break;
case DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE:
......@@ -1412,13 +1412,13 @@ function _drupal_bootstrap($phase) {
break;
case DRUPAL_BOOTSTRAP_LANGUAGE:
drupal_init_language();
drupal_language_initialize();
break;
case DRUPAL_BOOTSTRAP_PATH:
require_once DRUPAL_ROOT . '/includes/path.inc';
// Initialize $_GET['q'] prior to loading modules and invoking hook_init().
drupal_init_path();
drupal_path_initialize();
break;
case DRUPAL_BOOTSTRAP_FULL:
......@@ -1458,7 +1458,7 @@ function get_t() {
/**
* Choose a language for the current page, based on site and user preferences.
*/
function drupal_init_language() {
function drupal_language_initialize() {
global $language, $user;
// Ensure the language is correctly returned, even without multilanguage support.
......@@ -1608,8 +1608,8 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) {
// Invoke hook_schema for all modules.
foreach (module_implements('schema') as $module) {
$current = module_invoke($module, 'schema');
if (drupal_function_exists('_drupal_initialize_schema')) {
_drupal_initialize_schema($module, $current);
if (drupal_function_exists('_drupal_schema_initialize')) {
_drupal_schema_initialize($module, $current);
}
$schema = array_merge($schema, $current);
......
......@@ -798,7 +798,7 @@ function _drupal_decode_exception($exception) {
*/
function _drupal_log_error($error, $fatal = FALSE) {
// Initialize a maintenance theme if the boostrap was not complete.
// Do it early because drupal_set_message() triggers an init_theme().
// Do it early because drupal_set_message() triggers a drupal_theme_initialize().
if ($fatal && (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL)) {
unset($GLOBALS['theme']);
if (!defined('MAINTENANCE_MODE')) {
......@@ -4274,7 +4274,7 @@ function drupal_common_theme() {
*/
function drupal_install_schema($module) {
$schema = drupal_get_schema_unprocessed($module);
_drupal_initialize_schema($module, $schema);
_drupal_schema_initialize($module, $schema);
$ret = array();
foreach ($schema as $name => $table) {
......@@ -4299,7 +4299,7 @@ function drupal_install_schema($module) {
*/
function drupal_uninstall_schema($module) {
$schema = drupal_get_schema_unprocessed($module);
_drupal_initialize_schema($module, $schema);
_drupal_schema_initialize($module, $schema);
$ret = array();
foreach ($schema as $table) {
......@@ -4356,7 +4356,7 @@ function drupal_get_schema_unprocessed($module, $table = NULL) {
* The schema definition array as it was returned by the module's
* hook_schema().
*/
function _drupal_initialize_schema($module, &$schema) {
function _drupal_schema_initialize($module, &$schema) {
// Set the name and module key for all tables.
foreach ($schema as $name => $table) {
if (empty($table['module'])) {
......
......@@ -2442,7 +2442,7 @@ function db_change_field(&$ret, $table, $field, $field_new, $spec, $keys_new = a
*/
function _db_error_page($error = '') {
global $db_type;
drupal_init_language();
drupal_language_initialize();
drupal_maintenance_theme();
drupal_set_header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
drupal_set_title('Site offline');
......
......@@ -201,7 +201,7 @@ function drupal_build_form($form_id, &$form_state) {
// Don't override #theme if someone already set it.
if (!isset($form['#theme'])) {
init_theme();
drupal_theme_initialize();
$registry = theme_get_registry();
if (isset($registry[$form_id])) {
$form['#theme'] = $form_id;
......
......@@ -548,7 +548,7 @@ function _drupal_install_module($module) {
* Because we have no registry yet, we need to manually include the
* necessary database include files.
*/
function drupal_install_init_database() {
function drupal_install_initialize_database() {
static $included = FALSE;
if (!$included) {
......@@ -573,7 +573,7 @@ function drupal_install_init_database() {
function drupal_install_system() {
$system_path = dirname(drupal_get_filename('module', 'system', NULL));
require_once DRUPAL_ROOT . '/' . $system_path . '/system.install';
drupal_install_init_database();
drupal_install_initialize_database();
module_invoke('system', 'install');
$system_versions = drupal_get_schema_versions('system');
......
......@@ -13,7 +13,7 @@
/**
* Initialize the $_GET['q'] variable to the proper normal path.
*/
function drupal_init_path() {
function drupal_path_initialize() {
if (!empty($_GET['q'])) {
$_GET['q'] = drupal_get_normal_path(trim($_GET['q'], '/'));
}
......@@ -309,7 +309,7 @@ function drupal_is_front_page() {
$is_front_page = &drupal_static(__FUNCTION__);
if (!isset($is_front_page)) {
// As drupal_init_path updates $_GET['q'] with the 'site_frontpage' path,
// As drupal_path_initialize updates $_GET['q'] with the 'site_frontpage' path,
// we can check it against the 'site_frontpage' variable.
$is_front_page = ($_GET['q'] == drupal_get_normal_path(variable_get('site_frontpage', 'node')));
}
......
......@@ -40,7 +40,7 @@
/**
* Initialize the theme system by loading the theme.
*/
function init_theme() {
function drupal_theme_initialize() {
global $theme, $user, $custom_theme, $theme_key;
// If $theme is already set, assume the others are set, too, and do nothing
......@@ -69,7 +69,7 @@ function init_theme() {
$base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme];
$ancestor = $themes[$ancestor]->base_theme;
}
_init_theme($themes[$theme], array_reverse($base_theme));
_drupal_theme_initialize($themes[$theme], array_reverse($base_theme));
}
/**
......@@ -97,7 +97,7 @@ function init_theme() {
* @param $registry_callback
* The callback to invoke to set the theme registry.
*/
function _init_theme($theme, $base_theme = array(), $registry_callback = '_theme_load_registry') {
function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callback = '_theme_load_registry') {
global $theme_info, $base_theme_info, $theme_engine, $theme_path;
$theme_info = $theme;
$base_theme_info = $base_theme;
......@@ -690,7 +690,7 @@ function theme() {
static $hooks = NULL;
if (!isset($hooks)) {
init_theme();
drupal_theme_initialize();
$hooks = theme_get_registry();
}
......@@ -874,7 +874,7 @@ function path_to_theme() {
global $theme_path;
if (!isset($theme_path)) {
init_theme();
drupal_theme_initialize();
}
return $theme_path;
......
......@@ -61,7 +61,7 @@ function _drupal_maintenance_theme() {
$base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme];
$ancestor = $themes[$ancestor]->base_theme;
}
_init_theme($themes[$theme], array_reverse($base_theme), '_theme_load_offline_registry');
_drupal_theme_initialize($themes[$theme], array_reverse($base_theme), '_theme_load_offline_registry');
// These are usually added from system_init() -except maintenance.css.
// When the database is inactive it's not called so we add it here.
......
......@@ -46,7 +46,7 @@ function install_main() {
drupal_page_header();
// Set up $language, so t() caller functions will still work.
drupal_init_language();
drupal_language_initialize();
// Load module basics (needed for hook invokes).
include_once DRUPAL_ROOT . '/includes/module.inc';
......@@ -622,7 +622,7 @@ function install_tasks($profile, $task) {
// Bootstrap newly installed Drupal, while preserving existing messages.
$messages = isset($_SESSION['messages']) ? $_SESSION['messages'] : '';
drupal_install_init_database();
drupal_install_initialize_database();
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$_SESSION['messages'] = $messages;
......
......@@ -32,7 +32,7 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) {
// If non-default theme configuration has been selected, set the custom theme.
$custom_theme = isset($theme) ? $theme : variable_get('theme_default', 'garland');
init_theme();
drupal_theme_initialize();
$block_regions = system_region_list($theme_key) + array(BLOCK_REGION_NONE => '<' . t('none') . '>');
......
......@@ -233,7 +233,7 @@ function block_page_alter($page) {
global $theme;
// The theme system might not yet be initialized. We need $theme.
init_theme();
drupal_theme_initialize();
// Populate all block regions
$regions = system_region_list($theme);
......@@ -293,7 +293,7 @@ function block_get_blocks_by_region($region) {
function _block_rehash() {
global $theme_key;
init_theme();
drupal_theme_initialize();
$old_blocks = array();
$result = db_query("SELECT * FROM {block} WHERE theme = :theme", array(':theme' => $theme_key));
......@@ -509,7 +509,7 @@ function block_system_themes_form_submit(&$form, &$form_state) {
if (is_array($form_state['values']['status'])) {
foreach ($form_state['values']['status'] as $key => $choice) {
if ($choice || $form_state['values']['theme_default'] == $key) {
block_initialize_theme_blocks($key);
block_theme_initialize($key);
}
}
}
......@@ -517,7 +517,7 @@ function block_system_themes_form_submit(&$form, &$form_state) {
// If we're changing themes, make sure the theme has its blocks initialized.
$has_blocks = (bool) db_query_range('SELECT 1 FROM {block} WHERE theme = :theme', array(':theme' => $form_state['values']['admin_theme']), 0, 1)->fetchField();
if (!$has_blocks) {
block_initialize_theme_blocks($form_state['values']['admin_theme']);
block_theme_initialize($form_state['values']['admin_theme']);
}
}
}
......@@ -534,7 +534,7 @@ function block_system_themes_form_submit(&$form, &$form_state) {
* @param $theme
* The name of a theme.
*/
function block_initialize_theme_blocks($theme) {
function block_theme_initialize($theme) {
// Initialize theme's blocks if none already registered.
$has_blocks = (bool) db_query_range('SELECT 1 FROM {block} WHERE theme = :theme', array(':theme' => $theme), 0, 1)->fetchField();
if (!$has_blocks) {
......
......@@ -81,7 +81,7 @@ function locale_uninstall() {
// Switch back to English: with a $language->language value different from 'en'
// successive calls of t() might result in calling locale(), which in turn might
// try to query the unexisting {locales_source} and {locales_target} tables.
drupal_init_language();
drupal_language_initialize();
// Remove tables.
drupal_uninstall_schema('locale');
......
......@@ -934,7 +934,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
locale_add_language('fr', 'French', 'Français', LANGUAGE_LTR, '', '', TRUE, $this->ui_language == 'fr');
// Check the UI language.
drupal_init_language();
drupal_language_initialize();
global $language;
$this->assertEqual($language->language, $this->ui_language, t('Current language: %lang', array('%lang' => $language->language)));
......@@ -973,7 +973,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
$this->drupalGet('');
// Check the init language logic.
drupal_init_language();
drupal_language_initialize();
$this->assertEqual($language->language, 'en', t('Language after uninstall: %lang', array('%lang' => $language->language)));
// Check JavaScript files deletion.
......
......@@ -185,7 +185,7 @@ class PathLanguageTestCase extends DrupalWebTestCase {
variable_set('language_negotiation', LANGUAGE_NEGOTIATION_PATH);
// Force inclusion of language.inc.
drupal_init_language();
drupal_language_initialize();
}
/**
......
......@@ -525,7 +525,7 @@ function update_prepare_d7_bootstrap() {
// Allow the database system to work even if the registry has not been
// created yet.
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
drupal_install_init_database();
drupal_install_initialize_database();
spl_autoload_unregister('drupal_autoload_class');
spl_autoload_unregister('drupal_autoload_interface');
// The new {blocked_ips} table is used in Drupal 7 to store a list of
......@@ -682,7 +682,7 @@ function update_check_requirements() {
drupal_load('module', 'filter');
// Set up $language, since the installer components require it.
drupal_init_language();
drupal_language_initialize();
// Set up theme system for the maintenance page.
drupal_maintenance_theme();
......
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