r14658 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r14657‎ | r14658 | r14659 >
Date:13:08, 8 June 2006
Author:midom
Status:old
Tags:
Comment:
woo, revert the revert, apc 3.0.8 seems to work with this :)
Modified paths:
  • /trunk/phase3/includes/CacheManager.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/trackback.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/CacheManager.php
@@ -6,11 +6,6 @@
77 */
88
99 /**
10 - * We need the title class
11 - */
12 -require_once( 'Title.php' );
13 -
14 -/**
1510 * Handles talking to the file cache, putting stuff in and taking it back out.
1611 * Mostly called from Article.php, also from DatabaseFunctions.php for the
1712 * emergency abort/fallback to cache.
Index: trunk/phase3/includes/Setup.php
@@ -57,7 +57,6 @@
5858 require_once( 'User.php' );
5959 require_once( 'Skin.php' );
6060 require_once( 'OutputPage.php' );
61 -require_once( 'Title.php' );
6261 require_once( 'MagicWord.php' );
6362 require_once( 'Block.php' );
6463 require_once( 'MessageCache.php' );
Index: trunk/phase3/includes/Title.php
@@ -8,9 +8,6 @@
99 /** */
1010 require_once( 'normal/UtfNormal.php' );
1111
12 -$wgTitleInterwikiCache = array();
13 -$wgTitleCache = array();
14 -
1512 define ( 'GAID_FOR_UPDATE', 1 );
1613
1714 # Title::newFromTitle maintains a cache to avoid
@@ -29,6 +26,13 @@
3027 */
3128 class Title {
3229 /**
 30+ * Static cache variables
 31+ */
 32+ static private $titleCache=array();
 33+ static private $interwikiCache=array();
 34+
 35+
 36+ /**
3337 * All member variables should be considered private
3438 * Please use the accessor functions
3539 */
@@ -105,7 +109,6 @@
106110 * @access public
107111 */
108112 function newFromText( $text, $defaultNamespace = NS_MAIN ) {
109 - global $wgTitleCache;
110113 $fname = 'Title::newFromText';
111114
112115 if( is_object( $text ) ) {
@@ -120,8 +123,8 @@
121124 *
122125 * In theory these are value objects and won't get changed...
123126 */
124 - if( $defaultNamespace == NS_MAIN && isset( $wgTitleCache[$text] ) ) {
125 - return $wgTitleCache[$text];
 127+ if( $defaultNamespace == NS_MAIN && isset( Title::$titleCache[$text] ) ) {
 128+ return Title::$titleCache[$text];
126129 }
127130
128131 /**
@@ -138,11 +141,11 @@
139142 if( $defaultNamespace == NS_MAIN ) {
140143 if( $cachedcount >= MW_TITLECACHE_MAX ) {
141144 # Avoid memory leaks on mass operations...
142 - $wgTitleCache = array();
 145+ Title::$titleCache = array();
143146 $cachedcount=0;
144147 }
145148 $cachedcount++;
146 - $wgTitleCache[$text] =& $t;
 149+ Title::$titleCache[$text] =& $t;
147150 }
148151 return $t;
149152 } else {
@@ -374,15 +377,15 @@
375378 * @access public
376379 */
377380 function getInterwikiLink( $key ) {
378 - global $wgMemc, $wgDBname, $wgInterwikiExpiry, $wgTitleInterwikiCache;
 381+ global $wgMemc, $wgDBname, $wgInterwikiExpiry;
379382 global $wgInterwikiCache;
380383 $fname = 'Title::getInterwikiLink';
381384
382385 $key = strtolower( $key );
383386
384387 $k = $wgDBname.':interwiki:'.$key;
385 - if( array_key_exists( $k, $wgTitleInterwikiCache ) ) {
386 - return $wgTitleInterwikiCache[$k]->iw_url;
 388+ if( array_key_exists( $k, Title::$interwikiCache ) ) {
 389+ return Title::$interwikiCache[$k]->iw_url;
387390 }
388391
389392 if ($wgInterwikiCache) {
@@ -392,7 +395,7 @@
393396 $s = $wgMemc->get( $k );
394397 # Ignore old keys with no iw_local
395398 if( $s && isset( $s->iw_local ) && isset($s->iw_trans)) {
396 - $wgTitleInterwikiCache[$k] = $s;
 399+ Title::$interwikiCache[$k] = $s;
397400 return $s->iw_url;
398401 }
399402
@@ -413,7 +416,7 @@
414417 $s->iw_trans = 0;
415418 }
416419 $wgMemc->set( $k, $s, $wgInterwikiExpiry );
417 - $wgTitleInterwikiCache[$k] = $s;
 420+ Title::$interwikiCache[$k] = $s;
418421
419422 return $s->iw_url;
420423 }
@@ -428,7 +431,6 @@
429432 */
430433 function getInterwikiCached( $key ) {
431434 global $wgDBname, $wgInterwikiCache, $wgInterwikiScopes, $wgInterwikiFallbackSite;
432 - global $wgTitleInterwikiCache;
433435 static $db, $site;
434436
435437 if (!$db)
@@ -459,7 +461,7 @@
460462 $s->iw_url=$url;
461463 $s->iw_local=(int)$local;
462464 }
463 - $wgTitleInterwikiCache[$wgDBname.':interwiki:'.$key] = $s;
 465+ Title::$interwikiCache[$wgDBname.':interwiki:'.$key] = $s;
464466 return $s->iw_url;
465467 }
466468 /**
@@ -471,13 +473,13 @@
472474 * @access public
473475 */
474476 function isLocal() {
475 - global $wgTitleInterwikiCache, $wgDBname;
 477+ global $wgDBname;
476478
477479 if ( $this->mInterwiki != '' ) {
478480 # Make sure key is loaded into cache
479481 $this->getInterwikiLink( $this->mInterwiki );
480482 $k = $wgDBname.':interwiki:' . $this->mInterwiki;
481 - return (bool)($wgTitleInterwikiCache[$k]->iw_local);
 483+ return (bool)(Title::$interwikiCache[$k]->iw_local);
482484 } else {
483485 return true;
484486 }
@@ -491,14 +493,14 @@
492494 * @access public
493495 */
494496 function isTrans() {
495 - global $wgTitleInterwikiCache, $wgDBname;
 497+ global $wgDBname;
496498
497499 if ($this->mInterwiki == '')
498500 return false;
499501 # Make sure key is loaded into cache
500502 $this->getInterwikiLink( $this->mInterwiki );
501503 $k = $wgDBname.':interwiki:' . $this->mInterwiki;
502 - return (bool)($wgTitleInterwikiCache[$k]->iw_trans);
 504+ return (bool)(Title::$interwikiCache[$k]->iw_trans);
503505 }
504506
505507 /**
Index: trunk/phase3/trackback.php
@@ -20,7 +20,6 @@
2121 require_once('./LocalSettings.php');
2222 require_once('includes/Setup.php');
2323
24 -require_once('Title.php');
2524 require_once('DatabaseFunctions.php');
2625
2726 /**

Status & tagging log