X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FFileDeleteForm.php;h=98f8283813508a40799515dcb74559705a75cca5;hb=30aaec7b506e38ae628bbfd3b133bf43d58f12c1;hp=bcd6db20266f1636536720e0730fd94bb4697278;hpb=6467ad900b4799c01bbbaceb38cb7fbe309f1c53;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index bcd6db2026..98f8283813 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -180,6 +180,8 @@ class FileDeleteForm { $logEntry->setComment( $logComment ); $logid = $logEntry->insert(); $logEntry->publish( $logid ); + + $status->value = $logid; } } else { $status = Status::newFatal( 'cannotdelete', @@ -188,6 +190,7 @@ class FileDeleteForm { $page = WikiPage::factory( $title ); $dbw = wfGetDB( DB_MASTER ); try { + $dbw->startAtomic( __METHOD__ ); // delete the associated article first $error = ''; $deleteStatus = $page->doDeleteArticleReal( $reason, $suppress, 0, false, $error, $user ); @@ -196,10 +199,15 @@ class FileDeleteForm { if ( $deleteStatus->isOK() ) { $status = $file->delete( $reason, $suppress, $user ); if ( $status->isOK() ) { - $dbw->commit( __METHOD__ ); + $status->value = $deleteStatus->value; // log id + $dbw->endAtomic( __METHOD__ ); } else { + // Page deleted but file still there? rollback page delete $dbw->rollback( __METHOD__ ); } + } else { + // Done; nothing changed + $dbw->endAtomic( __METHOD__ ); } } catch ( Exception $e ) { // Rollback before returning to prevent UI from displaying @@ -210,7 +218,7 @@ class FileDeleteForm { } if ( $status->isOK() ) { - Hooks::run( 'FileDeleteComplete', array( &$file, &$oldimage, &$page, &$user, &$reason ) ); + Hooks::run( 'FileDeleteComplete', [ &$file, &$oldimage, &$page, &$user, &$reason ] ); } return $status; @@ -227,7 +235,7 @@ class FileDeleteForm { " . Xml::checkLabel( wfMessage( 'revdelete-suppress' )->text(), - 'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '3' ) ) . + 'wpSuppress', 'wpSuppress', false, [ 'tabindex' => '3' ] ) . " "; } else { @@ -235,13 +243,13 @@ class FileDeleteForm { } $checkWatch = $wgUser->getBoolOption( 'watchdeletion' ) || $wgUser->isWatched( $this->title ); - $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getAction(), - 'id' => 'mw-img-deleteconfirm' ) ) . + $form = Xml::openElement( 'form', [ 'method' => 'post', 'action' => $this->getAction(), + 'id' => 'mw-img-deleteconfirm' ] ) . Xml::openElement( 'fieldset' ) . Xml::element( 'legend', null, wfMessage( 'filedelete-legend' )->text() ) . Html::hidden( 'wpEditToken', $wgUser->getEditToken( $this->oldimage ) ) . $this->prepareMessage( 'filedelete-intro' ) . - Xml::openElement( 'table', array( 'id' => 'mw-img-deleteconfirm-table' ) ) . + Xml::openElement( 'table', [ 'id' => 'mw-img-deleteconfirm-table' ] ) . " " . Xml::label( wfMessage( 'filedelete-comment' )->text(), 'wpDeleteReasonList' ) . @@ -263,7 +271,7 @@ class FileDeleteForm { " " . Xml::input( 'wpReason', 60, $wgRequest->getText( 'wpReason' ), - array( 'type' => 'text', 'maxlength' => '255', 'tabindex' => '2', 'id' => 'wpReason' ) ) . + [ 'type' => 'text', 'maxlength' => '255', 'tabindex' => '2', 'id' => 'wpReason' ] ) . " {$suppress}"; @@ -273,7 +281,7 @@ class FileDeleteForm { " . Xml::checkLabel( wfMessage( 'watchthis' )->text(), - 'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) . + 'wpWatch', 'wpWatch', $checkWatch, [ 'tabindex' => '3' ] ) . " "; } @@ -283,11 +291,11 @@ class FileDeleteForm { " . Xml::submitButton( wfMessage( 'filedelete-submit' )->text(), - array( + [ 'name' => 'mw-filedelete-submit', 'id' => 'mw-filedelete-submit', 'tabindex' => '4' - ) + ] ) . " " . @@ -300,8 +308,8 @@ class FileDeleteForm { $link = Linker::linkKnown( $title, wfMessage( 'filedelete-edit-reasonlist' )->escaped(), - array(), - array( 'action' => 'edit' ) + [], + [ 'action' => 'edit' ] ); $form .= '

' . $link . '

'; } @@ -390,7 +398,7 @@ class FileDeleteForm { * @return string */ private function getAction() { - $q = array(); + $q = []; $q['action'] = 'delete'; if ( $this->oldimage ) {