Merge branch '5.5'
authorAlexander Ebert <ebert@woltlab.com>
Fri, 31 Mar 2023 09:47:33 +0000 (11:47 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 31 Mar 2023 09:47:33 +0000 (11:47 +0200)
1  2 
wcfsetup/install/files/lib/system/search/SearchIndexManager.class.php

index e4222cb567dd55f65755afe9c5930910ce7c0630,fc426403067bc920237a339fdeda65b504a52361..966eb378d6fb7b77458e80f75d5904b054e74138
@@@ -114,7 -121,11 +114,11 @@@ class SearchIndexManager extends Single
          $username,
          $languageID = null,
          $metaData = ''
 -    ) {
 +    ): void {
+         // Inserts a whitespace after certain tags to prevent words from adjacent
+         // lines to be effectively be glued together when the tags are removed.
+         $message = \preg_replace('~(<br>|</(?:h[1-6]|kbd|li|p|pre|td|woltlab-metacode)>)~', '\\1 ', $message);
          // strip html; remove whitespace from beginning and end of the message
          $message = StringUtil::trim(StringUtil::stripHTML($message));
  
      }
  
      /**
 -     * @deprecated  3.0 - please use `set() instead`
 -     */
 -    public function add(
 -        $objectType,
 -        $objectID,
 -        $message,
 -        $subject,
 -        $time,
 -        $userID,
 -        $username,
 -        $languageID = null,
 -        $metaData = ''
 -    ) {
 -        $this->set($objectType, $objectID, $message, $subject, $time, $userID, $username, $languageID, $metaData);
 -    }
 -
 -    /**
 -     * @deprecated  3.0 - please use `set() instead`
 -     */
 -    public function update(
 -        $objectType,
 -        $objectID,
 -        $message,
 -        $subject,
 -        $time,
 -        $userID,
 -        $username,
 -        $languageID = null,
 -        $metaData = ''
 -    ) {
 -        $this->set($objectType, $objectID, $message, $subject, $time, $userID, $username, $languageID, $metaData);
 +     * @inheritDoc
 +     * @since 6.0
 +     */
 +    public function setWithContext(
 +        string $objectType,
 +        int $objectID,
 +        int $parentID,
 +        int $containerID,
 +        string $message,
 +        string $subject,
 +        int $time,
 +        ?int $userID,
 +        string $username,
 +        ?int $languageID = null,
 +        string $metaData = ''
 +    ): void {
 +        $searchIndexManager = $this->getSearchIndexManager();
 +        if ($searchIndexManager instanceof IContextAwareSearchIndexManager) {
++            // Inserts a whitespace after certain tags to prevent words from adjacent
++            // lines to be effectively be glued together when the tags are removed.
++            $message = \preg_replace('~(<br>|</(?:h[1-6]|kbd|li|p|pre|td|woltlab-metacode)>)~', '\\1 ', $message);
++
 +            $message = StringUtil::trim(StringUtil::stripHTML($message));
 +
 +            $searchIndexManager->setWithContext(
 +                $objectType,
 +                $objectID,
 +                $parentID,
 +                $containerID,
 +                $message,
 +                $subject,
 +                $time,
 +                $userID,
 +                $username,
 +                $languageID,
 +                $metaData
 +            );
 +        } else {
 +            $searchIndexManager
 +                ->set($objectType, $objectID, $message, $subject, $time, $userID, $username, $languageID, $metaData);
 +        }
      }
  
      /**