I have patched Drupal core with the supplied patch, and enabled the cache class in my settings.php.
Before the module is enabled, i get the following error:
PHP Fatal error: Class 'CacheLocale' not found in /dr_vagrant/checkouts/loc1.drupal.dr.dk/docroot/modules/locale/locale.module on line 685
The problem is that the first time the locale()-function is called is sets the static variable $custom_locale to the value fetched from the Drupal variable custom_locale. If that class does not exist it calls the watchdog-function stating exactly that. After this is sets the static variable $custom_locale to false to make sure the function never tries to use that class.
// Support for custom locale function.
static $custom_locale = NULL;
if (!isset($custom_locale)) {
$custom_locale = variable_get('custom_locale', FALSE);
if ($custom_locale) {
if (!class_exists($custom_locale)) {
watchdog('locale', 'Class %class does not exist', array('%class' => $locale_class), WATCHDOG_ERROR);
$custom_locale = FALSE;
}
...
However, watchdog calls hook_watchdog, and if hook_watchdog is implemented with some code that calls the t()-function, that in turn calls the locale()-function. At this point the static variable $custom_locale is set to the name of the class, even though it does not exist, and the check for whether or not it exists is never reached. The code then tries to use it resulting in a fatal error.
I propose that setting the static variable $custom_locale is done before calling watchdog, like this:
// Support for custom locale function.
static $custom_locale = NULL;
if (!isset($custom_locale)) {
$custom_locale = variable_get('custom_locale', FALSE);
if ($custom_locale) {
if (!class_exists($custom_locale)) {
// Calling watchdog results in calling hook_watchdog, that might call
// t() resulting in calling this function. Because of this we have to
// set the static $custom_locale to false before calling watchdog, or
// the next time this function is called, it will think that the class
// exists.
$locale_class = $custom_locale;
$custom_locale = FALSE;
watchdog('locale', 'Class %class does not exist', array('%class' => $locale_class), WATCHDOG_ERROR);
}
...
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | cache_locale-core-patch-static-error-2487986-1.patch | 1.92 KB | mian3010 |
Comments
Comment #1
mian3010 commentedAttached patch with solution as described
Comment #3
Anonymous (not verified) commentedThe patch does not apply cleanly for me.