From b5f4bac21ff4aedd5b318812259ff05bf7da8ddf Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 13 Nov 2005 04:09:06 +0000 Subject: [PATCH] Moving the title cache from a static local variable to a global, to allow it to be cleared for benchmarking purposes. --- includes/Title.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index edde4ee73f..b2ec314e2d 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -9,6 +9,8 @@ require_once( 'normal/UtfNormal.php' ); $wgTitleInterwikiCache = array(); +$wgTitleCache = array(); + define ( 'GAID_FOR_UPDATE', 1 ); # Title::newFromTitle maintains a cache to avoid @@ -103,6 +105,7 @@ class Title { * @access public */ function newFromText( $text, $defaultNamespace = NS_MAIN ) { + global $wgTitleCache; $fname = 'Title::newFromText'; wfProfileIn( $fname ); @@ -118,10 +121,9 @@ class Title { * * In theory these are value objects and won't get changed... */ - static $titleCache = array(); - if( $defaultNamespace == NS_MAIN && isset( $titleCache[$text] ) ) { + if( $defaultNamespace == NS_MAIN && isset( $wgTitleCache[$text] ) ) { wfProfileOut( $fname ); - return $titleCache[$text]; + return $wgTitleCache[$text]; } /** @@ -135,11 +137,11 @@ class Title { if( $t->secureAndSplit() ) { if( $defaultNamespace == NS_MAIN ) { - if( count( $titleCache ) >= MW_TITLECACHE_MAX ) { + if( count( $wgTitleCache ) >= MW_TITLECACHE_MAX ) { # Avoid memory leaks on mass operations... - $titleCache = array(); + $wgTitleCache = array(); } - $titleCache[$text] =& $t; + $wgTitleCache[$text] =& $t; } wfProfileOut( $fname ); return $t; -- 2.20.1