summaryrefslogtreecommitdiff
path: root/includes/FileDeleteForm.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-06-22 11:28:20 +0200
committerPierre Schmitz <pierre@archlinux.de>2011-06-22 11:28:20 +0200
commit9db190c7e736ec8d063187d4241b59feaf7dc2d1 (patch)
tree46d1a0dee7febef5c2d57a9f7b972be16a163b3d /includes/FileDeleteForm.php
parent78677c7bbdcc9739f6c10c75935898a20e1acd9e (diff)
update to MediaWiki 1.17.0
Diffstat (limited to 'includes/FileDeleteForm.php')
-rw-r--r--includes/FileDeleteForm.php38
1 files changed, 25 insertions, 13 deletions
diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php
index dad19524..030330bb 100644
--- a/includes/FileDeleteForm.php
+++ b/includes/FileDeleteForm.php
@@ -102,34 +102,47 @@ class FileDeleteForm {
public static function doDelete( &$title, &$file, &$oldimage, $reason, $suppress ) {
global $wgUser;
$article = null;
+ $status = Status::newFatal( 'error' );
+
if( $oldimage ) {
$status = $file->deleteOld( $oldimage, $reason, $suppress );
if( $status->ok ) {
// Need to do a log item
$log = new LogPage( 'delete' );
$logComment = wfMsgForContent( 'deletedrevision', $oldimage );
- if( trim( $reason ) != '' )
+ if( trim( $reason ) != '' ) {
$logComment .= wfMsgForContent( 'colon-separator' ) . $reason;
- $log->addEntry( 'delete', $title, $logComment );
+ }
+ $log->addEntry( 'delete', $title, $logComment );
}
} else {
- $status = $file->delete( $reason, $suppress );
- if( $status->ok ) {
- $id = $title->getArticleID( GAID_FOR_UPDATE );
- // Need to delete the associated article
- $article = new Article( $title );
- $error = '';
- if( wfRunHooks('ArticleDelete', array(&$article, &$wgUser, &$reason, &$error)) ) {
- if( $article->doDeleteArticle( $reason, $suppress, $id ) ) {
+ $id = $title->getArticleID( Title::GAID_FOR_UPDATE );
+ $article = new Article( $title );
+ $error = '';
+ $dbw = wfGetDB( DB_MASTER );
+ try {
+ if( wfRunHooks( 'ArticleDelete', array( &$article, &$wgUser, &$reason, &$error ) ) ) {
+ // delete the associated article first
+ if( $article->doDeleteArticle( $reason, $suppress, $id, false ) ) {
global $wgRequest;
if( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) {
$article->doWatch();
} elseif( $title->userIsWatching() ) {
$article->doUnwatch();
}
- wfRunHooks('ArticleDeleteComplete', array(&$article, &$wgUser, $reason, $id));
+ $status = $file->delete( $reason, $suppress );
+ if( $status->ok ) {
+ $dbw->commit();
+ wfRunHooks( 'ArticleDeleteComplete', array( &$article, &$wgUser, $reason, $id ) );
+ } else {
+ $dbw->rollback();
+ }
}
}
+ } catch ( MWException $e ) {
+ // rollback before returning to prevent UI from displaying incorrect "View or restore N deleted edits?"
+ $dbw->rollback();
+ throw $e;
}
}
if( $status->isGood() )
@@ -161,7 +174,7 @@ class FileDeleteForm {
'id' => 'mw-img-deleteconfirm' ) ) .
Xml::openElement( 'fieldset' ) .
Xml::element( 'legend', null, wfMsg( 'filedelete-legend' ) ) .
- Xml::hidden( 'wpEditToken', $wgUser->editToken( $this->oldimage ) ) .
+ Html::hidden( 'wpEditToken', $wgUser->editToken( $this->oldimage ) ) .
$this->prepareMessage( 'filedelete-intro' ) .
Xml::openElement( 'table', array( 'id' => 'mw-img-deleteconfirm-table' ) ) .
"<tr>
@@ -241,7 +254,6 @@ class FileDeleteForm {
private function prepareMessage( $message ) {
global $wgLang;
if( $this->oldimage ) {
- $url = $this->file->getArchiveUrl( $this->oldimage );
return wfMsgExt(
"{$message}-old", # To ensure grep will find them: 'filedelete-intro-old', 'filedelete-nofile-old', 'filedelete-success-old'
'parse',