$id = $this->mTitle->getArticleID( Title::GAID_FOR_UPDATE );
$error = '';
- if ( wfRunHooks( 'ArticleDelete', array( &$this, &$wgUser, &$reason, &$error ) ) ) {
- if ( $this->doDeleteArticle( $reason, $suppress, $id ) ) {
- $deleted = $this->mTitle->getPrefixedText();
+ if ( $this->doDeleteArticle( $reason, $suppress, $id, &$error ) ) {
+ $deleted = $this->mTitle->getPrefixedText();
- $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
- $wgOut->setRobotPolicy( 'noindex,nofollow' );
+ $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
- $loglink = '[[Special:Log/delete|' . wfMsgNoTrans( 'deletionlog' ) . ']]';
+ $loglink = '[[Special:Log/delete|' . wfMsgNoTrans( 'deletionlog' ) . ']]';
- $wgOut->addWikiMsg( 'deletedtext', $deleted, $loglink );
- $wgOut->returnToMain( false );
- wfRunHooks( 'ArticleDeleteComplete', array( &$this, &$wgUser, $reason, $id ) );
- }
+ $wgOut->addWikiMsg( 'deletedtext', $deleted, $loglink );
+ $wgOut->returnToMain( false );
} else {
if ( $error == '' ) {
$wgOut->showFatalError(
* @param $commit boolean defaults to true, triggers transaction end
* @return boolean true if successful
*/
- public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true ) {
+ public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true, $error='' ) {
global $wgDeferredUpdateList, $wgUseTrackbacks;
wfDebug( __METHOD__ . "\n" );
+ if ( ! wfRunHooks( 'ArticleDelete', array( &$this, &$wgUser, &$reason, &$error ) ) ) {
+ return false;
+ }
$dbw = wfGetDB( DB_MASTER );
$t = $this->mTitle->getDBkey();
$id = $id ? $id : $this->mTitle->getArticleID( Title::GAID_FOR_UPDATE );
$dbw->commit();
}
+ wfRunHooks( 'ArticleDeleteComplete', array( &$this, &$wgUser, $reason, $id ) );
return true;
}
$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();
- }
- $status = $file->delete( $reason, $suppress );
- if( $status->ok ) {
- $dbw->commit();
- wfRunHooks( 'ArticleDeleteComplete', array( &$article, &$wgUser, $reason, $id ) );
- } else {
- $dbw->rollback();
- }
+ // 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();
+ }
+ $status = $file->delete( $reason, $suppress );
+ if( $status->ok ) {
+ $dbw->commit();
+ wfRunHooks( 'ArticleDeleteComplete', array( &$article, &$wgUser, $reason, $id ) );
+ } else {
+ $dbw->rollback();
}
}
} catch ( MWException $e ) {
}
$error = '';
- if ( !wfRunHooks( 'ArticleDelete', array( &$article, &$wgUser, &$reason, &$error ) ) ) {
- return array( array( 'hookaborted', $error ) );
- }
-
// Luckily, Article.php provides a reusable delete function that does the hard work for us
- if ( $article->doDeleteArticle( $reason ) ) {
- wfRunHooks( 'ArticleDeleteComplete', array( &$article, &$wgUser, $reason, $article->getId() ) );
+ if ( $article->doDeleteArticle( $reason, false, 0, true, &$error ) ) {
return array();
+ } else {
+ return array( array( 'cannotdelete', $article->mTitle->getPrefixedText() ) );
}
- return array( array( 'cannotdelete', $article->mTitle->getPrefixedText() ) );
}
/**
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}