Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -2859,14 +2859,34 @@ |
2860 | 2860 | |
2861 | 2861 | /** |
2862 | 2862 | * Do any deferred updates and clear the list |
2863 | | - * TODO: This could be in Wiki.php if that class made any sense at all |
| 2863 | + * |
| 2864 | + * @param $commit Boolean: commit after every update to prevent lock contention |
2864 | 2865 | */ |
2865 | | -function wfDoUpdates() { |
| 2866 | +function wfDoUpdates( $commit = false ) { |
2866 | 2867 | global $wgDeferredUpdateList; |
| 2868 | + |
| 2869 | + wfProfileIn( __METHOD__ ); |
| 2870 | + |
| 2871 | + // No need to get master connections in case of empty updates array |
| 2872 | + if ( !count( $wgDeferredUpdateList ) ) { |
| 2873 | + wfProfileOut( __METHOD__ ); |
| 2874 | + return; |
| 2875 | + } |
| 2876 | + |
| 2877 | + if ( $commit ) { |
| 2878 | + $dbw = wfGetDB( DB_MASTER ); |
| 2879 | + } |
| 2880 | + |
2867 | 2881 | foreach ( $wgDeferredUpdateList as $update ) { |
2868 | 2882 | $update->doUpdate(); |
| 2883 | + |
| 2884 | + if ( $commit && $dbw->trxLevel() ) { |
| 2885 | + $dbw->commit(); |
| 2886 | + } |
2869 | 2887 | } |
| 2888 | + |
2870 | 2889 | $wgDeferredUpdateList = array(); |
| 2890 | + wfProfileOut( __METHOD__ ); |
2871 | 2891 | } |
2872 | 2892 | |
2873 | 2893 | /** |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -153,9 +153,8 @@ |
154 | 154 | // the Read array in order for the user to see it. (We have to check here to |
155 | 155 | // catch special pages etc. We check again in Article::view()) |
156 | 156 | if( !is_null( $title ) && !$title->userCanRead() ) { |
157 | | - global $wgDeferredUpdateList; |
158 | 157 | $output->loginToUse(); |
159 | | - $this->finalCleanup( $wgDeferredUpdateList, $output ); |
| 158 | + $this->finalCleanup( $output ); |
160 | 159 | $output->disable(); |
161 | 160 | return false; |
162 | 161 | } |
— | — | @@ -361,10 +360,9 @@ |
362 | 361 | * Cleaning up request by doing: |
363 | 362 | ** deferred updates, DB transaction, and the output |
364 | 363 | * |
365 | | - * @param $deferredUpdates array of updates to do |
366 | 364 | * @param $output OutputPage |
367 | 365 | */ |
368 | | - function finalCleanup( &$deferredUpdates, &$output ) { |
| 366 | + function finalCleanup( &$output ) { |
369 | 367 | wfProfileIn( __METHOD__ ); |
370 | 368 | // Now commit any transactions, so that unreported errors after |
371 | 369 | // output() don't roll back the whole DB transaction |
— | — | @@ -373,7 +371,7 @@ |
374 | 372 | // Output everything! |
375 | 373 | $output->output(); |
376 | 374 | // Do any deferred jobs |
377 | | - $this->doUpdates( $deferredUpdates ); |
| 375 | + wfDoUpdates( true ); |
378 | 376 | // Close the session so that jobs don't access the current session |
379 | 377 | session_write_close(); |
380 | 378 | $this->doJobs(); |
— | — | @@ -381,34 +379,6 @@ |
382 | 380 | } |
383 | 381 | |
384 | 382 | /** |
385 | | - * Deferred updates aren't really deferred anymore. It's important to report |
386 | | - * errors to the user, and that means doing this before OutputPage::output(). |
387 | | - * Note that for page saves, the client will wait until the script exits |
388 | | - * anyway before following the redirect. |
389 | | - * |
390 | | - * @param $updates array of objects that hold an update to do |
391 | | - */ |
392 | | - function doUpdates( &$updates ) { |
393 | | - wfProfileIn( __METHOD__ ); |
394 | | - /* No need to get master connections in case of empty updates array */ |
395 | | - if (!$updates) { |
396 | | - wfProfileOut( __METHOD__ ); |
397 | | - return; |
398 | | - } |
399 | | - |
400 | | - $dbw = wfGetDB( DB_MASTER ); |
401 | | - foreach( $updates as $up ) { |
402 | | - $up->doUpdate(); |
403 | | - |
404 | | - // Commit after every update to prevent lock contention |
405 | | - if( $dbw->trxLevel() ) { |
406 | | - $dbw->commit(); |
407 | | - } |
408 | | - } |
409 | | - wfProfileOut( __METHOD__ ); |
410 | | - } |
411 | | - |
412 | | - /** |
413 | 383 | * Do a job from the job queue |
414 | 384 | */ |
415 | 385 | function doJobs() { |
Index: trunk/phase3/index.php |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | $mediaWiki->setVal( 'UsePathInfo', $wgUsePathInfo ); |
113 | 113 | |
114 | 114 | $mediaWiki->performRequestForTitle( $wgTitle, $wgArticle, $wgOut, $wgUser, $wgRequest ); |
115 | | -$mediaWiki->finalCleanup( $wgDeferredUpdateList, $wgOut ); |
| 115 | +$mediaWiki->finalCleanup( $wgOut ); |
116 | 116 | |
117 | 117 | $mediaWiki->restInPeace(); |
118 | 118 | |