From: Tim Starling Date: Sun, 13 Nov 2005 04:09:06 +0000 (+0000) Subject: Moving the title cache from a static local variable to a global, to allow it to be... X-Git-Tag: 1.6.0~1182 X-Git-Url: http://git.cyclocoop.org/wiki/Target_page?a=commitdiff_plain;h=b5f4bac21ff4aedd5b318812259ff05bf7da8ddf;p=lhc%2Fweb%2Fwiklou.git Moving the title cache from a static local variable to a global, to allow it to be cleared for benchmarking purposes. --- 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;