From ce4df7b66b9b7475b28eaaf3ca92f043f511cf3e Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 3 Apr 2009 17:41:32 +0000 Subject: - Patch #422374 by JamesAn: convert to use the new static caching API. --- includes/path.inc | 12 +++++++----- includes/registry.inc | 4 ++-- includes/session.inc | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) (limited to 'includes') diff --git a/includes/path.inc b/includes/path.inc index 6eedad9bf..1ff9cb36d 100644 --- a/includes/path.inc +++ b/includes/path.inc @@ -46,7 +46,9 @@ function drupal_init_path() { function drupal_lookup_path($action, $path = '', $path_language = '') { global $language; // $map is an array with language keys, holding arrays of Drupal paths to alias relations - static $map = array(), $no_src = array(), $count; + $map = &drupal_static(__FUNCTION__, array()); + $no_src = &drupal_static(__FUNCTION__ . ':no_src', array()); + $count = &drupal_static(__FUNCTION__ . ':count'); $path_language = $path_language ? $path_language : $language->language; @@ -165,7 +167,7 @@ function drupal_get_normal_path($path, $path_language = '') { * not found. */ function arg($index = NULL, $path = NULL) { - static $arguments; + $arguments = &drupal_static(__FUNCTION__); if (!isset($path)) { $path = $_GET['q']; @@ -214,7 +216,7 @@ function drupal_get_title() { * The updated title of the current page. */ function drupal_set_title($title = NULL, $output = CHECK_PLAIN) { - static $stored_title; + $stored_title = &drupal_static(__FUNCTION__); if (isset($title)) { $stored_title = ($output == PASS_THROUGH) ? $title : check_plain($title); @@ -230,7 +232,7 @@ function drupal_set_title($title = NULL, $output = CHECK_PLAIN) { * Boolean value: TRUE if the current page is the front page; FALSE if otherwise. */ function drupal_is_front_page() { - static $is_front_page; + $is_front_page = &drupal_static(__FUNCTION__); if (!isset($is_front_page)) { // As drupal_init_path updates $_GET['q'] with the 'site_frontpage' path, @@ -253,7 +255,7 @@ function drupal_is_front_page() { * Boolean value: TRUE if the path matches a pattern, FALSE otherwise. */ function drupal_match_path($path, $patterns) { - static $regexps; + $regexps = &drupal_static(__FUNCTION__); if (!isset($regexps[$patterns])) { $regexps[$patterns] = '/^(' . preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\($|\|)/'), array('|', '.*', '\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\2'), preg_quote($patterns, '/')) . ')$/'; diff --git a/includes/registry.inc b/includes/registry.inc index 35caaa3fb..3fb3a9964 100644 --- a/includes/registry.inc +++ b/includes/registry.inc @@ -145,7 +145,7 @@ function _registry_parse_files($files) { * (optional) Weight of the module. */ function _registry_parse_file($filename, $contents, $module = '', $weight = 0) { - static $map = array(T_FUNCTION => 'function', T_CLASS => 'class', T_INTERFACE => 'interface'); + $map = &drupal_static(__FUNCTION__, array(T_FUNCTION => 'function', T_CLASS => 'class', T_INTERFACE => 'interface')); // Delete registry entries for this file, so we can insert the new resources. db_delete('registry') ->condition('filename', $filename) @@ -207,7 +207,7 @@ function _registry_parse_file($filename, $contents, $module = '', $weight = 0) { function _registry_get_resource_name(&$tokens = NULL, $type = NULL) { // Keep a running list of all resources we've saved so far, so that we never // save one more than once. - static $resources; + $resources = &drupal_static(__FUNCTION__); if (!isset($tokens)) { $resources = array(); diff --git a/includes/session.inc b/includes/session.inc index aa06db4ca..e6bcde173 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -169,7 +169,7 @@ function _sess_write($key, $value) { * TRUE if session has already been started, or FALSE if it has not. */ function drupal_session_start($start = TRUE) { - static $started = FALSE; + $started = &drupal_static(__FUNCTION__, FALSE); if ($start && !$started) { $started = TRUE; session_start(); @@ -329,7 +329,7 @@ function _sess_gc($lifetime) { * FALSE if writing session data has been disabled. Otherwise, TRUE. */ function drupal_save_session($status = NULL) { - static $save_session = TRUE; + $save_session = &drupal_static(__FUNCTION__, TRUE); if (isset($status)) { $save_session = $status; } -- cgit v1.2.3