Merge "Expose the log_id of the deletion log entry in the action=delete API"
[lhc/web/wiklou.git] / includes / Article.php
index dcde2cf..3b259e2 100644 (file)
@@ -1369,10 +1369,12 @@ class Article extends Page {
 
                        $this->doDelete( $reason, $suppress );
 
-                       if ( $request->getCheck( 'wpWatch' ) && $user->isLoggedIn() ) {
-                               WatchAction::doWatch( $title, $user );
-                       } elseif ( $title->userIsWatching() ) {
-                               WatchAction::doUnwatch( $title, $user );
+                       if ( $user->isLoggedIn() && $request->getCheck( 'wpWatch' ) != $user->isWatched( $title ) ) {
+                               if ( $request->getCheck( 'wpWatch' ) ) {
+                                       WatchAction::doWatch( $title, $user );
+                               } else {
+                                       WatchAction::doUnwatch( $title, $user );
+                               }
                        }
 
                        return;
@@ -1436,7 +1438,7 @@ class Article extends Page {
                } else {
                        $suppress = '';
                }
-               $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $this->getTitle()->userIsWatching();
+               $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $user->isWatched( $this->getTitle() );
 
                $form = Xml::openElement( 'form', array( 'method' => 'post',
                        'action' => $this->getTitle()->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) .
@@ -1520,7 +1522,8 @@ class Article extends Page {
        public function doDelete( $reason, $suppress = false ) {
                $error = '';
                $outputPage = $this->getContext()->getOutput();
-               if ( $this->mPage->doDeleteArticle( $reason, $suppress, 0, true, $error ) ) {
+               $status = $this->mPage->doDeleteArticleReal( $reason, $suppress, 0, true, $error );
+               if ( $status->isGood() ) {
                        $deleted = $this->getTitle()->getPrefixedText();
 
                        $outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
@@ -1533,8 +1536,9 @@ class Article extends Page {
                } else {
                        $outputPage->setPageTitle( wfMessage( 'cannotdelete-title', $this->getTitle()->getPrefixedText() ) );
                        if ( $error == '' ) {
+                               $errors = $status->getErrorsArray();
                                $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
-                                       array( 'cannotdelete', wfEscapeWikiText( $this->getTitle()->getPrefixedText() ) )
+                                       $errors[0]
                                );
                                $outputPage->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );