--- poormanscron.module.1.18.2.1 Sun Jan 14 12:34:37 2007 +++ poormanscron.module Tue Aug 12 13:01:16 2008 @@ -46,6 +46,45 @@ function poormanscron_exit() { // we don't get a chance to restore them below. $saved_messages = drupal_set_message(); + // We don't know whether this exit hook is being run after serving the page + // from Drupal's page cache or at the end of the request after a full + // Drupal bootstrap. However, we need to ensure that something equivalent + // to a full bootstrap has taken place since cron hooks can reasonably + // assume a full bootstrap has happened. But we can't simply request a + // full bootstrap since this will set an HTTP response header, causing a + // a PHP error if the current page request has just been served from + // Drupal's page cache. Therefore we need to simulate a full bootstrap. + + // We can be sure that bootstrap phase DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE has + // essentially been completed. Continue with DRUPAL_BOOTSTRAP_PATH. + drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH); + // Now simulate the final bootstrap phase, but without setting the HTTP + // header or invoking init hooks. If a full bootstrap has already taken + // place, no harm should be done by attempting to do the following again. + require_once './includes/common.inc'; + require_once './includes/theme.inc'; + require_once './includes/pager.inc'; + require_once './includes/menu.inc'; + require_once './includes/tablesort.inc'; + require_once './includes/file.inc'; + require_once './includes/unicode.inc'; + require_once './includes/image.inc'; + require_once './includes/form.inc'; + // Set the Drupal custom error handler. + set_error_handler('error_handler'); + // Detect string handling method + unicode_check(); + // Undo magic quotes + fix_gpc_magic(); + // Load all enabled modules + module_load_all(); + // Check if the localization system has already been initialized. + if (!isset($GLOBALS['locale'])) { + // Initialize the localization system. Depends on i18n.module being loaded already. + $locale = locale_initialize(); + } + // End of simulated full bootstrap. + // Invoke the cron hooks of all enabled modules. if (variable_get('poormanscron_log_progress', 0) == 1) { // Invoke the cron hooks of all enabled modules and log the progress.