diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 3f2f591..4c7223e 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1452,8 +1452,24 @@ function t($string, array $args = array(), array $options = array()) { static $custom_strings; $locale_exists = &drupal_static(__FUNCTION__); + // Check whether locale() is available and operational. if (!isset($locale_exits)) { - $locale_exists = function_exists('module_exists') && module_exists('locale'); + // The availability of locale() requires more explanation: + // - Whether the module system has been loaded. + // In early bootstrap, in the installer, update.php, and also in early + // error/exception conditions, the module system might not be loaded yet. + // - Whether Locale module is enabled. + // The mere existence of locale() does not imply that Locale module is + // actually enabled and its database tables are installed. Since PHP code + // cannot be unloaded, this is typically the case in the environment that + // is executing a test. + // - Whether Locale module actually has been loaded. + // The Locale module may be enabled, but the actual .module might not be + // loaded. This is typically the case in update.php, which needs to + // populate the full module list to invoke hook_requirements(), but must + // not load any actual modules and APIs, since they are not guaranteed to + // be operational. + $locale_exists = function_exists('module_exists') && module_exists('locale') && function_exists('locale'); } // Merge in default.