Make MysqlSearchIndexManager implement set()
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 8 Jun 2021 14:51:27 +0000 (16:51 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 8 Jun 2021 14:51:27 +0000 (16:51 +0200)
The use of `add()` is deprecated. `set()` should be the canonical method.

wcfsetup/install/files/lib/system/search/mysql/MysqlSearchIndexManager.class.php

index 110a5ede11b86f1044b5de174c2753f3628a0ce4..bf283f78bfaaa21974f7b1e8fad03a29ceef9dfc 100644 (file)
@@ -22,7 +22,7 @@ class MysqlSearchIndexManager extends AbstractSearchIndexManager
     /**
      * @inheritDoc
      */
-    public function add(
+    public function set(
         $objectType,
         $objectID,
         $message,
@@ -59,11 +59,44 @@ class MysqlSearchIndexManager extends AbstractSearchIndexManager
         $languageID = null,
         $metaData = ''
     ) {
-        // delete existing entry
-        $this->delete($objectType, [$objectID]);
+        $this->set(
+            $objectType,
+            $objectID,
+            $message,
+            $subject,
+            $time,
+            $userID,
+            $username,
+            $languageID,
+            $metaData
+        );
+    }
 
-        // save new entry
-        $this->add($objectType, $objectID, $message, $subject, $time, $userID, $username, $languageID, $metaData);
+    /**
+     * @inheritDoc
+     */
+    public function add(
+        $objectType,
+        $objectID,
+        $message,
+        $subject,
+        $time,
+        $userID,
+        $username,
+        $languageID = null,
+        $metaData = ''
+    ) {
+        $this->set(
+            $objectType,
+            $objectID,
+            $message,
+            $subject,
+            $time,
+            $userID,
+            $username,
+            $languageID,
+            $metaData
+        );
     }
 
     /**