Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.208 diff -u -3 -p -r1.208 bootstrap.inc --- includes/bootstrap.inc 14 Apr 2008 17:48:33 -0000 1.208 +++ includes/bootstrap.inc 27 Apr 2008 10:50:49 -0000 @@ -71,31 +71,36 @@ define('DRUPAL_BOOTSTRAP_DATABASE', 2); define('DRUPAL_BOOTSTRAP_ACCESS', 3); /** - * Fifth bootstrap phase: initialize session handling. + * Fifth bootstrap phase: initialize locking system. */ -define('DRUPAL_BOOTSTRAP_SESSION', 4); +define('DRUPAL_BOOTSTRAP_LOCK', 4); /** - * Sixth bootstrap phase: load bootstrap.inc and module.inc, start + * Sixth bootstrap phase: initialize session handling. + */ +define('DRUPAL_BOOTSTRAP_SESSION', 5); + +/** + * Seventh bootstrap phase: load bootstrap.inc and module.inc, start * the variable system and try to serve a page from the cache. */ -define('DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE', 5); +define('DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE', 6); /** - * Seventh bootstrap phase: find out language of the page. + * Eighth bootstrap phase: find out language of the page. */ -define('DRUPAL_BOOTSTRAP_LANGUAGE', 6); +define('DRUPAL_BOOTSTRAP_LANGUAGE', 7); /** - * Eighth bootstrap phase: set $_GET['q'] to Drupal path of request. + * Nineth bootstrap phase: set $_GET['q'] to Drupal path of request. */ -define('DRUPAL_BOOTSTRAP_PATH', 7); +define('DRUPAL_BOOTSTRAP_PATH', 8); /** * Final bootstrap phase: Drupal is fully loaded; validate and fix * input data. */ -define('DRUPAL_BOOTSTRAP_FULL', 8); +define('DRUPAL_BOOTSTRAP_FULL', 9); /** * Role ID for anonymous users; should match what's in the "role" table. @@ -902,6 +907,7 @@ function drupal_anonymous_user($session * DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE: try to call a non-database cache fetch routine. * DRUPAL_BOOTSTRAP_DATABASE: initialize database layer. * DRUPAL_BOOTSTRAP_ACCESS: identify and reject banned hosts. + * DRUPAL_BOOTSTRAP_LOCK: initialize locking system. * DRUPAL_BOOTSTRAP_SESSION: initialize session handling. * DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE: load bootstrap.inc and module.inc, start * the variable system and try to serve a page from the cache. @@ -910,7 +916,7 @@ function drupal_anonymous_user($session * DRUPAL_BOOTSTRAP_FULL: Drupal is fully loaded, validate and fix input data. */ function drupal_bootstrap($phase) { - static $phases = array(DRUPAL_BOOTSTRAP_CONFIGURATION, DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE, DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_ACCESS, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE, DRUPAL_BOOTSTRAP_LANGUAGE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL), $phase_index = 0; + static $phases = array(DRUPAL_BOOTSTRAP_CONFIGURATION, DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE, DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_ACCESS, DRUPAL_BOOTSTRAP_LOCK, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE, DRUPAL_BOOTSTRAP_LANGUAGE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL), $phase_index = 0; while ($phase >= $phase_index && isset($phases[$phase_index])) { $current_phase = $phases[$phase_index]; @@ -960,6 +966,11 @@ function _drupal_bootstrap($phase) { } break; + case DRUPAL_BOOTSTRAP_LOCK: + require_once variable_get('lock_inc', './includes/lock-db.inc'); + lock_init(); + break; + case DRUPAL_BOOTSTRAP_SESSION: require_once variable_get('session_inc', './includes/session.inc'); session_set_save_handler('sess_open', 'sess_close', 'sess_read', 'sess_write', 'sess_destroy_sid', 'sess_gc'); Index: includes/lock-apc.inc =================================================================== RCS file: includes/lock-apc.inc diff -N includes/lock-apc.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ includes/lock-apc.inc 27 Apr 2008 10:50:49 -0000 @@ -0,0 +1,96 @@ + $v) { + apc_delete('lock:' . $instance_id . ':' . $lock_name); + } + $locks = array(); + } +} Index: includes/lock-db.inc =================================================================== RCS file: includes/lock-db.inc diff -N includes/lock-db.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ includes/lock-db.inc 27 Apr 2008 10:50:49 -0000 @@ -0,0 +1,93 @@ +data; } else { - // Refresh database stored cache of translations for given language. - // We only store short strings used in current version, to improve - // performance and consume less memory. - $result = db_query("SELECT s.source, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = 'default' AND s.version = '%s' AND LENGTH(s.source) < 75", $langcode, VERSION); - while ($data = db_fetch_object($result)) { - $locale_t[$langcode][$data->source] = (empty($data->translation) ? TRUE : $data->translation); + if (lock_acquire('locale_cache_' . $langcode)) { + // Refresh database stored cache of translations for given language. + // We only store short strings used in current version, to improve + // performance and consume less memory. + $result = db_query("SELECT s.source, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = 'default' AND s.version = '%s' AND LENGTH(s.source) < 75", $langcode, VERSION); + while ($data = db_fetch_object($result)) { + $locale_t[$langcode][$data->source] = (empty($data->translation) ? TRUE : $data->translation); + } + cache_set('locale:' . $langcode, $locale_t[$langcode]); + lock_release('locale_cache_' . $langcode); } - cache_set('locale:' . $langcode, $locale_t[$langcode]); } } }