Index: trunk/phase3/includes/Article.php |
— | — | @@ -3052,19 +3052,16 @@ |
3053 | 3053 | $id = $this->mTitle->getArticleID( Title::GAID_FOR_UPDATE ); |
3054 | 3054 | |
3055 | 3055 | $error = ''; |
3056 | | - if ( wfRunHooks( 'ArticleDelete', array( &$this, &$wgUser, &$reason, &$error ) ) ) { |
3057 | | - if ( $this->doDeleteArticle( $reason, $suppress, $id ) ) { |
3058 | | - $deleted = $this->mTitle->getPrefixedText(); |
| 3056 | + if ( $this->doDeleteArticle( $reason, $suppress, $id, &$error ) ) { |
| 3057 | + $deleted = $this->mTitle->getPrefixedText(); |
3059 | 3058 | |
3060 | | - $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) ); |
3061 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
| 3059 | + $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) ); |
| 3060 | + $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
3062 | 3061 | |
3063 | | - $loglink = '[[Special:Log/delete|' . wfMsgNoTrans( 'deletionlog' ) . ']]'; |
| 3062 | + $loglink = '[[Special:Log/delete|' . wfMsgNoTrans( 'deletionlog' ) . ']]'; |
3064 | 3063 | |
3065 | | - $wgOut->addWikiMsg( 'deletedtext', $deleted, $loglink ); |
3066 | | - $wgOut->returnToMain( false ); |
3067 | | - wfRunHooks( 'ArticleDeleteComplete', array( &$this, &$wgUser, $reason, $id ) ); |
3068 | | - } |
| 3064 | + $wgOut->addWikiMsg( 'deletedtext', $deleted, $loglink ); |
| 3065 | + $wgOut->returnToMain( false ); |
3069 | 3066 | } else { |
3070 | 3067 | if ( $error == '' ) { |
3071 | 3068 | $wgOut->showFatalError( |
— | — | @@ -3102,11 +3099,14 @@ |
3103 | 3100 | * @param $commit boolean defaults to true, triggers transaction end |
3104 | 3101 | * @return boolean true if successful |
3105 | 3102 | */ |
3106 | | - public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true ) { |
| 3103 | + public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true, $error='' ) { |
3107 | 3104 | global $wgDeferredUpdateList, $wgUseTrackbacks; |
3108 | 3105 | |
3109 | 3106 | wfDebug( __METHOD__ . "\n" ); |
3110 | 3107 | |
| 3108 | + if ( ! wfRunHooks( 'ArticleDelete', array( &$this, &$wgUser, &$reason, &$error ) ) ) { |
| 3109 | + return false; |
| 3110 | + } |
3111 | 3111 | $dbw = wfGetDB( DB_MASTER ); |
3112 | 3112 | $t = $this->mTitle->getDBkey(); |
3113 | 3113 | $id = $id ? $id : $this->mTitle->getArticleID( Title::GAID_FOR_UPDATE ); |
— | — | @@ -3232,6 +3232,7 @@ |
3233 | 3233 | $dbw->commit(); |
3234 | 3234 | } |
3235 | 3235 | |
| 3236 | + wfRunHooks( 'ArticleDeleteComplete', array( &$this, &$wgUser, $reason, $id ) ); |
3236 | 3237 | return true; |
3237 | 3238 | } |
3238 | 3239 | |
Index: trunk/phase3/includes/api/ApiDelete.php |
— | — | @@ -146,16 +146,12 @@ |
147 | 147 | } |
148 | 148 | |
149 | 149 | $error = ''; |
150 | | - if ( !wfRunHooks( 'ArticleDelete', array( &$article, &$wgUser, &$reason, &$error ) ) ) { |
151 | | - return array( array( 'hookaborted', $error ) ); |
152 | | - } |
153 | | - |
154 | 150 | // Luckily, Article.php provides a reusable delete function that does the hard work for us |
155 | | - if ( $article->doDeleteArticle( $reason ) ) { |
156 | | - wfRunHooks( 'ArticleDeleteComplete', array( &$article, &$wgUser, $reason, $article->getId() ) ); |
| 151 | + if ( $article->doDeleteArticle( $reason, false, 0, true, &$error ) ) { |
157 | 152 | return array(); |
| 153 | + } else { |
| 154 | + return array( array( 'cannotdelete', $article->mTitle->getPrefixedText() ) ); |
158 | 155 | } |
159 | | - return array( array( 'cannotdelete', $article->mTitle->getPrefixedText() ) ); |
160 | 156 | } |
161 | 157 | |
162 | 158 | /** |
— | — | @@ -284,4 +280,4 @@ |
285 | 281 | public function getVersion() { |
286 | 282 | return __CLASS__ . ': $Id$'; |
287 | 283 | } |
288 | | -} |
\ No newline at end of file |
| 284 | +} |
Index: trunk/phase3/includes/FileDeleteForm.php |
— | — | @@ -121,23 +121,21 @@ |
122 | 122 | $error = ''; |
123 | 123 | $dbw = wfGetDB( DB_MASTER ); |
124 | 124 | try { |
125 | | - if( wfRunHooks( 'ArticleDelete', array( &$article, &$wgUser, &$reason, &$error ) ) ) { |
126 | | - // delete the associated article first |
127 | | - if( $article->doDeleteArticle( $reason, $suppress, $id, false ) ) { |
128 | | - global $wgRequest; |
129 | | - if( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) { |
130 | | - $article->doWatch(); |
131 | | - } elseif( $title->userIsWatching() ) { |
132 | | - $article->doUnwatch(); |
133 | | - } |
134 | | - $status = $file->delete( $reason, $suppress ); |
135 | | - if( $status->ok ) { |
136 | | - $dbw->commit(); |
137 | | - wfRunHooks( 'ArticleDeleteComplete', array( &$article, &$wgUser, $reason, $id ) ); |
138 | | - } else { |
139 | | - $dbw->rollback(); |
140 | | - } |
| 125 | + // delete the associated article first |
| 126 | + if( $article->doDeleteArticle( $reason, $suppress, $id, false ) ) { |
| 127 | + global $wgRequest; |
| 128 | + if( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) { |
| 129 | + $article->doWatch(); |
| 130 | + } elseif( $title->userIsWatching() ) { |
| 131 | + $article->doUnwatch(); |
141 | 132 | } |
| 133 | + $status = $file->delete( $reason, $suppress ); |
| 134 | + if( $status->ok ) { |
| 135 | + $dbw->commit(); |
| 136 | + wfRunHooks( 'ArticleDeleteComplete', array( &$article, &$wgUser, $reason, $id ) ); |
| 137 | + } else { |
| 138 | + $dbw->rollback(); |
| 139 | + } |
142 | 140 | } |
143 | 141 | } catch ( MWException $e ) { |
144 | 142 | // rollback before returning to prevent UI from displaying incorrect "View or restore N deleted edits?" |