Merged wfDoUpdates() and MediaWiki::doUpdates() in wfDoUpdates(); avoids code duplication
This commit is contained in:
parent
d274f4f57f
commit
30caa2a8b9
3 changed files with 26 additions and 36 deletions
|
|
@ -2859,14 +2859,34 @@ function wfMakeUrlIndex( $url ) {
|
|||
|
||||
/**
|
||||
* Do any deferred updates and clear the list
|
||||
* TODO: This could be in Wiki.php if that class made any sense at all
|
||||
*
|
||||
* @param $commit Boolean: commit after every update to prevent lock contention
|
||||
*/
|
||||
function wfDoUpdates() {
|
||||
function wfDoUpdates( $commit = false ) {
|
||||
global $wgDeferredUpdateList;
|
||||
|
||||
wfProfileIn( __METHOD__ );
|
||||
|
||||
// No need to get master connections in case of empty updates array
|
||||
if ( !count( $wgDeferredUpdateList ) ) {
|
||||
wfProfileOut( __METHOD__ );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $commit ) {
|
||||
$dbw = wfGetDB( DB_MASTER );
|
||||
}
|
||||
|
||||
foreach ( $wgDeferredUpdateList as $update ) {
|
||||
$update->doUpdate();
|
||||
|
||||
if ( $commit && $dbw->trxLevel() ) {
|
||||
$dbw->commit();
|
||||
}
|
||||
}
|
||||
|
||||
$wgDeferredUpdateList = array();
|
||||
wfProfileOut( __METHOD__ );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -153,9 +153,8 @@ class MediaWiki {
|
|||
// the Read array in order for the user to see it. (We have to check here to
|
||||
// catch special pages etc. We check again in Article::view())
|
||||
if( !is_null( $title ) && !$title->userCanRead() ) {
|
||||
global $wgDeferredUpdateList;
|
||||
$output->loginToUse();
|
||||
$this->finalCleanup( $wgDeferredUpdateList, $output );
|
||||
$this->finalCleanup( $output );
|
||||
$output->disable();
|
||||
return false;
|
||||
}
|
||||
|
|
@ -361,10 +360,9 @@ class MediaWiki {
|
|||
* Cleaning up request by doing:
|
||||
** deferred updates, DB transaction, and the output
|
||||
*
|
||||
* @param $deferredUpdates array of updates to do
|
||||
* @param $output OutputPage
|
||||
*/
|
||||
function finalCleanup( &$deferredUpdates, &$output ) {
|
||||
function finalCleanup( &$output ) {
|
||||
wfProfileIn( __METHOD__ );
|
||||
// Now commit any transactions, so that unreported errors after
|
||||
// output() don't roll back the whole DB transaction
|
||||
|
|
@ -373,41 +371,13 @@ class MediaWiki {
|
|||
// Output everything!
|
||||
$output->output();
|
||||
// Do any deferred jobs
|
||||
$this->doUpdates( $deferredUpdates );
|
||||
wfDoUpdates( true );
|
||||
// Close the session so that jobs don't access the current session
|
||||
session_write_close();
|
||||
$this->doJobs();
|
||||
wfProfileOut( __METHOD__ );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deferred updates aren't really deferred anymore. It's important to report
|
||||
* errors to the user, and that means doing this before OutputPage::output().
|
||||
* Note that for page saves, the client will wait until the script exits
|
||||
* anyway before following the redirect.
|
||||
*
|
||||
* @param $updates array of objects that hold an update to do
|
||||
*/
|
||||
function doUpdates( &$updates ) {
|
||||
wfProfileIn( __METHOD__ );
|
||||
/* No need to get master connections in case of empty updates array */
|
||||
if (!$updates) {
|
||||
wfProfileOut( __METHOD__ );
|
||||
return;
|
||||
}
|
||||
|
||||
$dbw = wfGetDB( DB_MASTER );
|
||||
foreach( $updates as $up ) {
|
||||
$up->doUpdate();
|
||||
|
||||
// Commit after every update to prevent lock contention
|
||||
if( $dbw->trxLevel() ) {
|
||||
$dbw->commit();
|
||||
}
|
||||
}
|
||||
wfProfileOut( __METHOD__ );
|
||||
}
|
||||
|
||||
/**
|
||||
* Do a job from the job queue
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ $mediaWiki->setVal( 'UseExternalEditor', $wgUseExternalEditor );
|
|||
$mediaWiki->setVal( 'UsePathInfo', $wgUsePathInfo );
|
||||
|
||||
$mediaWiki->performRequestForTitle( $wgTitle, $wgArticle, $wgOut, $wgUser, $wgRequest );
|
||||
$mediaWiki->finalCleanup( $wgDeferredUpdateList, $wgOut );
|
||||
$mediaWiki->finalCleanup( $wgOut );
|
||||
|
||||
$mediaWiki->restInPeace();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue