summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-11-25 06:14:59 +0000
committerDries Buytaert <dries@buytaert.net>2004-11-25 06:14:59 +0000
commit5d0dfeb5620f6cb130a62381a634141d6a65af63 (patch)
tree7daa38baf096021655d21dc9ab0df394205f9a7f
parent4726c93156e59e0b44faf55845c3f97cf00a9168 (diff)
downloadbrdo-5d0dfeb5620f6cb130a62381a634141d6a65af63.tar.gz
brdo-5d0dfeb5620f6cb130a62381a634141d6a65af63.tar.bz2
- Patch #13405 by Moshe:
+ Make bootstrap functionality work with HEAD. + Move functions into bootstrap.inc so that statistics_exit() works for cached pages. (Does this close any issues?)
-rw-r--r--includes/bootstrap.inc168
-rw-r--r--includes/common.inc145
-rw-r--r--includes/module.inc15
3 files changed, 164 insertions, 164 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index a0d783910..f3f30bfc9 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -43,13 +43,59 @@ function conf_init() {
}
}
}
-
-print "$confdir/default/settings.php<br />";
$conf = "$confdir/default";
return $conf;
}
/**
+ * Returns and optionally sets the filename for a system item (module,
+ * theme, etc.). The filename, whether provided, cached, or retrieved
+ * from the database, is only returned if the file exists.
+ *
+ * @param $type
+ * The type of the item (i.e. theme, theme_engine, module).
+ * @param $name
+ * The name of the item for which the filename is requested.
+ * @param $filename
+ * The filename of the item if it is to be set explicitly rather
+ * than by consulting the database.
+ *
+ * @return
+ * The filename of the requested item.
+ */
+function drupal_get_filename($type, $name, $filename = NULL) {
+ static $files = array();
+
+ if (!$files[$type]) {
+ $files[$type] = array();
+ }
+
+ if ($filename && file_exists($filename)) {
+ $files[$type][$name] = $filename;
+ }
+ elseif ($files[$type][$name]) {
+ // nothing
+ }
+ elseif (($file = db_result(db_query("SELECT filename FROM {system} WHERE name = '%s' AND type = '%s'", $name, $type))) && file_exists($file)) {
+ $files[$type][$name] = $file;
+ }
+ else {
+ $config = conf_init();
+ $dir = (($type == 'theme_engine') ? 'themes/engines' : "${type}s");
+ $file = "$name.$type";
+
+ foreach (array("$config/$dir/$file", "$config/$dir/$name/$file", "$dir/$file", "$dir/$name/$file") as $file) {
+ if (file_exists($file)) {
+ $files[$type][$name] = $file;
+ break;
+ }
+ }
+ }
+
+ return $files[$type][$name];
+}
+
+/**
* Load the persistent variable table.
*
* The variable table is composed of values that have been saved in the table
@@ -240,12 +286,123 @@ function page_get_cache() {
}
/**
+ * Call all init or exit hooks without including all modules.
+ *
+ * @param $op
+ * The name of the bootstrap hook we wish to invoke.
+ */
+function bootstrap_invoke_all($op) {
+ foreach (module_list(FALSE, TRUE) as $module) {
+ drupal_load('module', $module);
+ module_invoke($module, $op);
+ }
+}
+
+/**
+ * Includes a file with the provided type and name. This prevents
+ * including a theme, engine, module, etc., more than once.
+ *
+ * @param $type
+ * The type of item to load (i.e. theme, theme_engine, module).
+ * @param $name
+ * The name of the item to load.
+ *
+ * @return
+ * TRUE if the item is loaded or has already been loaded.
+ */
+function drupal_load($type, $name) {
+ // print $name. '<br />';
+ static $files = array();
+
+ if ($files[$type][$name]) {
+ return TRUE;
+ }
+
+ $filename = drupal_get_filename($type, $name);
+
+ if ($filename) {
+ include_once($filename);
+ $files[$type][$name] = TRUE;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ * Return an array mapping path aliases to their internal Drupal paths.
+ */
+function drupal_get_path_map($action = '') {
+ static $map = NULL;
+
+ if ($action == 'rebuild') {
+ $map = NULL;
+ }
+
+ if (is_null($map)) {
+ $map = array(); // Make $map non-null in case no aliases are defined.
+ $result = db_query('SELECT * FROM {url_alias}');
+ while ($data = db_fetch_object($result)) {
+ $map[$data->dst] = $data->src;
+ }
+ }
+
+ return $map;
+}
+
+/**
+ * Given an internal Drupal path, return the alias set by the administrator.
+ */
+function drupal_get_path_alias($path) {
+ if (($map = drupal_get_path_map()) && ($newpath = array_search($path, $map))) {
+ return $newpath;
+ }
+ elseif (function_exists('conf_url_rewrite')) {
+ return conf_url_rewrite($path, 'outgoing');
+ }
+ else {
+ // No alias found. Return the normal path.
+ return $path;
+ }
+}
+
+/**
+ * Get the title of the current page, for display on the page and in the title bar.
+ */
+function drupal_get_title() {
+ $title = drupal_set_title();
+
+ if (!isset($title)) {
+ // during a bootstrap, menu.inc is not included and thus we cannot provide a title
+ if (function_exists('menu_get_active_title')) {
+ $title = menu_get_active_title();
+ }
+ }
+
+ return $title;
+}
+
+/**
+ * Set the title of the current page, for display on the page and in the title bar.
+ */
+function drupal_set_title($title = NULL) {
+ static $stored_title;
+
+ if (isset($title)) {
+ $stored_title = $title;
+ }
+ return $stored_title;
+}
+
+/**
* Set HTTP headers in preparation for a page response.
*/
function drupal_page_header() {
if (variable_get('dev_timer', 0)) {
timer_start();
}
+ bootstrap_invoke_all('init');
if (variable_get('cache', 0)) {
if ($cache = page_get_cache()) {
@@ -292,12 +449,7 @@ function drupal_page_header() {
}
print $cache->data;
-
- // Call all init() and exit() hooks without including all modules.
- // Only use those hooks for critical operations.
- foreach (bootstrap_hooks() as $hook) {
- module_invoke_all($hook);
- }
+ bootstrap_invoke_all('exit');
exit();
}
}
diff --git a/includes/common.inc b/includes/common.inc
index 911549e0c..87ac73d4b 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -10,31 +10,6 @@
*/
/**
- * Set the title of the current page, for display on the page and in the title bar.
- */
-function drupal_set_title($title = NULL) {
- static $stored_title;
-
- if (isset($title)) {
- $stored_title = $title;
- }
- return $stored_title;
-}
-
-/**
- * Get the title of the current page, for display on the page and in the title bar.
- */
-function drupal_get_title() {
- $title = drupal_set_title();
-
- if (!isset($title)) {
- $title = menu_get_active_title();
- }
-
- return $title;
-}
-
-/**
* Set the breadcrumb trail for the current page.
*
* @param $breadcrumb
@@ -90,27 +65,6 @@ function drupal_get_html_head() {
}
/**
- * Return an array mapping path aliases to their internal Drupal paths.
- */
-function drupal_get_path_map($action = '') {
- static $map = NULL;
-
- if ($action == 'rebuild') {
- $map = NULL;
- }
-
- if (is_null($map)) {
- $map = array(); // Make $map non-null in case no aliases are defined.
- $result = db_query('SELECT * FROM {url_alias}');
- while ($data = db_fetch_object($result)) {
- $map[$data->dst] = $data->src;
- }
- }
-
- return $map;
-}
-
-/**
* Regenerate the path map from the information in the database.
*/
function drupal_rebuild_path_map() {
@@ -118,22 +72,6 @@ function drupal_rebuild_path_map() {
}
/**
- * Given an internal Drupal path, return the alias set by the administrator.
- */
-function drupal_get_path_alias($path) {
- if (($map = drupal_get_path_map()) && ($newpath = array_search($path, $map))) {
- return $newpath;
- }
- elseif (function_exists('conf_url_rewrite')) {
- return conf_url_rewrite($path, 'outgoing');
- }
- else {
- // No alias found. Return the normal path.
- return $path;
- }
-}
-
-/**
* Given a path alias, return the internal path it represents.
*/
function drupal_get_normal_path($path) {
@@ -1819,54 +1757,6 @@ function drupal_eval($code) {
}
/**
- * Returns and optionally sets the filename for a system item (module,
- * theme, etc.). The filename, whether provided, cached, or retrieved
- * from the database, is only returned if the file exists.
- *
- * @param $type
- * The type of the item (i.e. theme, theme_engine, module).
- * @param $name
- * The name of the item for which the filename is requested.
- * @param $filename
- * The filename of the item if it is to be set explicitly rather
- * than by consulting the database.
- *
- * @return
- * The filename of the requested item.
- */
-function drupal_get_filename($type, $name, $filename = NULL) {
- static $files = array();
-
- if (!$files[$type]) {
- $files[$type] = array();
- }
-
- if ($filename && file_exists($filename)) {
- $files[$type][$name] = $filename;
- }
- elseif ($files[$type][$name]) {
- // nothing
- }
- elseif (($file = db_result(db_query("SELECT filename FROM {system} WHERE name = '%s' AND type = '%s'", $name, $type))) && file_exists($file)) {
- $files[$type][$name] = $file;
- }
- else {
- $config = conf_init();
- $dir = (($type == 'theme_engine') ? 'themes/engines' : "${type}s");
- $file = "$name.$type";
-
- foreach (array("$config/$dir/$file", "$config/$dir/$name/$file", "$dir/$file", "$dir/$name/$file") as $file) {
- if (file_exists($file)) {
- $files[$type][$name] = $file;
- break;
- }
- }
- }
-
- return $files[$type][$name];
-}
-
-/**
* Returns the path to a system item (module, theme, etc.).
*
* @param $type
@@ -1881,37 +1771,6 @@ function drupal_get_path($type, $name) {
return dirname(drupal_get_filename($type, $name));
}
-/**
- * Includes a file with the provided type and name. This prevents
- * including a theme, engine, module, etc., more than once.
- *
- * @param $type
- * The type of item to load (i.e. theme, theme_engine, module).
- * @param $name
- * The name of the item to load.
- *
- * @return
- * TRUE if the item is loaded or has already been loaded.
- */
-function drupal_load($type, $name) {
- static $files = array();
-
- if ($files[$type][$name]) {
- return TRUE;
- }
-
- $filename = drupal_get_filename($type, $name);
-
- if ($filename) {
- include_once($filename);
- $files[$type][$name] = TRUE;
-
- return TRUE;
- }
-
- return FALSE;
-}
-
include_once 'includes/theme.inc';
include_once 'includes/pager.inc';
include_once 'includes/menu.inc';
@@ -1933,8 +1792,8 @@ else {
$_GET['q'] = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
}
-// Initialize all enabled modules.
-module_init();
+// Load all enabled modules.
+module_load_all();
if ($_REQUEST && !user_access('bypass input data check')) {
if (!valid_input_data($_REQUEST)) {
diff --git a/includes/module.inc b/includes/module.inc
index e5a68d7f1..8cfe216e3 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -7,17 +7,6 @@
*/
/**
- * Initialize all modules.
- *
- * To change the required set of modules, change this function as well as
- * system_listing() and module_list().
- */
-function module_init() {
- module_load_all();
- module_invoke_all('init');
-}
-
-/**
* Call a function repeatedly with each module in turn as an argument.
*/
function module_iterate($function, $argument = '') {
@@ -43,7 +32,7 @@ function module_list($refresh = FALSE, $bootstrap = FALSE) {
static $list;
if ($refresh) {
- unset($list);
+ $list = array();
}
if (!$list) {
@@ -78,7 +67,7 @@ function module_list($refresh = FALSE, $bootstrap = FALSE) {
* TRUE if all modules were loaded successfully.
*/
function module_load_all() {
- $list = module_list();
+ $list = module_list(TRUE, FALSE);
$status = TRUE;
foreach ($list as $module) {