Index: trunk/phase3/includes/CacheManager.php |
— | — | @@ -6,11 +6,6 @@ |
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** |
10 | | - * We need the title class |
11 | | - */ |
12 | | -require_once( 'Title.php' ); |
13 | | - |
14 | | -/** |
15 | 10 | * Handles talking to the file cache, putting stuff in and taking it back out. |
16 | 11 | * Mostly called from Article.php, also from DatabaseFunctions.php for the |
17 | 12 | * emergency abort/fallback to cache. |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -58,7 +58,6 @@ |
59 | 59 | require_once( 'User.php' ); |
60 | 60 | require_once( 'Skin.php' ); |
61 | 61 | require_once( 'OutputPage.php' ); |
62 | | -require_once( 'Title.php' ); |
63 | 62 | require_once( 'MagicWord.php' ); |
64 | 63 | require_once( 'Block.php' ); |
65 | 64 | require_once( 'MessageCache.php' ); |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -8,9 +8,6 @@ |
9 | 9 | /** */ |
10 | 10 | require_once( 'normal/UtfNormal.php' ); |
11 | 11 | |
12 | | -$wgTitleInterwikiCache = array(); |
13 | | -$wgTitleCache = array(); |
14 | | - |
15 | 12 | define ( 'GAID_FOR_UPDATE', 1 ); |
16 | 13 | |
17 | 14 | # Title::newFromTitle maintains a cache to avoid |
— | — | @@ -29,6 +26,13 @@ |
30 | 27 | */ |
31 | 28 | class Title { |
32 | 29 | /** |
| 30 | + * Static cache variables |
| 31 | + */ |
| 32 | + static private $titleCache=array(); |
| 33 | + static private $interwikiCache=array(); |
| 34 | + |
| 35 | + |
| 36 | + /** |
33 | 37 | * All member variables should be considered private |
34 | 38 | * Please use the accessor functions |
35 | 39 | */ |
— | — | @@ -105,7 +109,6 @@ |
106 | 110 | * @access public |
107 | 111 | */ |
108 | 112 | function newFromText( $text, $defaultNamespace = NS_MAIN ) { |
109 | | - global $wgTitleCache; |
110 | 113 | $fname = 'Title::newFromText'; |
111 | 114 | |
112 | 115 | if( is_object( $text ) ) { |
— | — | @@ -120,8 +123,8 @@ |
121 | 124 | * |
122 | 125 | * In theory these are value objects and won't get changed... |
123 | 126 | */ |
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]; |
126 | 129 | } |
127 | 130 | |
128 | 131 | /** |
— | — | @@ -138,11 +141,11 @@ |
139 | 142 | if( $defaultNamespace == NS_MAIN ) { |
140 | 143 | if( $cachedcount >= MW_TITLECACHE_MAX ) { |
141 | 144 | # Avoid memory leaks on mass operations... |
142 | | - $wgTitleCache = array(); |
| 145 | + Title::$titleCache = array(); |
143 | 146 | $cachedcount=0; |
144 | 147 | } |
145 | 148 | $cachedcount++; |
146 | | - $wgTitleCache[$text] =& $t; |
| 149 | + Title::$titleCache[$text] =& $t; |
147 | 150 | } |
148 | 151 | return $t; |
149 | 152 | } else { |
— | — | @@ -374,15 +377,15 @@ |
375 | 378 | * @access public |
376 | 379 | */ |
377 | 380 | function getInterwikiLink( $key ) { |
378 | | - global $wgMemc, $wgDBname, $wgInterwikiExpiry, $wgTitleInterwikiCache; |
| 381 | + global $wgMemc, $wgDBname, $wgInterwikiExpiry; |
379 | 382 | global $wgInterwikiCache; |
380 | 383 | $fname = 'Title::getInterwikiLink'; |
381 | 384 | |
382 | 385 | $key = strtolower( $key ); |
383 | 386 | |
384 | 387 | $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; |
387 | 390 | } |
388 | 391 | |
389 | 392 | if ($wgInterwikiCache) { |
— | — | @@ -392,7 +395,7 @@ |
393 | 396 | $s = $wgMemc->get( $k ); |
394 | 397 | # Ignore old keys with no iw_local |
395 | 398 | if( $s && isset( $s->iw_local ) && isset($s->iw_trans)) { |
396 | | - $wgTitleInterwikiCache[$k] = $s; |
| 399 | + Title::$interwikiCache[$k] = $s; |
397 | 400 | return $s->iw_url; |
398 | 401 | } |
399 | 402 | |
— | — | @@ -413,7 +416,7 @@ |
414 | 417 | $s->iw_trans = 0; |
415 | 418 | } |
416 | 419 | $wgMemc->set( $k, $s, $wgInterwikiExpiry ); |
417 | | - $wgTitleInterwikiCache[$k] = $s; |
| 420 | + Title::$interwikiCache[$k] = $s; |
418 | 421 | |
419 | 422 | return $s->iw_url; |
420 | 423 | } |
— | — | @@ -428,7 +431,6 @@ |
429 | 432 | */ |
430 | 433 | function getInterwikiCached( $key ) { |
431 | 434 | global $wgDBname, $wgInterwikiCache, $wgInterwikiScopes, $wgInterwikiFallbackSite; |
432 | | - global $wgTitleInterwikiCache; |
433 | 435 | static $db, $site; |
434 | 436 | |
435 | 437 | if (!$db) |
— | — | @@ -459,7 +461,7 @@ |
460 | 462 | $s->iw_url=$url; |
461 | 463 | $s->iw_local=(int)$local; |
462 | 464 | } |
463 | | - $wgTitleInterwikiCache[$wgDBname.':interwiki:'.$key] = $s; |
| 465 | + Title::$interwikiCache[$wgDBname.':interwiki:'.$key] = $s; |
464 | 466 | return $s->iw_url; |
465 | 467 | } |
466 | 468 | /** |
— | — | @@ -471,13 +473,13 @@ |
472 | 474 | * @access public |
473 | 475 | */ |
474 | 476 | function isLocal() { |
475 | | - global $wgTitleInterwikiCache, $wgDBname; |
| 477 | + global $wgDBname; |
476 | 478 | |
477 | 479 | if ( $this->mInterwiki != '' ) { |
478 | 480 | # Make sure key is loaded into cache |
479 | 481 | $this->getInterwikiLink( $this->mInterwiki ); |
480 | 482 | $k = $wgDBname.':interwiki:' . $this->mInterwiki; |
481 | | - return (bool)($wgTitleInterwikiCache[$k]->iw_local); |
| 483 | + return (bool)(Title::$interwikiCache[$k]->iw_local); |
482 | 484 | } else { |
483 | 485 | return true; |
484 | 486 | } |
— | — | @@ -491,14 +493,14 @@ |
492 | 494 | * @access public |
493 | 495 | */ |
494 | 496 | function isTrans() { |
495 | | - global $wgTitleInterwikiCache, $wgDBname; |
| 497 | + global $wgDBname; |
496 | 498 | |
497 | 499 | if ($this->mInterwiki == '') |
498 | 500 | return false; |
499 | 501 | # Make sure key is loaded into cache |
500 | 502 | $this->getInterwikiLink( $this->mInterwiki ); |
501 | 503 | $k = $wgDBname.':interwiki:' . $this->mInterwiki; |
502 | | - return (bool)($wgTitleInterwikiCache[$k]->iw_trans); |
| 504 | + return (bool)(Title::$interwikiCache[$k]->iw_trans); |
503 | 505 | } |
504 | 506 | |
505 | 507 | /** |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -457,6 +457,7 @@ |
458 | 458 | * Regression fix: suppress warning about session failure when clicking to |
459 | 459 | edit with 'preview on first edit' enabled. |
460 | 460 | * (bug 6230) Regression fix: <nowiki> in [URL link text] |
| 461 | +* Added AutoLoader.php, which loads classes without need of require_once() |
461 | 462 | |
462 | 463 | |
463 | 464 | == Compatibility == |
Index: trunk/phase3/trackback.php |
— | — | @@ -20,7 +20,6 @@ |
21 | 21 | require_once('./LocalSettings.php'); |
22 | 22 | require_once('includes/Setup.php'); |
23 | 23 | |
24 | | -require_once('Title.php'); |
25 | 24 | require_once('DatabaseFunctions.php'); |
26 | 25 | |
27 | 26 | /** |