r14640 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r14639‎ | r14640 | r14641 >
Date:13:58, 7 June 2006
Author:midom
Status:old
Tags:
Comment:
revert r14636, private static arrays seem to crash APC on half of our boxen, will have to investigate (or ask nicely Tim to help there)
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,6 +6,11 @@
77 */
88
99 /**
 10+ * We need the title class
 11+ */
 12+require_once( 'Title.php' );
 13+
 14+/**
1015 * Handles talking to the file cache, putting stuff in and taking it back out.
1116 * Mostly called from Article.php, also from DatabaseFunctions.php for the
1217 * emergency abort/fallback to cache.
Index: trunk/phase3/includes/Setup.php
@@ -57,6 +57,7 @@
5858 require_once( 'User.php' );
5959 require_once( 'Skin.php' );
6060 require_once( 'OutputPage.php' );
 61+require_once( 'Title.php' );
6162 require_once( 'MagicWord.php' );
6263 require_once( 'Block.php' );
6364 require_once( 'MessageCache.php' );
Index: trunk/phase3/includes/Title.php
@@ -8,6 +8,9 @@
99 /** */
1010 require_once( 'normal/UtfNormal.php' );
1111
 12+$wgTitleInterwikiCache = array();
 13+$wgTitleCache = array();
 14+
1215 define ( 'GAID_FOR_UPDATE', 1 );
1316
1417 # Title::newFromTitle maintains a cache to avoid
@@ -26,13 +29,6 @@
2730 */
2831 class Title {
2932 /**
30 - * Static cache variables
31 - */
32 - static private $titleCache=array();
33 - static private $interwikiCache=array();
34 -
35 -
36 - /**
3733 * All member variables should be considered private
3834 * Please use the accessor functions
3935 */
@@ -109,6 +105,7 @@
110106 * @access public
111107 */
112108 function newFromText( $text, $defaultNamespace = NS_MAIN ) {
 109+ global $wgTitleCache;
113110 $fname = 'Title::newFromText';
114111
115112 if( is_object( $text ) ) {
@@ -123,8 +120,8 @@
124121 *
125122 * In theory these are value objects and won't get changed...
126123 */
127 - if( $defaultNamespace == NS_MAIN && isset( Title::$titleCache[$text] ) ) {
128 - return Title::$titleCache[$text];
 124+ if( $defaultNamespace == NS_MAIN && isset( $wgTitleCache[$text] ) ) {
 125+ return $wgTitleCache[$text];
129126 }
130127
131128 /**
@@ -141,11 +138,11 @@
142139 if( $defaultNamespace == NS_MAIN ) {
143140 if( $cachedcount >= MW_TITLECACHE_MAX ) {
144141 # Avoid memory leaks on mass operations...
145 - Title::$titleCache = array();
 142+ $wgTitleCache = array();
146143 $cachedcount=0;
147144 }
148145 $cachedcount++;
149 - Title::$titleCache[$text] =& $t;
 146+ $wgTitleCache[$text] =& $t;
150147 }
151148 return $t;
152149 } else {
@@ -377,15 +374,15 @@
378375 * @access public
379376 */
380377 function getInterwikiLink( $key ) {
381 - global $wgMemc, $wgDBname, $wgInterwikiExpiry;
 378+ global $wgMemc, $wgDBname, $wgInterwikiExpiry, $wgTitleInterwikiCache;
382379 global $wgInterwikiCache;
383380 $fname = 'Title::getInterwikiLink';
384381
385382 $key = strtolower( $key );
386383
387384 $k = $wgDBname.':interwiki:'.$key;
388 - if( array_key_exists( $k, Title::$interwikiCache ) ) {
389 - return Title::$interwikiCache[$k]->iw_url;
 385+ if( array_key_exists( $k, $wgTitleInterwikiCache ) ) {
 386+ return $wgTitleInterwikiCache[$k]->iw_url;
390387 }
391388
392389 if ($wgInterwikiCache) {
@@ -395,7 +392,7 @@
396393 $s = $wgMemc->get( $k );
397394 # Ignore old keys with no iw_local
398395 if( $s && isset( $s->iw_local ) && isset($s->iw_trans)) {
399 - Title::$interwikiCache[$k] = $s;
 396+ $wgTitleInterwikiCache[$k] = $s;
400397 return $s->iw_url;
401398 }
402399
@@ -416,7 +413,7 @@
417414 $s->iw_trans = 0;
418415 }
419416 $wgMemc->set( $k, $s, $wgInterwikiExpiry );
420 - Title::$interwikiCache[$k] = $s;
 417+ $wgTitleInterwikiCache[$k] = $s;
421418
422419 return $s->iw_url;
423420 }
@@ -431,6 +428,7 @@
432429 */
433430 function getInterwikiCached( $key ) {
434431 global $wgDBname, $wgInterwikiCache, $wgInterwikiScopes, $wgInterwikiFallbackSite;
 432+ global $wgTitleInterwikiCache;
435433 static $db, $site;
436434
437435 if (!$db)
@@ -461,7 +459,7 @@
462460 $s->iw_url=$url;
463461 $s->iw_local=(int)$local;
464462 }
465 - Title::$interwikiCache[$wgDBname.':interwiki:'.$key] = $s;
 463+ $wgTitleInterwikiCache[$wgDBname.':interwiki:'.$key] = $s;
466464 return $s->iw_url;
467465 }
468466 /**
@@ -473,13 +471,13 @@
474472 * @access public
475473 */
476474 function isLocal() {
477 - global $wgDBname;
 475+ global $wgTitleInterwikiCache, $wgDBname;
478476
479477 if ( $this->mInterwiki != '' ) {
480478 # Make sure key is loaded into cache
481479 $this->getInterwikiLink( $this->mInterwiki );
482480 $k = $wgDBname.':interwiki:' . $this->mInterwiki;
483 - return (bool)(Title::$interwikiCache[$k]->iw_local);
 481+ return (bool)($wgTitleInterwikiCache[$k]->iw_local);
484482 } else {
485483 return true;
486484 }
@@ -493,14 +491,14 @@
494492 * @access public
495493 */
496494 function isTrans() {
497 - global $wgDBname;
 495+ global $wgTitleInterwikiCache, $wgDBname;
498496
499497 if ($this->mInterwiki == '')
500498 return false;
501499 # Make sure key is loaded into cache
502500 $this->getInterwikiLink( $this->mInterwiki );
503501 $k = $wgDBname.':interwiki:' . $this->mInterwiki;
504 - return (bool)(Title::$interwikiCache[$k]->iw_trans);
 502+ return (bool)($wgTitleInterwikiCache[$k]->iw_trans);
505503 }
506504
507505 /**
Index: trunk/phase3/trackback.php
@@ -20,6 +20,7 @@
2121 require_once('./LocalSettings.php');
2222 require_once('includes/Setup.php');
2323
 24+require_once('Title.php');
2425 require_once('DatabaseFunctions.php');
2526
2627 /**

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r14636AutoLoad Title.php, move global cache arrays to static Title:: variablesmidom11:44, 7 June 2006

Status & tagging log