$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 );
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 {
- $dbw->rollback( __METHOD__ );
+ // Page deleted but file still there? rollback page delete
+ wfGetLBFactory()->rollbackMasterChanges( __METHOD__ );
}
+ } else {
+ // Done; nothing changed
+ $dbw->endAtomic( __METHOD__ );
}
} catch ( Exception $e ) {
// Rollback before returning to prevent UI from displaying
}
if ( $status->isOK() ) {
- Hooks::run( 'FileDeleteComplete', array( &$file, &$oldimage, &$page, &$user, &$reason ) );
+ Hooks::run( 'FileDeleteComplete', [ &$file, &$oldimage, &$page, &$user, &$reason ] );
}
return $status;
<td></td>
<td class='mw-input'><strong>" .
Xml::checkLabel( wfMessage( 'revdelete-suppress' )->text(),
- 'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '3' ) ) .
+ 'wpSuppress', 'wpSuppress', false, [ 'tabindex' => '3' ] ) .
"</strong></td>
</tr>";
} else {
}
$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' ] ) .
"<tr>
<td class='mw-label'>" .
Xml::label( wfMessage( 'filedelete-comment' )->text(), 'wpDeleteReasonList' ) .
"</td>
<td class='mw-input'>" .
Xml::input( 'wpReason', 60, $wgRequest->getText( 'wpReason' ),
- array( 'type' => 'text', 'maxlength' => '255', 'tabindex' => '2', 'id' => 'wpReason' ) ) .
+ [ 'type' => 'text', 'maxlength' => '255', 'tabindex' => '2', 'id' => 'wpReason' ] ) .
"</td>
</tr>
{$suppress}";
<td></td>
<td class='mw-input'>" .
Xml::checkLabel( wfMessage( 'watchthis' )->text(),
- 'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) .
+ 'wpWatch', 'wpWatch', $checkWatch, [ 'tabindex' => '3' ] ) .
"</td>
</tr>";
}
<td class='mw-submit'>" .
Xml::submitButton(
wfMessage( 'filedelete-submit' )->text(),
- array(
+ [
'name' => 'mw-filedelete-submit',
'id' => 'mw-filedelete-submit',
'tabindex' => '4'
- )
+ ]
) .
"</td>
</tr>" .
$link = Linker::linkKnown(
$title,
wfMessage( 'filedelete-edit-reasonlist' )->escaped(),
- array(),
- array( 'action' => 'edit' )
+ [],
+ [ 'action' => 'edit' ]
);
$form .= '<p class="mw-filedelete-editreasons">' . $link . '</p>';
}
* @return string
*/
private function getAction() {
- $q = array();
+ $q = [];
$q['action'] = 'delete';
if ( $this->oldimage ) {