Clean up old title on move before reset article id
[lhc/web/wiklou.git] / includes / Wiki.php
1 <?php
2 /**
3 * Helper class for the index.php entry point.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 /**
24 * The MediaWiki class is the helper class for the index.php entry point.
25 *
26 * @internal documentation reviewed 15 Mar 2010
27 */
28 class MediaWiki {
29
30 /**
31 * TODO: fold $output, etc, into this
32 * @var IContextSource
33 */
34 private $context;
35
36 /**
37 * @param $x null|WebRequest
38 * @return WebRequest
39 */
40 public function request( WebRequest $x = null ) {
41 $old = $this->context->getRequest();
42 $this->context->setRequest( $x );
43 return $old;
44 }
45
46 /**
47 * @param $x null|OutputPage
48 * @return OutputPage
49 */
50 public function output( OutputPage $x = null ) {
51 $old = $this->context->getOutput();
52 $this->context->setOutput( $x );
53 return $old;
54 }
55
56 /**
57 * @param IContextSource|null $context
58 */
59 public function __construct( IContextSource $context = null ) {
60 if ( !$context ) {
61 $context = RequestContext::getMain();
62 }
63
64 $this->context = $context;
65 }
66
67 /**
68 * Parse the request to get the Title object
69 *
70 * @return Title object to be $wgTitle
71 */
72 private function parseTitle() {
73 global $wgContLang;
74
75 $request = $this->context->getRequest();
76 $curid = $request->getInt( 'curid' );
77 $title = $request->getVal( 'title' );
78 $action = $request->getVal( 'action', 'view' );
79
80 if ( $request->getCheck( 'search' ) ) {
81 // Compatibility with old search URLs which didn't use Special:Search
82 // Just check for presence here, so blank requests still
83 // show the search page when using ugly URLs (bug 8054).
84 $ret = SpecialPage::getTitleFor( 'Search' );
85 } elseif ( $curid ) {
86 // URLs like this are generated by RC, because rc_title isn't always accurate
87 $ret = Title::newFromID( $curid );
88 } else {
89 $ret = Title::newFromURL( $title );
90 // Alias NS_MEDIA page URLs to NS_FILE...we only use NS_MEDIA
91 // in wikitext links to tell Parser to make a direct file link
92 if ( !is_null( $ret ) && $ret->getNamespace() == NS_MEDIA ) {
93 $ret = Title::makeTitle( NS_FILE, $ret->getDBkey() );
94 }
95 // Check variant links so that interwiki links don't have to worry
96 // about the possible different language variants
97 if ( count( $wgContLang->getVariants() ) > 1
98 && !is_null( $ret ) && $ret->getArticleID() == 0 )
99 {
100 $wgContLang->findVariantLink( $title, $ret );
101 }
102 }
103
104 // If title is not provided, always allow oldid and diff to set the title.
105 // If title is provided, allow oldid and diff to override the title, unless
106 // we are talking about a special page which might use these parameters for
107 // other purposes.
108 if ( $ret === null || !$ret->isSpecialPage() ) {
109 // We can have urls with just ?diff=,?oldid= or even just ?diff=
110 $oldid = $request->getInt( 'oldid' );
111 $oldid = $oldid ? $oldid : $request->getInt( 'diff' );
112 // Allow oldid to override a changed or missing title
113 if ( $oldid ) {
114 $rev = Revision::newFromId( $oldid );
115 $ret = $rev ? $rev->getTitle() : $ret;
116 }
117 }
118
119 // Use the main page as default title if nothing else has been provided
120 if ( $ret === null && strval( $title ) === '' && $action !== 'delete' ) {
121 $ret = Title::newMainPage();
122 }
123
124 if ( $ret === null || ( $ret->getDBkey() == '' && $ret->getInterwiki() == '' ) ) {
125 $ret = SpecialPage::getTitleFor( 'Badtitle' );
126 }
127
128 return $ret;
129 }
130
131 /**
132 * Get the Title object that we'll be acting on, as specified in the WebRequest
133 * @return Title
134 */
135 public function getTitle() {
136 if ( $this->context->getTitle() === null ) {
137 $this->context->setTitle( $this->parseTitle() );
138 }
139 return $this->context->getTitle();
140 }
141
142 /**
143 * Returns the name of the action that will be executed.
144 *
145 * @return string: action
146 */
147 public function getAction() {
148 static $action = null;
149
150 if ( $action === null ) {
151 $action = Action::getActionName( $this->context );
152 }
153
154 return $action;
155 }
156
157 /**
158 * Create an Article object of the appropriate class for the given page.
159 *
160 * @deprecated in 1.18; use Article::newFromTitle() instead
161 * @param $title Title
162 * @param $context IContextSource
163 * @return Article object
164 */
165 public static function articleFromTitle( $title, IContextSource $context ) {
166 wfDeprecated( __METHOD__, '1.18' );
167 return Article::newFromTitle( $title, $context );
168 }
169
170 /**
171 * Performs the request.
172 * - bad titles
173 * - read restriction
174 * - local interwiki redirects
175 * - redirect loop
176 * - special pages
177 * - normal pages
178 *
179 * @throws MWException|PermissionsError|BadTitleError|HttpError
180 * @return void
181 */
182 private function performRequest() {
183 global $wgServer, $wgUsePathInfo, $wgTitle;
184
185 wfProfileIn( __METHOD__ );
186
187 $request = $this->context->getRequest();
188 $requestTitle = $title = $this->context->getTitle();
189 $output = $this->context->getOutput();
190 $user = $this->context->getUser();
191
192 if ( $request->getVal( 'printable' ) === 'yes' ) {
193 $output->setPrintable();
194 }
195
196 $unused = null; // To pass it by reference
197 wfRunHooks( 'BeforeInitialize', array( &$title, &$unused, &$output, &$user, $request, $this ) );
198
199 // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
200 if ( is_null( $title ) || ( $title->getDBkey() == '' && $title->getInterwiki() == '' ) ||
201 $title->isSpecial( 'Badtitle' ) )
202 {
203 $this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) );
204 wfProfileOut( __METHOD__ );
205 throw new BadTitleError();
206 }
207
208 // Check user's permissions to read this page.
209 // We have to check here to catch special pages etc.
210 // We will check again in Article::view().
211 $permErrors = $title->getUserPermissionsErrors( 'read', $user );
212 if ( count( $permErrors ) ) {
213 // Bug 32276: allowing the skin to generate output with $wgTitle or
214 // $this->context->title set to the input title would allow anonymous users to
215 // determine whether a page exists, potentially leaking private data. In fact, the
216 // curid and oldid request parameters would allow page titles to be enumerated even
217 // when they are not guessable. So we reset the title to Special:Badtitle before the
218 // permissions error is displayed.
219 //
220 // The skin mostly uses $this->context->getTitle() these days, but some extensions
221 // still use $wgTitle.
222
223 $badTitle = SpecialPage::getTitleFor( 'Badtitle' );
224 $this->context->setTitle( $badTitle );
225 $wgTitle = $badTitle;
226
227 wfProfileOut( __METHOD__ );
228 throw new PermissionsError( 'read', $permErrors );
229 }
230
231 $pageView = false; // was an article or special page viewed?
232
233 // Interwiki redirects
234 if ( $title->getInterwiki() != '' ) {
235 $rdfrom = $request->getVal( 'rdfrom' );
236 if ( $rdfrom ) {
237 $url = $title->getFullURL( array( 'rdfrom' => $rdfrom ) );
238 } else {
239 $query = $request->getValues();
240 unset( $query['title'] );
241 $url = $title->getFullURL( $query );
242 }
243 // Check for a redirect loop
244 if ( !preg_match( '/^' . preg_quote( $wgServer, '/' ) . '/', $url )
245 && $title->isLocal() )
246 {
247 // 301 so google et al report the target as the actual url.
248 $output->redirect( $url, 301 );
249 } else {
250 $this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) );
251 wfProfileOut( __METHOD__ );
252 throw new BadTitleError();
253 }
254 // Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
255 } elseif ( $request->getVal( 'action', 'view' ) == 'view' && !$request->wasPosted()
256 && ( $request->getVal( 'title' ) === null ||
257 $title->getPrefixedDBkey() != $request->getVal( 'title' ) )
258 && !count( $request->getValueNames( array( 'action', 'title' ) ) )
259 && wfRunHooks( 'TestCanonicalRedirect', array( $request, $title, $output ) ) )
260 {
261 if ( $title->isSpecialPage() ) {
262 list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
263 if ( $name ) {
264 $title = SpecialPage::getTitleFor( $name, $subpage );
265 }
266 }
267 $targetUrl = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
268 // Redirect to canonical url, make it a 301 to allow caching
269 if ( $targetUrl == $request->getFullRequestURL() ) {
270 $message = "Redirect loop detected!\n\n" .
271 "This means the wiki got confused about what page was " .
272 "requested; this sometimes happens when moving a wiki " .
273 "to a new server or changing the server configuration.\n\n";
274
275 if ( $wgUsePathInfo ) {
276 $message .= "The wiki is trying to interpret the page " .
277 "title from the URL path portion (PATH_INFO), which " .
278 "sometimes fails depending on the web server. Try " .
279 "setting \"\$wgUsePathInfo = false;\" in your " .
280 "LocalSettings.php, or check that \$wgArticlePath " .
281 "is correct.";
282 } else {
283 $message .= "Your web server was detected as possibly not " .
284 "supporting URL path components (PATH_INFO) correctly; " .
285 "check your LocalSettings.php for a customized " .
286 "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " .
287 "to true.";
288 }
289 throw new HttpError( 500, $message );
290 } else {
291 $output->setSquidMaxage( 1200 );
292 $output->redirect( $targetUrl, '301' );
293 }
294 // Special pages
295 } elseif ( NS_SPECIAL == $title->getNamespace() ) {
296 $pageView = true;
297 // Actions that need to be made when we have a special pages
298 SpecialPageFactory::executePath( $title, $this->context );
299 } else {
300 // ...otherwise treat it as an article view. The article
301 // may be a redirect to another article or URL.
302 $article = $this->initializeArticle();
303 if ( is_object( $article ) ) {
304 $pageView = true;
305 /**
306 * $wgArticle is deprecated, do not use it.
307 * @deprecated since 1.18
308 */
309 global $wgArticle;
310 $wgArticle = new DeprecatedGlobal( 'wgArticle', $article, '1.18' );
311
312 $this->performAction( $article, $requestTitle );
313 } elseif ( is_string( $article ) ) {
314 $output->redirect( $article );
315 } else {
316 wfProfileOut( __METHOD__ );
317 throw new MWException( "Shouldn't happen: MediaWiki::initializeArticle()"
318 . " returned neither an object nor a URL" );
319 }
320 }
321
322 if ( $pageView ) {
323 // Promote user to any groups they meet the criteria for
324 $user->addAutopromoteOnceGroups( 'onView' );
325 }
326
327 wfProfileOut( __METHOD__ );
328 }
329
330 /**
331 * Initialize the main Article object for "standard" actions (view, etc)
332 * Create an Article object for the page, following redirects if needed.
333 *
334 * @return mixed an Article, or a string to redirect to another URL
335 */
336 private function initializeArticle() {
337 global $wgDisableHardRedirects;
338
339 wfProfileIn( __METHOD__ );
340
341 $title = $this->context->getTitle();
342 if ( $this->context->canUseWikiPage() ) {
343 // Try to use request context wiki page, as there
344 // is already data from db saved in per process
345 // cache there from this->getAction() call.
346 $page = $this->context->getWikiPage();
347 $article = Article::newFromWikiPage( $page, $this->context );
348 } else {
349 // This case should not happen, but just in case.
350 $article = Article::newFromTitle( $title, $this->context );
351 $this->context->setWikiPage( $article->getPage() );
352 }
353
354 // NS_MEDIAWIKI has no redirects.
355 // It is also used for CSS/JS, so performance matters here...
356 if ( $title->getNamespace() == NS_MEDIAWIKI ) {
357 wfProfileOut( __METHOD__ );
358 return $article;
359 }
360
361 $request = $this->context->getRequest();
362
363 // Namespace might change when using redirects
364 // Check for redirects ...
365 $action = $request->getVal( 'action', 'view' );
366 $file = ( $title->getNamespace() == NS_FILE ) ? $article->getFile() : null;
367 if ( ( $action == 'view' || $action == 'render' ) // ... for actions that show content
368 && !$request->getVal( 'oldid' ) && // ... and are not old revisions
369 !$request->getVal( 'diff' ) && // ... and not when showing diff
370 $request->getVal( 'redirect' ) != 'no' && // ... unless explicitly told not to
371 // ... and the article is not a non-redirect image page with associated file
372 !( is_object( $file ) && $file->exists() && !$file->getRedirected() ) )
373 {
374 // Give extensions a change to ignore/handle redirects as needed
375 $ignoreRedirect = $target = false;
376
377 wfRunHooks( 'InitializeArticleMaybeRedirect',
378 array( &$title, &$request, &$ignoreRedirect, &$target, &$article ) );
379
380 // Follow redirects only for... redirects.
381 // If $target is set, then a hook wanted to redirect.
382 if ( !$ignoreRedirect && ( $target || $article->isRedirect() ) ) {
383 // Is the target already set by an extension?
384 $target = $target ? $target : $article->followRedirect();
385 if ( is_string( $target ) ) {
386 if ( !$wgDisableHardRedirects ) {
387 // we'll need to redirect
388 wfProfileOut( __METHOD__ );
389 return $target;
390 }
391 }
392 if ( is_object( $target ) ) {
393 // Rewrite environment to redirected article
394 $rarticle = Article::newFromTitle( $target, $this->context );
395 $rarticle->loadPageData();
396 if ( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) {
397 $rarticle->setRedirectedFrom( $title );
398 $article = $rarticle;
399 $this->context->setTitle( $target );
400 $this->context->setWikiPage( $article->getPage() );
401 }
402 }
403 } else {
404 $this->context->setTitle( $article->getTitle() );
405 $this->context->setWikiPage( $article->getPage() );
406 }
407 }
408
409 wfProfileOut( __METHOD__ );
410 return $article;
411 }
412
413 /**
414 * Perform one of the "standard" actions
415 *
416 * @param $page Page
417 * @param $requestTitle The original title, before any redirects were applied
418 */
419 private function performAction( Page $page, Title $requestTitle ) {
420 global $wgUseSquid, $wgSquidMaxage;
421
422 wfProfileIn( __METHOD__ );
423
424 $request = $this->context->getRequest();
425 $output = $this->context->getOutput();
426 $title = $this->context->getTitle();
427 $user = $this->context->getUser();
428
429 if ( !wfRunHooks( 'MediaWikiPerformAction',
430 array( $output, $page, $title, $user, $request, $this ) ) )
431 {
432 wfProfileOut( __METHOD__ );
433 return;
434 }
435
436 $act = $this->getAction();
437
438 $action = Action::factory( $act, $page, $this->context );
439
440 if ( $action instanceof Action ) {
441 # Let Squid cache things if we can purge them.
442 if ( $wgUseSquid &&
443 in_array( $request->getFullRequestURL(), $requestTitle->getSquidURLs() )
444 ) {
445 $output->setSquidMaxage( $wgSquidMaxage );
446 }
447
448 $action->show();
449 wfProfileOut( __METHOD__ );
450 return;
451 }
452
453 if ( wfRunHooks( 'UnknownAction', array( $request->getVal( 'action', 'view' ), $page ) ) ) {
454 $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
455 }
456
457 wfProfileOut( __METHOD__ );
458 }
459
460 /**
461 * Run the current MediaWiki instance
462 * index.php just calls this
463 */
464 public function run() {
465 try {
466 $this->checkMaxLag();
467 $this->main();
468 $this->restInPeace();
469 } catch ( Exception $e ) {
470 MWExceptionHandler::handle( $e );
471 }
472 }
473
474 /**
475 * Checks if the request should abort due to a lagged server,
476 * for given maxlag parameter.
477 * @return bool
478 */
479 private function checkMaxLag() {
480 global $wgShowHostnames;
481
482 wfProfileIn( __METHOD__ );
483 $maxLag = $this->context->getRequest()->getVal( 'maxlag' );
484 if ( !is_null( $maxLag ) ) {
485 list( $host, $lag ) = wfGetLB()->getMaxLag();
486 if ( $lag > $maxLag ) {
487 $resp = $this->context->getRequest()->response();
488 $resp->header( 'HTTP/1.1 503 Service Unavailable' );
489 $resp->header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
490 $resp->header( 'X-Database-Lag: ' . intval( $lag ) );
491 $resp->header( 'Content-Type: text/plain' );
492 if ( $wgShowHostnames ) {
493 echo "Waiting for $host: $lag seconds lagged\n";
494 } else {
495 echo "Waiting for a database server: $lag seconds lagged\n";
496 }
497
498 wfProfileOut( __METHOD__ );
499
500 exit;
501 }
502 }
503 wfProfileOut( __METHOD__ );
504 return true;
505 }
506
507 private function main() {
508 global $wgUseFileCache, $wgTitle, $wgUseAjax;
509
510 wfProfileIn( __METHOD__ );
511
512 $request = $this->context->getRequest();
513
514 // Send Ajax requests to the Ajax dispatcher.
515 if ( $wgUseAjax && $request->getVal( 'action', 'view' ) == 'ajax' ) {
516
517 // Set a dummy title, because $wgTitle == null might break things
518 $title = Title::makeTitle( NS_MAIN, 'AJAX' );
519 $this->context->setTitle( $title );
520 $wgTitle = $title;
521
522 $dispatcher = new AjaxDispatcher();
523 $dispatcher->performAction();
524 wfProfileOut( __METHOD__ );
525 return;
526 }
527
528 // Get title from request parameters,
529 // is set on the fly by parseTitle the first time.
530 $title = $this->getTitle();
531 $action = $this->getAction();
532 $wgTitle = $title;
533
534 // If the user has forceHTTPS set to true, or if the user
535 // is in a group requiring HTTPS, or if they have the HTTPS
536 // preference set, redirect them to HTTPS.
537 // Note: Do this after $wgTitle is setup, otherwise the hooks run from
538 // isLoggedIn() will do all sorts of weird stuff.
539 if (
540 (
541 $request->getCookie( 'forceHTTPS', '' ) ||
542 // check for prefixed version for currently logged in users
543 $request->getCookie( 'forceHTTPS' ) ||
544 // Avoid checking the user and groups unless it's enabled.
545 (
546 $this->context->getUser()->isLoggedIn()
547 && $this->context->getUser()->requiresHTTPS()
548 )
549 ) &&
550 $request->detectProtocol() == 'http'
551 ) {
552 $oldUrl = $request->getFullRequestURL();
553 $redirUrl = str_replace( 'http://', 'https://', $oldUrl );
554
555 if ( $request->wasPosted() ) {
556 // This is weird and we'd hope it almost never happens. This
557 // means that a POST came in via HTTP and policy requires us
558 // redirecting to HTTPS. It's likely such a request is going
559 // to fail due to post data being lost, but let's try anyway
560 // and just log the instance.
561 //
562 // @todo @fixme See if we could issue a 307 or 308 here, need
563 // to see how clients (automated & browser) behave when we do
564 wfDebugLog( 'RedirectedPosts', "Redirected from HTTP to HTTPS: $oldUrl" );
565 }
566
567 // Setup dummy Title, otherwise OutputPage::redirect will fail
568 $title = Title::newFromText( NS_MAIN, 'REDIR' );
569 $this->context->setTitle( $title );
570 $output = $this->context->getOutput();
571 // Since we only do this redir to change proto, always send a vary header
572 $output->addVaryHeader( 'X-Forwarded-Proto' );
573 $output->redirect( $redirUrl );
574 $output->output();
575 wfProfileOut( __METHOD__ );
576 return;
577 }
578
579 if ( $wgUseFileCache && $title->getNamespace() >= 0 ) {
580 wfProfileIn( 'main-try-filecache' );
581 if ( HTMLFileCache::useFileCache( $this->context ) ) {
582 // Try low-level file cache hit
583 $cache = HTMLFileCache::newFromTitle( $title, $action );
584 if ( $cache->isCacheGood( /* Assume up to date */ ) ) {
585 // Check incoming headers to see if client has this cached
586 $timestamp = $cache->cacheTimestamp();
587 if ( !$this->context->getOutput()->checkLastModified( $timestamp ) ) {
588 $cache->loadFromFileCache( $this->context );
589 }
590 // Do any stats increment/watchlist stuff
591 $this->context->getWikiPage()->doViewUpdates( $this->context->getUser() );
592 // Tell OutputPage that output is taken care of
593 $this->context->getOutput()->disable();
594 wfProfileOut( 'main-try-filecache' );
595 wfProfileOut( __METHOD__ );
596 return;
597 }
598 }
599 wfProfileOut( 'main-try-filecache' );
600 }
601
602 $this->performRequest();
603
604 // Now commit any transactions, so that unreported errors after
605 // output() don't roll back the whole DB transaction
606 wfGetLBFactory()->commitMasterChanges();
607
608 // Output everything!
609 $this->context->getOutput()->output();
610
611 wfProfileOut( __METHOD__ );
612 }
613
614 /**
615 * Ends this task peacefully
616 */
617 public function restInPeace() {
618 // Do any deferred jobs
619 DeferredUpdates::doUpdates( 'commit' );
620
621 // Execute a job from the queue
622 $this->doJobs();
623
624 // Log profiling data, e.g. in the database or UDP
625 wfLogProfilingData();
626
627 // Commit and close up!
628 $factory = wfGetLBFactory();
629 $factory->commitMasterChanges();
630 $factory->shutdown();
631
632 wfDebug( "Request ended normally\n" );
633 }
634
635 /**
636 * Do a job from the job queue
637 */
638 private function doJobs() {
639 global $wgJobRunRate, $wgPhpCli, $IP;
640
641 if ( $wgJobRunRate <= 0 || wfReadOnly() ) {
642 return;
643 }
644
645 if ( $wgJobRunRate < 1 ) {
646 $max = mt_getrandmax();
647 if ( mt_rand( 0, $max ) > $max * $wgJobRunRate ) {
648 return; // the higher $wgJobRunRate, the less likely we return here
649 }
650 $n = 1;
651 } else {
652 $n = intval( $wgJobRunRate );
653 }
654
655 if ( !wfShellExecDisabled() && is_executable( $wgPhpCli ) ) {
656 // Start a background process to run some of the jobs.
657 // This will be asynchronous on *nix though not on Windows.
658 wfProfileIn( __METHOD__ . '-exec' );
659 $retVal = 1;
660 $cmd = wfShellWikiCmd( "$IP/maintenance/runJobs.php", array( '--maxjobs', $n ) );
661 wfShellExec( "$cmd &", $retVal );
662 wfProfileOut( __METHOD__ . '-exec' );
663 } else {
664 try {
665 // Fallback to running the jobs here while the user waits
666 $group = JobQueueGroup::singleton();
667 do {
668 $job = $group->pop( JobQueueGroup::USE_CACHE ); // job from any queue
669 if ( $job ) {
670 $output = $job->toString() . "\n";
671 $t = - microtime( true );
672 wfProfileIn( __METHOD__ . '-' . get_class( $job ) );
673 $success = $job->run();
674 wfProfileOut( __METHOD__ . '-' . get_class( $job ) );
675 $group->ack( $job ); // done
676 $t += microtime( true );
677 $t = round( $t * 1000 );
678 if ( $success === false ) {
679 $output .= "Error: " . $job->getLastError() . ", Time: $t ms\n";
680 } else {
681 $output .= "Success, Time: $t ms\n";
682 }
683 wfDebugLog( 'jobqueue', $output );
684 }
685 } while ( --$n && $job );
686 } catch ( MWException $e ) {
687 // We don't want exceptions thrown during job execution to
688 // be reported to the user since the output is already sent.
689 // Instead we just log them.
690 wfDebugLog( 'exception', $e->getLogMessage() );
691 }
692 }
693 }
694 }