jenkins-bot has submitted this change and it was merged.

Change subject: Move tagging of API deletions to RC save
......................................................................


Move tagging of API deletions to RC save

Since the recent change save of logged actions is now deferred, we need
to move tagging of API deletions to the RC save, like other API actions
do already. Otherwise, only the log gets tagged, not the RC.

Bug: T108564
Change-Id: I4e6e18e7f8fb7a6b0932e7579bafddcc1b0a9758
---
M includes/FileDeleteForm.php
M includes/api/ApiDelete.php
M includes/page/Article.php
M includes/page/WikiPage.php
4 files changed, 22 insertions(+), 17 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php
index 47360df..e6223e8 100644
--- a/includes/FileDeleteForm.php
+++ b/includes/FileDeleteForm.php
@@ -150,11 +150,12 @@
         * @param string $reason Reason of the deletion
         * @param bool $suppress Whether to mark all deleted versions as 
restricted
         * @param User $user User object performing the request
+        * @param array $tags Tags to apply to the deletion action
         * @throws MWException
         * @return bool|Status
         */
        public static function doDelete( &$title, &$file, &$oldimage, $reason,
-               $suppress, User $user = null
+               $suppress, User $user = null, $tags = []
        ) {
                if ( $user === null ) {
                        global $wgUser;
@@ -178,6 +179,7 @@
                                $logEntry->setPerformer( $user );
                                $logEntry->setTarget( $title );
                                $logEntry->setComment( $logComment );
+                               $logEntry->setTags( $tags );
                                $logid = $logEntry->insert();
                                $logEntry->publish( $logid );
 
@@ -192,7 +194,8 @@
                        $dbw->startAtomic( __METHOD__ );
                        // delete the associated article first
                        $error = '';
-                       $deleteStatus = $page->doDeleteArticleReal( $reason, 
$suppress, 0, false, $error, $user );
+                       $deleteStatus = $page->doDeleteArticleReal( $reason, 
$suppress, 0, false, $error,
+                               $user, $tags );
                        // doDeleteArticleReal() returns a non-fatal error 
status if the page
                        // or revision is missing, so check for isOK() rather 
than isGood()
                        if ( $deleteStatus->isOK() ) {
diff --git a/includes/api/ApiDelete.php b/includes/api/ApiDelete.php
index 77911b0..993c23e 100644
--- a/includes/api/ApiDelete.php
+++ b/includes/api/ApiDelete.php
@@ -73,10 +73,11 @@
                                $user,
                                $params['oldimage'],
                                $reason,
-                               false
+                               false,
+                               $params['tags']
                        );
                } else {
-                       $status = self::delete( $pageObj, $user, $reason );
+                       $status = self::delete( $pageObj, $user, $reason, 
$params['tags'] );
                }
 
                if ( is_array( $status ) ) {
@@ -96,11 +97,6 @@
                }
                $this->setWatch( $watch, $titleObj, 'watchdeletion' );
 
-               // Apply change tags to the log entry, if requested
-               if ( count( $params['tags'] ) ) {
-                       ChangeTags::addTags( $params['tags'], null, null, 
$status->value, null );
-               }
-
                $r = [
                        'title' => $titleObj->getPrefixedText(),
                        'reason' => $reason,
@@ -115,9 +111,10 @@
         * @param Page|WikiPage $page Page or WikiPage object to work on
         * @param User $user User doing the action
         * @param string|null $reason Reason for the deletion. Autogenerated if 
null
+        * @param array $tags Tags to tag the deletion with
         * @return Status|array
         */
-       protected static function delete( Page $page, User $user, &$reason = 
null ) {
+       protected static function delete( Page $page, User $user, &$reason = 
null, $tags = [] ) {
                $title = $page->getTitle();
 
                // Auto-generate a summary, if necessary
@@ -134,7 +131,7 @@
                $error = '';
 
                // Luckily, Article.php provides a reusable delete function 
that does the hard work for us
-               return $page->doDeleteArticleReal( $reason, false, 0, true, 
$error, $user );
+               return $page->doDeleteArticleReal( $reason, false, 0, true, 
$error, $user, $tags );
        }
 
        /**
@@ -143,16 +140,17 @@
         * @param string $oldimage Archive name
         * @param string $reason Reason for the deletion. Autogenerated if null.
         * @param bool $suppress Whether to mark all deleted versions as 
restricted
+        * @param array $tags Tags to tag the deletion with
         * @return Status|array
         */
        protected static function deleteFile( Page $page, User $user, $oldimage,
-               &$reason = null, $suppress = false
+               &$reason = null, $suppress = false, $tags = []
        ) {
                $title = $page->getTitle();
 
                $file = $page->getFile();
                if ( !$file->exists() || !$file->isLocal() || 
$file->getRedirected() ) {
-                       return self::delete( $page, $user, $reason );
+                       return self::delete( $page, $user, $reason, $tags );
                }
 
                if ( $oldimage ) {
@@ -169,7 +167,7 @@
                        $reason = '';
                }
 
-               return FileDeleteForm::doDelete( $title, $file, $oldimage, 
$reason, $suppress, $user );
+               return FileDeleteForm::doDelete( $title, $file, $oldimage, 
$reason, $suppress, $user, $tags );
        }
 
        public function mustBePosted() {
diff --git a/includes/page/Article.php b/includes/page/Article.php
index ba0a484..adc2aef 100644
--- a/includes/page/Article.php
+++ b/includes/page/Article.php
@@ -2091,10 +2091,11 @@
         * @see WikiPage::doDeleteArticleReal
         */
        public function doDeleteArticleReal(
-               $reason, $suppress = false, $u1 = null, $u2 = null, &$error = 
'', User $user = null
+               $reason, $suppress = false, $u1 = null, $u2 = null, &$error = 
'', User $user = null,
+               $tags = []
        ) {
                return $this->mPage->doDeleteArticleReal(
-                       $reason, $suppress, $u1, $u2, $error, $user
+                       $reason, $suppress, $u1, $u2, $error, $user, $tags
                );
        }
 
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index fe0fffc..50c5030 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -2882,12 +2882,14 @@
         * @param bool $u2 Unused
         * @param array|string &$error Array of errors to append to
         * @param User $user The deleting user
+        * @param array $tags Tags to apply to the deletion action
         * @return Status Status object; if successful, $status->value is the 
log_id of the
         *   deletion log entry. If the page couldn't be deleted because it 
wasn't
         *   found, $status is a non-fatal 'cannotdelete' error
         */
        public function doDeleteArticleReal(
-               $reason, $suppress = false, $u1 = null, $u2 = null, &$error = 
'', User $user = null
+               $reason, $suppress = false, $u1 = null, $u2 = null, &$error = 
'', User $user = null,
+               $tags = []
        ) {
                global $wgUser, $wgContentHandlerUseDB;
 
@@ -3026,6 +3028,7 @@
                $logEntry->setPerformer( $user );
                $logEntry->setTarget( $logTitle );
                $logEntry->setComment( $reason );
+               $logEntry->setTags( $tags );
                $logid = $logEntry->insert();
 
                $dbw->onTransactionPreCommitOrIdle(

-- 
To view, visit https://gerrit.wikimedia.org/r/312046
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4e6e18e7f8fb7a6b0932e7579bafddcc1b0a9758
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Cenarium <cenarium.sy...@gmail.com>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Anomie <bjor...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: TTO <at.li...@live.com.au>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to