Take articles into account when merging users
authorMarcel Werk <burntime@woltlab.com>
Thu, 24 Oct 2024 12:21:20 +0000 (14:21 +0200)
committerMarcel Werk <burntime@woltlab.com>
Thu, 24 Oct 2024 12:21:20 +0000 (14:21 +0200)
ref https://www.woltlab.com/community/thread/308576-when-merging-two-users-the-cms-articles-are-not-assigned-to-the-new-target-user/

wcfsetup/install/files/lib/acp/form/UserMergeForm.class.php

index 2dcf3dc0aec3ad70bf12142801a534f8e96a6fb2..abc358919200f3cf6de587289a2b02465032ec24 100644 (file)
@@ -272,6 +272,15 @@ class UserMergeForm extends AbstractForm
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(\array_merge([$this->destinationUserID], $conditions->getParameters()));
 
+        // articles
+        $conditions = new PreparedStatementConditionBuilder();
+        $conditions->add("userID IN (?)", [$this->mergedUserIDs]);
+        $sql = "UPDATE  wcf" . WCF_N . "_article
+                SET     userID = ?
+                " . $conditions;
+        $statement = WCF::getDB()->prepareStatement($sql);
+        $statement->execute(\array_merge([$this->destinationUserID], $conditions->getParameters()));
+
         // delete merged users
         $action = new UserAction($this->mergedUserIDs, 'delete');
         $action->executeAction();