* Wrap file into one nice move transaction with the rest

* Fix undefined variable error
This commit is contained in:
Aaron Schulz 2008-05-25 05:06:50 +00:00
parent 1efa4fbd5d
commit cf13bdb44d
2 changed files with 34 additions and 28 deletions

View file

@ -342,9 +342,9 @@ class MovePageForm {
$conds = null;
}
$extrapages = array();
if( !is_null( $conds ) ) {
$extrapages = $dbr->select(
'page',
$extrapages = $dbr->select( 'page',
array( 'page_id', 'page_namespace', 'page_title' ),
$conds,
__METHOD__

View file

@ -2584,18 +2584,9 @@ class Title {
$now = wfTimestampNow();
$newid = $nt->getArticleID();
$oldid = $this->getArticleID();
$dbw = wfGetDB( DB_MASTER );
# Move an image if it is
if( $this->getNamespace() == NS_IMAGE ) {
$file = wfLocalFile( $this );
if( $file->exists() ) {
$status = $file->move( $nt );
if( !$status->isOk() ) {
return $status->getWikiText();
}
}
}
$dbw = wfGetDB( DB_MASTER );
$dbw->begin();
# Delete the old redirect. We don't save it to history since
# by definition if we've got here it's rather uninteresting.
@ -2638,8 +2629,7 @@ class Title {
wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, false) );
# Recreate the redirect, this time in the other direction.
if($createRedirect || !$wgUser->isAllowed('suppressredirect'))
{
if( $createRedirect || !$wgUser->isAllowed('suppressredirect') ) {
$mwRedir = MagicWord::get( 'redirect' );
$redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
$redirectArticle = new Article( $this );
@ -2665,6 +2655,19 @@ class Title {
} else {
$this->resetArticleID( 0 );
}
# Move an image if this is a file
if( $this->getNamespace() == NS_IMAGE ) {
$file = wfLocalFile( $this );
if( $file->exists() ) {
$status = $file->move( $nt );
if( !$status->isOk() ) {
$dbw->rollback();
return $status->getWikiText();
}
}
}
$dbw->commit();
# Log the move
$log = new LogPage( 'move' );
@ -2695,20 +2698,11 @@ class Title {
$newid = $nt->getArticleID();
$oldid = $this->getArticleID();
$dbw = wfGetDB( DB_MASTER );
$dbw->begin();
$now = $dbw->timestamp();
# Move an image if it is
if( $this->getNamespace() == NS_IMAGE ) {
$file = wfLocalFile( $this );
if( $file->exists() ) {
$status = $file->move( $nt );
if( !$status->isOk() ) {
return $status->getWikiText();
}
}
}
# Save a null revision in the page's history notifying of the move
$nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true );
$nullRevId = $nullRevision->insertOn( $dbw );
@ -2730,8 +2724,7 @@ class Title {
wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, false) );
if($createRedirect || !$wgUser->isAllowed('suppressredirect'))
{
if( $createRedirect || !$wgUser->isAllowed('suppressredirect') ) {
# Insert redirect
$mwRedir = MagicWord::get( 'redirect' );
$redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
@ -2756,6 +2749,19 @@ class Title {
} else {
$this->resetArticleID( 0 );
}
# Move an image if this is a file
if( $this->getNamespace() == NS_IMAGE ) {
$file = wfLocalFile( $this );
if( $file->exists() ) {
$status = $file->move( $nt );
if( !$status->isOk() ) {
$dbw->rollback();
return $status->getWikiText();
}
}
}
$dbw->commit();
# Log the move
$log = new LogPage( 'move' );