Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -150,7 +150,6 @@ |
151 | 151 | |
152 | 152 | // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty. |
153 | 153 | if ( $this->context->title instanceof BadTitle ) { |
154 | | - // Die now before we mess up $wgArticle and the skin stops working |
155 | 154 | throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
156 | 155 | |
157 | 156 | // Interwiki redirects |
— | — | @@ -292,7 +291,7 @@ |
293 | 292 | } |
294 | 293 | |
295 | 294 | /** |
296 | | - * Initialize the object to be known as $wgArticle for "standard" actions |
| 295 | + * Initialize the main Article object for "standard" actions (view, etc) |
297 | 296 | * Create an Article object for the page, following redirects if needed. |
298 | 297 | * |
299 | 298 | * @return mixed an Article, or a string to redirect to another URL |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -443,11 +443,10 @@ |
444 | 444 | |
445 | 445 | # Placeholders in case of DB error |
446 | 446 | $wgTitle = null; |
447 | | -$wgArticle = null; |
448 | 447 | |
449 | 448 | $wgDeferredUpdateList = array(); |
450 | 449 | |
451 | | -// We need to check for safe_mode, because mail() willl throws an E_NOTICE |
| 450 | +// We need to check for safe_mode, because mail() will throw an E_NOTICE |
452 | 451 | // on additional parameters |
453 | 452 | if( !is_null($wgAdditionalMailParams) && wfIniGetBool('safe_mode') ) { |
454 | 453 | $wgAdditionalMailParams = null; |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | * Globals used: |
36 | 36 | * objects: $wgLang, $wgContLang |
37 | 37 | * |
38 | | - * NOT $wgArticle, $wgUser or $wgTitle. Keep them away! |
| 38 | + * NOT $wgUser or $wgTitle. Keep them away! |
39 | 39 | * |
40 | 40 | * settings: |
41 | 41 | * $wgUseDynamicDates*, $wgInterwikiMagic*, |
Index: trunk/phase3/includes/Exception.php |
— | — | @@ -22,7 +22,8 @@ |
23 | 23 | function useOutputPage() { |
24 | 24 | return $this->useMessageCache() && |
25 | 25 | !empty( $GLOBALS['wgFullyInitialised'] ) && |
26 | | - ( !empty( $GLOBALS['wgArticle'] ) || ( !empty( $GLOBALS['wgOut'] ) && !$GLOBALS['wgOut']->isArticleRelated() ) ) && |
| 26 | + !empty( $GLOBALS['wgOut'] ) && |
| 27 | + !$GLOBALS['wgOut']->isArticleRelated() && |
27 | 28 | !empty( $GLOBALS['wgTitle'] ); |
28 | 29 | } |
29 | 30 | |
Index: trunk/phase3/index.php |
— | — | @@ -63,83 +63,98 @@ |
64 | 64 | |
65 | 65 | # Initialise common code. This gives us access to GlobalFunctions, the AutoLoader, and |
66 | 66 | # the globals $wgRequest, $wgOut, $wgUser, $wgLang and $wgContLang, amongst others; it |
67 | | -# does *not* load $wgTitle or $wgArticle |
| 67 | +# does *not* load $wgTitle |
68 | 68 | require ( dirname( __FILE__ ) . '/includes/WebStart.php' ); |
69 | 69 | |
70 | | -wfProfileIn( 'index.php' ); |
71 | | -wfProfileIn( 'index.php-setup' ); |
| 70 | +wfIndexMain(); |
72 | 71 | |
73 | | -$maxLag = $wgRequest->getVal( 'maxlag' ); |
74 | | -if ( !is_null( $maxLag ) ) { |
75 | | - $lb = wfGetLB(); // foo()->bar() is not supported in PHP4 |
76 | | - list( $host, $lag ) = $lb->getMaxLag(); |
77 | | - if ( $lag > $maxLag ) { |
78 | | - header( 'HTTP/1.1 503 Service Unavailable' ); |
79 | | - header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) ); |
80 | | - header( 'X-Database-Lag: ' . intval( $lag ) ); |
81 | | - header( 'Content-Type: text/plain' ); |
82 | | - if( $wgShowHostnames ) { |
83 | | - echo "Waiting for $host: $lag seconds lagged\n"; |
84 | | - } else { |
85 | | - echo "Waiting for a database server: $lag seconds lagged\n"; |
| 72 | +function wfIndexMain() { |
| 73 | + global $wgRequest, $wgShowHostnames, $mediaWiki, $wgTitle, $wgUseAjax, $wgUseFileCache; |
| 74 | + |
| 75 | + wfProfileIn( 'index.php' ); |
| 76 | + wfProfileIn( 'index.php-setup' ); |
| 77 | + |
| 78 | + $maxLag = $wgRequest->getVal( 'maxlag' ); |
| 79 | + if ( !is_null( $maxLag ) ) { |
| 80 | + $lb = wfGetLB(); // foo()->bar() is not supported in PHP4 |
| 81 | + list( $host, $lag ) = $lb->getMaxLag(); |
| 82 | + if ( $lag > $maxLag ) { |
| 83 | + header( 'HTTP/1.1 503 Service Unavailable' ); |
| 84 | + header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) ); |
| 85 | + header( 'X-Database-Lag: ' . intval( $lag ) ); |
| 86 | + header( 'Content-Type: text/plain' ); |
| 87 | + if( $wgShowHostnames ) { |
| 88 | + echo "Waiting for $host: $lag seconds lagged\n"; |
| 89 | + } else { |
| 90 | + echo "Waiting for a database server: $lag seconds lagged\n"; |
| 91 | + } |
| 92 | + exit; |
86 | 93 | } |
87 | | - exit; |
88 | 94 | } |
89 | | -} |
90 | 95 | |
91 | | -# Initialize MediaWiki base class |
92 | | -$context = RequestContext::getMain(); |
93 | | -$mediaWiki = new MediaWiki( $context ); |
| 96 | + # Initialize MediaWiki base class |
| 97 | + $context = RequestContext::getMain(); |
| 98 | + $mediaWiki = new MediaWiki( $context ); |
94 | 99 | |
95 | | -# Set title from request parameters |
96 | | -$wgTitle = $mediaWiki->getTitle(); |
97 | | -$action = $wgRequest->getVal( 'action', 'view' ); |
| 100 | + # Set title from request parameters |
| 101 | + $wgTitle = $mediaWiki->getTitle(); |
| 102 | + $action = $wgRequest->getVal( 'action', 'view' ); |
98 | 103 | |
99 | | -wfProfileOut( 'index.php-setup' ); |
| 104 | + wfProfileOut( 'index.php-setup' ); |
100 | 105 | |
101 | | -# Send Ajax requests to the Ajax dispatcher. |
102 | | -if ( $wgUseAjax && $action == 'ajax' ) { |
103 | | - $dispatcher = new AjaxDispatcher(); |
104 | | - $dispatcher->performAction(); |
105 | | - wfProfileOut( 'index.php' ); |
106 | | - $mediaWiki->restInPeace(); |
107 | | - exit; |
108 | | -} |
| 106 | + # Send Ajax requests to the Ajax dispatcher. |
| 107 | + if ( $wgUseAjax && $action == 'ajax' ) { |
| 108 | + $dispatcher = new AjaxDispatcher(); |
| 109 | + $dispatcher->performAction(); |
| 110 | + wfProfileOut( 'index.php' ); |
| 111 | + $mediaWiki->restInPeace(); |
| 112 | + exit; |
| 113 | + } |
109 | 114 | |
110 | | -if ( $wgUseFileCache && $wgTitle !== null ) { |
111 | | - wfProfileIn( 'index.php-filecache' ); |
112 | | - // Raw pages should handle cache control on their own, |
113 | | - // even when using file cache. This reduces hits from clients. |
114 | | - if ( $action != 'raw' && HTMLFileCache::useFileCache() ) { |
115 | | - /* Try low-level file cache hit */ |
116 | | - $cache = new HTMLFileCache( $wgTitle, $action ); |
117 | | - if ( $cache->isFileCacheGood( /* Assume up to date */ ) ) { |
118 | | - /* Check incoming headers to see if client has this cached */ |
119 | | - if ( !$context->output->checkLastModified( $cache->fileCacheTime() ) ) { |
120 | | - $cache->loadFromFileCache(); |
| 115 | + if ( $wgUseFileCache && $wgTitle !== null ) { |
| 116 | + wfProfileIn( 'index.php-filecache' ); |
| 117 | + // Raw pages should handle cache control on their own, |
| 118 | + // even when using file cache. This reduces hits from clients. |
| 119 | + if ( $action != 'raw' && HTMLFileCache::useFileCache() ) { |
| 120 | + /* Try low-level file cache hit */ |
| 121 | + $cache = new HTMLFileCache( $wgTitle, $action ); |
| 122 | + if ( $cache->isFileCacheGood( /* Assume up to date */ ) ) { |
| 123 | + /* Check incoming headers to see if client has this cached */ |
| 124 | + if ( !$context->output->checkLastModified( $cache->fileCacheTime() ) ) { |
| 125 | + $cache->loadFromFileCache(); |
| 126 | + } |
| 127 | + # Do any stats increment/watchlist stuff |
| 128 | + $article = MediaWiki::articleFromTitle( $wgTitle, $context ); |
| 129 | + $article->viewUpdates(); |
| 130 | + # Tell OutputPage that output is taken care of |
| 131 | + $context->output->disable(); |
| 132 | + wfProfileOut( 'index.php-filecache' ); |
| 133 | + $mediaWiki->finalCleanup(); |
| 134 | + wfProfileOut( 'index.php' ); |
| 135 | + $mediaWiki->restInPeace(); |
| 136 | + exit; |
121 | 137 | } |
122 | | - # Do any stats increment/watchlist stuff |
123 | | - $wgArticle = MediaWiki::articleFromTitle( $wgTitle, $context ); |
124 | | - $wgArticle->viewUpdates(); |
125 | | - # Tell OutputPage that output is taken care of |
126 | | - $context->output->disable(); |
127 | | - wfProfileOut( 'index.php-filecache' ); |
128 | | - $mediaWiki->finalCleanup(); |
129 | | - wfProfileOut( 'index.php' ); |
130 | | - $mediaWiki->restInPeace(); |
131 | | - exit; |
132 | 138 | } |
| 139 | + wfProfileOut( 'index.php-filecache' ); |
133 | 140 | } |
134 | | - wfProfileOut( 'index.php-filecache' ); |
135 | | -} |
136 | 141 | |
137 | | -$mediaWiki->performRequestForTitle( $wgArticle ); |
138 | | -$mediaWiki->finalCleanup(); |
| 142 | + $mediaWiki->performRequestForTitle( $article ); |
139 | 143 | |
140 | | -wfProfileOut( 'index.php' ); |
| 144 | + /** |
| 145 | + * $wgArticle is deprecated, do not use it. This will possibly be removed |
| 146 | + * entirely in 1.20 or 1.21 |
| 147 | + * @deprecated since 1.19 |
| 148 | + */ |
| 149 | + global $wgArticle; |
| 150 | + $wgArticle = $article; |
141 | 151 | |
142 | | -$mediaWiki->restInPeace(); |
| 152 | + $mediaWiki->finalCleanup(); |
143 | 153 | |
| 154 | + wfProfileOut( 'index.php' ); |
| 155 | + |
| 156 | + $mediaWiki->restInPeace(); |
| 157 | +} |
| 158 | + |
144 | 159 | /** |
145 | 160 | * Display something vaguely comprehensible in the event of a totally unrecoverable error. |
146 | 161 | * Does not assume access to *anything*; no globals, no autloader, no database, no localisation. |
Index: trunk/phase3/maintenance/rebuildFileCache.php |
— | — | @@ -31,6 +31,9 @@ |
32 | 32 | $this->setBatchSize( 100 ); |
33 | 33 | } |
34 | 34 | |
| 35 | + /** |
| 36 | + * @todo MAKE $wgArticle GO AWAY! This is the absolute LAST use in core |
| 37 | + */ |
35 | 38 | public function execute() { |
36 | 39 | global $wgUseFileCache, $wgDisableCounters, $wgContentNamespaces, $wgRequestTime; |
37 | 40 | global $wgTitle, $wgArticle, $wgOut; |
Index: trunk/phase3/docs/globals.txt |
— | — | @@ -45,9 +45,6 @@ |
46 | 46 | $wgTitle |
47 | 47 | Title object created from the request URL. |
48 | 48 | |
49 | | -$wgArticle |
50 | | - Article object corresponding to $wgTitle. |
51 | | - |
52 | 49 | $wgOut |
53 | 50 | OutputPage object for HTTP response. |
54 | 51 | |