Commit ce4df7b6 authored by Dries's avatar Dries

- Patch #422374 by JamesAn: convert to use the new static caching API.

parent 238c2a61
......@@ -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)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\2'), preg_quote($patterns, '/')) . ')$/';
......
......@@ -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();
......
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment