Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -5,16 +5,23 @@ |
6 | 6 | * @internal documentation reviewed 15 Mar 2010 |
7 | 7 | */ |
8 | 8 | class MediaWiki { |
9 | | - var $params = array(); |
10 | 9 | |
11 | 10 | /** |
| 11 | + * Array of options which may or may not be used |
| 12 | + * FIXME: this seems currently to be a messy halfway-house between globals |
| 13 | + * and a config object. Pick one and run with it |
| 14 | + * @var array |
| 15 | + */ |
| 16 | + private $params = array(); |
| 17 | + |
| 18 | + /** |
12 | 19 | * Stores key/value pairs to circumvent global variables |
13 | 20 | * Note that keys are case-insensitive! |
14 | 21 | * |
15 | 22 | * @param $key String: key to store |
16 | 23 | * @param $value Mixed: value to put for the key |
17 | 24 | */ |
18 | | - function setVal( $key, &$value ) { |
| 25 | + public function setVal( $key, &$value ) { |
19 | 26 | $key = strtolower( $key ); |
20 | 27 | $this->params[$key] =& $value; |
21 | 28 | } |
— | — | @@ -27,9 +34,9 @@ |
28 | 35 | * @param $default string default value, defaults to empty string |
29 | 36 | * @return $default Mixed: default value if if the key doesn't exist |
30 | 37 | */ |
31 | | - function getVal( $key, $default = '' ) { |
| 38 | + public function getVal( $key, $default = '' ) { |
32 | 39 | $key = strtolower( $key ); |
33 | | - if( isset( $this->params[$key] ) ) { |
| 40 | + if ( isset( $this->params[$key] ) ) { |
34 | 41 | return $this->params[$key]; |
35 | 42 | } |
36 | 43 | return $default; |
— | — | @@ -45,29 +52,36 @@ |
46 | 53 | * @param $user User |
47 | 54 | * @param $request WebRequest |
48 | 55 | */ |
49 | | - function performRequestForTitle( &$title, &$article, &$output, &$user, $request ) { |
| 56 | + public function performRequestForTitle( &$title, &$article, &$output, &$user, $request ) { |
50 | 57 | wfProfileIn( __METHOD__ ); |
51 | 58 | |
52 | 59 | $output->setTitle( $title ); |
53 | | - if( $request->getVal( 'printable' ) === 'yes' ) { |
| 60 | + if ( $request->getVal( 'printable' ) === 'yes' ) { |
54 | 61 | $output->setPrintable(); |
55 | 62 | } |
56 | 63 | |
57 | 64 | wfRunHooks( 'BeforeInitialize', array( &$title, &$article, &$output, &$user, $request, $this ) ); |
58 | 65 | |
59 | | - if( !$this->preliminaryChecks( $title, $output ) ) { |
| 66 | + // If the user is not logged in, the Namespace:title of the article must be in |
| 67 | + // the Read array in order for the user to see it. (We have to check here to |
| 68 | + // catch special pages etc. We check again in Article::view()) |
| 69 | + if ( !is_null( $title ) && !$title->userCanRead() ) { |
| 70 | + $output->loginToUse(); |
| 71 | + $this->finalCleanup( $output ); |
| 72 | + $output->disable(); |
60 | 73 | wfProfileOut( __METHOD__ ); |
61 | | - return; |
| 74 | + return false; |
62 | 75 | } |
| 76 | + |
63 | 77 | // Call handleSpecialCases() to deal with all special requests... |
64 | | - if( !$this->handleSpecialCases( $title, $output, $request ) ) { |
| 78 | + if ( !$this->handleSpecialCases( $title, $output, $request ) ) { |
65 | 79 | // ...otherwise treat it as an article view. The article |
66 | 80 | // may be a redirect to another article or URL. |
67 | 81 | $new_article = $this->initializeArticle( $title, $output, $request ); |
68 | | - if( is_object( $new_article ) ) { |
| 82 | + if ( is_object( $new_article ) ) { |
69 | 83 | $article = $new_article; |
70 | 84 | $this->performAction( $output, $article, $title, $user, $request ); |
71 | | - } elseif( is_string( $new_article ) ) { |
| 85 | + } elseif ( is_string( $new_article ) ) { |
72 | 86 | $output->redirect( $new_article ); |
73 | 87 | } else { |
74 | 88 | wfProfileOut( __METHOD__ ); |
— | — | @@ -78,59 +92,42 @@ |
79 | 93 | } |
80 | 94 | |
81 | 95 | /** |
82 | | - * Check if the maximum lag of database slaves is higher that $maxLag, and |
83 | | - * if it's the case, output an error message |
84 | | - * |
85 | | - * @param $maxLag int: maximum lag allowed for the request, as supplied by |
86 | | - * the client |
87 | | - * @return bool true if the request can continue |
88 | | - */ |
89 | | - function checkMaxLag( $maxLag ) { |
90 | | - list( $host, $lag ) = wfGetLB()->getMaxLag(); |
91 | | - if( $lag > $maxLag ) { |
92 | | - wfMaxlagError( $host, $lag, $maxLag ); |
93 | | - return false; |
94 | | - } else { |
95 | | - return true; |
96 | | - } |
97 | | - } |
98 | | - |
99 | | - /** |
100 | 96 | * Checks some initial queries |
| 97 | + * FIXME: rename to parseTitle() ? |
101 | 98 | * |
102 | 99 | * @param $request WebRequest |
103 | 100 | * @return Title object to be $wgTitle |
104 | 101 | */ |
105 | | - function checkInitialQueries( WebRequest $request ) { |
| 102 | + /* private */ function checkInitialQueries( WebRequest $request ) { |
106 | 103 | global $wgContLang; |
107 | 104 | |
108 | 105 | $curid = $request->getInt( 'curid' ); |
109 | 106 | $title = $request->getVal( 'title' ); |
110 | 107 | |
111 | | - if( $request->getCheck( 'search' ) ) { |
| 108 | + if ( $request->getCheck( 'search' ) ) { |
112 | 109 | // Compatibility with old search URLs which didn't use Special:Search |
113 | 110 | // Just check for presence here, so blank requests still |
114 | 111 | // show the search page when using ugly URLs (bug 8054). |
115 | 112 | $ret = SpecialPage::getTitleFor( 'Search' ); |
116 | | - } elseif( $curid ) { |
| 113 | + } elseif ( $curid ) { |
117 | 114 | // URLs like this are generated by RC, because rc_title isn't always accurate |
118 | 115 | $ret = Title::newFromID( $curid ); |
119 | | - } elseif( $title == '' && $this->getAction( $request ) != 'delete' ) { |
| 116 | + } elseif ( $title == '' && $this->getAction( $request ) != 'delete' ) { |
120 | 117 | $ret = Title::newMainPage(); |
121 | 118 | } else { |
122 | 119 | $ret = Title::newFromURL( $title ); |
123 | 120 | // check variant links so that interwiki links don't have to worry |
124 | 121 | // about the possible different language variants |
125 | | - if( count( $wgContLang->getVariants() ) > 1 && !is_null( $ret ) && $ret->getArticleID() == 0 ) |
| 122 | + if ( count( $wgContLang->getVariants() ) > 1 && !is_null( $ret ) && $ret->getArticleID() == 0 ) |
126 | 123 | $wgContLang->findVariantLink( $title, $ret ); |
127 | 124 | } |
128 | 125 | // For non-special titles, check for implicit titles |
129 | | - if( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) { |
| 126 | + if ( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) { |
130 | 127 | // We can have urls with just ?diff=,?oldid= or even just ?diff= |
131 | 128 | $oldid = $request->getInt( 'oldid' ); |
132 | 129 | $oldid = $oldid ? $oldid : $request->getInt( 'diff' ); |
133 | 130 | // Allow oldid to override a changed or missing title |
134 | | - if( $oldid ) { |
| 131 | + if ( $oldid ) { |
135 | 132 | $rev = Revision::newFromId( $oldid ); |
136 | 133 | $ret = $rev ? $rev->getTitle() : $ret; |
137 | 134 | } |
— | — | @@ -139,26 +136,6 @@ |
140 | 137 | } |
141 | 138 | |
142 | 139 | /** |
143 | | - * Checks for anon-cannot-read case |
144 | | - * |
145 | | - * @param $title Title |
146 | | - * @param $output OutputPage |
147 | | - * @return boolean true if successful |
148 | | - */ |
149 | | - function preliminaryChecks( &$title, &$output ) { |
150 | | - // If the user is not logged in, the Namespace:title of the article must be in |
151 | | - // the Read array in order for the user to see it. (We have to check here to |
152 | | - // catch special pages etc. We check again in Article::view()) |
153 | | - if( !is_null( $title ) && !$title->userCanRead() ) { |
154 | | - $output->loginToUse(); |
155 | | - $this->finalCleanup( $output ); |
156 | | - $output->disable(); |
157 | | - return false; |
158 | | - } |
159 | | - return true; |
160 | | - } |
161 | | - |
162 | | - /** |
163 | 140 | * Initialize some special cases: |
164 | 141 | * - bad titles |
165 | 142 | * - local interwiki redirects |
— | — | @@ -170,20 +147,20 @@ |
171 | 148 | * @param $request WebRequest |
172 | 149 | * @return bool true if the request is already executed |
173 | 150 | */ |
174 | | - function handleSpecialCases( &$title, &$output, $request ) { |
| 151 | + private function handleSpecialCases( &$title, &$output, $request ) { |
175 | 152 | wfProfileIn( __METHOD__ ); |
176 | 153 | |
177 | 154 | // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty. |
178 | | - if( is_null($title) || ( ( $title->getDBkey() == '' ) && ( $title->getInterwiki() == '' ) ) ) { |
| 155 | + if ( is_null( $title ) || ( ( $title->getDBkey() == '' ) && ( $title->getInterwiki() == '' ) ) ) { |
179 | 156 | $title = SpecialPage::getTitleFor( 'Badtitle' ); |
180 | 157 | $output->setTitle( $title ); // bug 21456 |
181 | 158 | // Die now before we mess up $wgArticle and the skin stops working |
182 | 159 | throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
183 | 160 | |
184 | 161 | // Interwiki redirects |
185 | | - } else if( $title->getInterwiki() != '' ) { |
| 162 | + } else if ( $title->getInterwiki() != '' ) { |
186 | 163 | $rdfrom = $request->getVal( 'rdfrom' ); |
187 | | - if( $rdfrom ) { |
| 164 | + if ( $rdfrom ) { |
188 | 165 | $url = $title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) ); |
189 | 166 | } else { |
190 | 167 | $query = $request->getValues(); |
— | — | @@ -191,7 +168,7 @@ |
192 | 169 | $url = $title->getFullURL( $query ); |
193 | 170 | } |
194 | 171 | /* Check for a redirect loop */ |
195 | | - if( !preg_match( '/^' . preg_quote( $this->getVal('Server'), '/' ) . '/', $url ) && $title->isLocal() ) { |
| 172 | + if ( !preg_match( '/^' . preg_quote( $this->getVal( 'Server' ), '/' ) . '/', $url ) && $title->isLocal() ) { |
196 | 173 | // 301 so google et al report the target as the actual url. |
197 | 174 | $output->redirect( $url, 301 ); |
198 | 175 | } else { |
— | — | @@ -213,13 +190,13 @@ |
214 | 191 | } |
215 | 192 | $targetUrl = $title->getFullURL(); |
216 | 193 | // Redirect to canonical url, make it a 301 to allow caching |
217 | | - if( $targetUrl == $request->getFullRequestURL() ) { |
| 194 | + if ( $targetUrl == $request->getFullRequestURL() ) { |
218 | 195 | $message = "Redirect loop detected!\n\n" . |
219 | 196 | "This means the wiki got confused about what page was " . |
220 | 197 | "requested; this sometimes happens when moving a wiki " . |
221 | 198 | "to a new server or changing the server configuration.\n\n"; |
222 | 199 | |
223 | | - if( $this->getVal( 'UsePathInfo' ) ) { |
| 200 | + if ( $this->getVal( 'UsePathInfo' ) ) { |
224 | 201 | $message .= "The wiki is trying to interpret the page " . |
225 | 202 | "title from the URL path portion (PATH_INFO), which " . |
226 | 203 | "sometimes fails depending on the web server. Try " . |
— | — | @@ -241,7 +218,7 @@ |
242 | 219 | $output->redirect( $targetUrl, '301' ); |
243 | 220 | } |
244 | 221 | // Special pages |
245 | | - } else if( NS_SPECIAL == $title->getNamespace() ) { |
| 222 | + } else if ( NS_SPECIAL == $title->getNamespace() ) { |
246 | 223 | /* actions that need to be made when we have a special pages */ |
247 | 224 | SpecialPage::executePath( $title ); |
248 | 225 | } else { |
— | — | @@ -260,15 +237,15 @@ |
261 | 238 | * @param $title Title |
262 | 239 | * @return Article object |
263 | 240 | */ |
264 | | - static function articleFromTitle( &$title ) { |
265 | | - if( NS_MEDIA == $title->getNamespace() ) { |
| 241 | + public static function articleFromTitle( &$title ) { |
| 242 | + if ( NS_MEDIA == $title->getNamespace() ) { |
266 | 243 | // FIXME: where should this go? |
267 | 244 | $title = Title::makeTitle( NS_FILE, $title->getDBkey() ); |
268 | 245 | } |
269 | 246 | |
270 | 247 | $article = null; |
271 | 248 | wfRunHooks( 'ArticleFromTitle', array( &$title, &$article ) ); |
272 | | - if( $article ) { |
| 249 | + if ( $article ) { |
273 | 250 | return $article; |
274 | 251 | } |
275 | 252 | |
— | — | @@ -296,7 +273,7 @@ |
297 | 274 | $action = $request->getVal( 'action', 'view' ); |
298 | 275 | |
299 | 276 | // Check for disabled actions |
300 | | - if( in_array( $action, $wgDisabledActions ) ) { |
| 277 | + if ( in_array( $action, $wgDisabledActions ) ) { |
301 | 278 | return 'nosuchaction'; |
302 | 279 | } |
303 | 280 | |
— | — | @@ -326,21 +303,21 @@ |
327 | 304 | * @param $request WebRequest ($wgRequest) |
328 | 305 | * @return mixed an Article, or a string to redirect to another URL |
329 | 306 | */ |
330 | | - function initializeArticle( &$title, &$output, $request ) { |
| 307 | + private function initializeArticle( &$title, &$output, $request ) { |
331 | 308 | wfProfileIn( __METHOD__ ); |
332 | 309 | |
333 | 310 | $action = $request->getVal( 'action', 'view' ); |
334 | 311 | $article = self::articleFromTitle( $title ); |
335 | 312 | // NS_MEDIAWIKI has no redirects. |
336 | 313 | // It is also used for CSS/JS, so performance matters here... |
337 | | - if( $title->getNamespace() == NS_MEDIAWIKI ) { |
| 314 | + if ( $title->getNamespace() == NS_MEDIAWIKI ) { |
338 | 315 | wfProfileOut( __METHOD__ ); |
339 | 316 | return $article; |
340 | 317 | } |
341 | 318 | // Namespace might change when using redirects |
342 | 319 | // Check for redirects ... |
343 | | - $file = ($title->getNamespace() == NS_FILE) ? $article->getFile() : null; |
344 | | - if( ( $action == 'view' || $action == 'render' ) // ... for actions that show content |
| 320 | + $file = ( $title->getNamespace() == NS_FILE ) ? $article->getFile() : null; |
| 321 | + if ( ( $action == 'view' || $action == 'render' ) // ... for actions that show content |
345 | 322 | && !$request->getVal( 'oldid' ) && // ... and are not old revisions |
346 | 323 | !$request->getVal( 'diff' ) && // ... and not when showing diff |
347 | 324 | $request->getVal( 'redirect' ) != 'no' && // ... unless explicitly told not to |
— | — | @@ -351,25 +328,25 @@ |
352 | 329 | $ignoreRedirect = $target = false; |
353 | 330 | |
354 | 331 | wfRunHooks( 'InitializeArticleMaybeRedirect', |
355 | | - array(&$title,&$request,&$ignoreRedirect,&$target,&$article) ); |
| 332 | + array( &$title, &$request, &$ignoreRedirect, &$target, &$article ) ); |
356 | 333 | |
357 | 334 | // Follow redirects only for... redirects. |
358 | 335 | // If $target is set, then a hook wanted to redirect. |
359 | | - if( !$ignoreRedirect && ($target || $article->isRedirect()) ) { |
| 336 | + if ( !$ignoreRedirect && ( $target || $article->isRedirect() ) ) { |
360 | 337 | // Is the target already set by an extension? |
361 | 338 | $target = $target ? $target : $article->followRedirect(); |
362 | | - if( is_string( $target ) ) { |
363 | | - if( !$this->getVal( 'DisableHardRedirects' ) ) { |
| 339 | + if ( is_string( $target ) ) { |
| 340 | + if ( !$this->getVal( 'DisableHardRedirects' ) ) { |
364 | 341 | // we'll need to redirect |
365 | 342 | wfProfileOut( __METHOD__ ); |
366 | 343 | return $target; |
367 | 344 | } |
368 | 345 | } |
369 | | - if( is_object($target) ) { |
| 346 | + if ( is_object( $target ) ) { |
370 | 347 | // Rewrite environment to redirected article |
371 | 348 | $rarticle = self::articleFromTitle( $target ); |
372 | 349 | $rarticle->loadPageData(); |
373 | | - if( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) { |
| 350 | + if ( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) { |
374 | 351 | $rarticle->setRedirectedFrom( $title ); |
375 | 352 | $article = $rarticle; |
376 | 353 | $title = $target; |
— | — | @@ -385,12 +362,11 @@ |
386 | 363 | } |
387 | 364 | |
388 | 365 | /** |
389 | | - * Cleaning up request by doing: |
390 | | - ** deferred updates, DB transaction, and the output |
| 366 | + * Cleaning up request by doing deferred updates, DB transaction, and the output |
391 | 367 | * |
392 | 368 | * @param $output OutputPage |
393 | 369 | */ |
394 | | - function finalCleanup( &$output ) { |
| 370 | + public function finalCleanup( &$output ) { |
395 | 371 | wfProfileIn( __METHOD__ ); |
396 | 372 | // Now commit any transactions, so that unreported errors after |
397 | 373 | // output() don't roll back the whole DB transaction |
— | — | @@ -409,15 +385,15 @@ |
410 | 386 | /** |
411 | 387 | * Do a job from the job queue |
412 | 388 | */ |
413 | | - function doJobs() { |
| 389 | + private function doJobs() { |
414 | 390 | global $wgJobRunRate; |
415 | 391 | |
416 | | - if( $wgJobRunRate <= 0 || wfReadOnly() ) { |
| 392 | + if ( $wgJobRunRate <= 0 || wfReadOnly() ) { |
417 | 393 | return; |
418 | 394 | } |
419 | | - if( $wgJobRunRate < 1 ) { |
| 395 | + if ( $wgJobRunRate < 1 ) { |
420 | 396 | $max = mt_getrandmax(); |
421 | | - if( mt_rand( 0, $max ) > $max * $wgJobRunRate ) { |
| 397 | + if ( mt_rand( 0, $max ) > $max * $wgJobRunRate ) { |
422 | 398 | return; |
423 | 399 | } |
424 | 400 | $n = 1; |
— | — | @@ -430,8 +406,8 @@ |
431 | 407 | $t = -wfTime(); |
432 | 408 | $success = $job->run(); |
433 | 409 | $t += wfTime(); |
434 | | - $t = round( $t*1000 ); |
435 | | - if( !$success ) { |
| 410 | + $t = round( $t * 1000 ); |
| 411 | + if ( !$success ) { |
436 | 412 | $output .= "Error: " . $job->getLastError() . ", Time: $t ms\n"; |
437 | 413 | } else { |
438 | 414 | $output .= "Success, Time: $t ms\n"; |
— | — | @@ -443,7 +419,7 @@ |
444 | 420 | /** |
445 | 421 | * Ends this task peacefully |
446 | 422 | */ |
447 | | - function restInPeace() { |
| 423 | + public function restInPeace() { |
448 | 424 | MessageCache::logMessages(); |
449 | 425 | wfLogProfilingData(); |
450 | 426 | // Commit and close up! |
— | — | @@ -462,10 +438,10 @@ |
463 | 439 | * @param $user User |
464 | 440 | * @param $request WebRequest |
465 | 441 | */ |
466 | | - function performAction( &$output, &$article, &$title, &$user, &$request ) { |
| 442 | + private function performAction( &$output, &$article, &$title, &$user, &$request ) { |
467 | 443 | wfProfileIn( __METHOD__ ); |
468 | 444 | |
469 | | - if( !wfRunHooks( 'MediaWikiPerformAction', array( $output, $article, $title, $user, $request, $this ) ) ) { |
| 445 | + if ( !wfRunHooks( 'MediaWikiPerformAction', array( $output, $article, $title, $user, $request, $this ) ) ) { |
470 | 446 | wfProfileOut( __METHOD__ ); |
471 | 447 | return; |
472 | 448 | } |
— | — | @@ -478,10 +454,10 @@ |
479 | 455 | $article->view(); |
480 | 456 | break; |
481 | 457 | case 'raw': // includes JS/CSS |
482 | | - wfProfileIn( __METHOD__.'-raw' ); |
| 458 | + wfProfileIn( __METHOD__ . '-raw' ); |
483 | 459 | $raw = new RawPage( $article ); |
484 | 460 | $raw->view(); |
485 | | - wfProfileOut( __METHOD__.'-raw' ); |
| 461 | + wfProfileOut( __METHOD__ . '-raw' ); |
486 | 462 | break; |
487 | 463 | case 'watch': |
488 | 464 | case 'unwatch': |
— | — | @@ -501,7 +477,7 @@ |
502 | 478 | $article->view(); |
503 | 479 | break; |
504 | 480 | case 'dublincore': |
505 | | - if( !$this->getVal( 'EnableDublinCoreRdf' ) ) { |
| 481 | + if ( !$this->getVal( 'EnableDublinCoreRdf' ) ) { |
506 | 482 | wfHttpError( 403, 'Forbidden', wfMsg( 'nodublincore' ) ); |
507 | 483 | } else { |
508 | 484 | $rdf = new DublinCoreRdf( $article ); |
— | — | @@ -509,7 +485,7 @@ |
510 | 486 | } |
511 | 487 | break; |
512 | 488 | case 'creativecommons': |
513 | | - if( !$this->getVal( 'EnableCreativeCommonsRdf' ) ) { |
| 489 | + if ( !$this->getVal( 'EnableCreativeCommonsRdf' ) ) { |
514 | 490 | wfHttpError( 403, 'Forbidden', wfMsg( 'nocreativecommons' ) ); |
515 | 491 | } else { |
516 | 492 | $rdf = new CreativeCommonsRdf( $article ); |
— | — | @@ -520,22 +496,22 @@ |
521 | 497 | Credits::showPage( $article ); |
522 | 498 | break; |
523 | 499 | case 'submit': |
524 | | - if( session_id() == '' ) { |
| 500 | + if ( session_id() == '' ) { |
525 | 501 | /* Send a cookie so anons get talk message notifications */ |
526 | 502 | wfSetupSession(); |
527 | 503 | } |
528 | 504 | /* Continue... */ |
529 | 505 | case 'edit': |
530 | | - if( wfRunHooks( 'CustomEditor', array( $article, $user ) ) ) { |
| 506 | + if ( wfRunHooks( 'CustomEditor', array( $article, $user ) ) ) { |
531 | 507 | $internal = $request->getVal( 'internaledit' ); |
532 | 508 | $external = $request->getVal( 'externaledit' ); |
533 | 509 | $section = $request->getVal( 'section' ); |
534 | 510 | $oldid = $request->getVal( 'oldid' ); |
535 | | - if( !$this->getVal( 'UseExternalEditor' ) || $action=='submit' || $internal || |
| 511 | + if ( !$this->getVal( 'UseExternalEditor' ) || $action == 'submit' || $internal || |
536 | 512 | $section || $oldid || ( !$user->getOption( 'externaleditor' ) && !$external ) ) { |
537 | 513 | $editor = new EditPage( $article ); |
538 | 514 | $editor->submit(); |
539 | | - } elseif( $this->getVal( 'UseExternalEditor' ) && ( $external || $user->getOption( 'externaleditor' ) ) ) { |
| 515 | + } elseif ( $this->getVal( 'UseExternalEditor' ) && ( $external || $user->getOption( 'externaleditor' ) ) ) { |
540 | 516 | $mode = $request->getVal( 'mode' ); |
541 | 517 | $extedit = new ExternalEdit( $article, $mode ); |
542 | 518 | $extedit->edit(); |
— | — | @@ -543,7 +519,7 @@ |
544 | 520 | } |
545 | 521 | break; |
546 | 522 | case 'history': |
547 | | - if( $request->getFullRequestURL() == $title->getInternalURL( 'action=history' ) ) { |
| 523 | + if ( $request->getFullRequestURL() == $title->getInternalURL( 'action=history' ) ) { |
548 | 524 | $output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) ); |
549 | 525 | } |
550 | 526 | $history = new HistoryPage( $article ); |
— | — | @@ -560,12 +536,10 @@ |
561 | 537 | $special->execute( '' ); |
562 | 538 | break; |
563 | 539 | default: |
564 | | - if( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) { |
| 540 | + if ( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) { |
565 | 541 | $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); |
566 | 542 | } |
567 | 543 | } |
568 | 544 | wfProfileOut( __METHOD__ ); |
569 | | - |
570 | 545 | } |
571 | | - |
572 | 546 | } |
Index: trunk/phase3/index.php |
— | — | @@ -47,8 +47,12 @@ |
48 | 48 | $mediaWiki = new MediaWiki(); |
49 | 49 | |
50 | 50 | $maxLag = $wgRequest->getVal( 'maxlag' ); |
51 | | -if( !is_null( $maxLag ) && !$mediaWiki->checkMaxLag( $maxLag ) ) { |
52 | | - exit; |
| 51 | +if ( !is_null( $maxLag ) ) { |
| 52 | + list( $host, $lag ) = wfGetLB()->getMaxLag(); |
| 53 | + if ( $lag > $maxLag ) { |
| 54 | + wfMaxlagError( $host, $lag, $maxLag ); |
| 55 | + exit; |
| 56 | + } |
53 | 57 | } |
54 | 58 | |
55 | 59 | # Set title from request parameters |
— | — | @@ -58,7 +62,7 @@ |
59 | 63 | wfProfileOut( 'index.php-setup' ); |
60 | 64 | |
61 | 65 | # Send Ajax requests to the Ajax dispatcher. |
62 | | -if( $wgUseAjax && $action == 'ajax' ) { |
| 66 | +if ( $wgUseAjax && $action == 'ajax' ) { |
63 | 67 | $dispatcher = new AjaxDispatcher(); |
64 | 68 | $dispatcher->performAction(); |
65 | 69 | wfProfileOut( 'index.php' ); |
— | — | @@ -66,16 +70,16 @@ |
67 | 71 | exit; |
68 | 72 | } |
69 | 73 | |
70 | | -if( $wgUseFileCache && $wgTitle !== null ) { |
| 74 | +if ( $wgUseFileCache && $wgTitle !== null ) { |
71 | 75 | wfProfileIn( 'index.php-filecache' ); |
72 | 76 | // Raw pages should handle cache control on their own, |
73 | 77 | // even when using file cache. This reduces hits from clients. |
74 | | - if( $action != 'raw' && HTMLFileCache::useFileCache() ) { |
| 78 | + if ( $action != 'raw' && HTMLFileCache::useFileCache() ) { |
75 | 79 | /* Try low-level file cache hit */ |
76 | 80 | $cache = new HTMLFileCache( $wgTitle, $action ); |
77 | | - if( $cache->isFileCacheGood( /* Assume up to date */ ) ) { |
| 81 | + if ( $cache->isFileCacheGood( /* Assume up to date */ ) ) { |
78 | 82 | /* Check incoming headers to see if client has this cached */ |
79 | | - if( !$wgOut->checkLastModified( $cache->fileCacheTime() ) ) { |
| 83 | + if ( !$wgOut->checkLastModified( $cache->fileCacheTime() ) ) { |
80 | 84 | $cache->loadFromFileCache(); |
81 | 85 | } |
82 | 86 | # Do any stats increment/watchlist stuff |