Remove deprecated support for `ISearchableObjectType` remove-deprecated-search-stuff
authorMarcel Werk <burntime@woltlab.com>
Wed, 26 Apr 2023 15:06:59 +0000 (17:06 +0200)
committerMarcel Werk <burntime@woltlab.com>
Wed, 26 Apr 2023 15:06:59 +0000 (17:06 +0200)
com.woltlab.wcf/objectTypeDefinition.xml
wcfsetup/install/files/lib/form/SearchForm.class.php [deleted file]
wcfsetup/install/files/lib/page/SearchPage.class.php
wcfsetup/install/files/lib/page/SearchResultPage.class.php [deleted file]
wcfsetup/install/files/lib/system/search/AbstractSearchProvider.class.php
wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php [deleted file]
wcfsetup/install/files/lib/system/search/ISearchableObjectType.class.php [deleted file]
wcfsetup/install/files/lib/system/search/SearchEngine.class.php
wcfsetup/install/files/lib/system/search/SearchHandler.class.php
wcfsetup/install/files/lib/system/search/SearchResultHandler.class.php
wcfsetup/install/files/lib/system/search/mysql/MysqlSearchEngine.class.php

index afb06c88c582e46ded0a701d92c68558213413dd..b1ad6a6aaf1d08d11602e1b8b08da3ed434978dd 100644 (file)
@@ -93,6 +93,7 @@
                </definition>
                <definition>
                        <name>com.woltlab.wcf.searchableObjectType</name>
+                       <interfacename>wcf\system\search\ISearchProvider</interfacename>
                </definition>
                <definition>
                        <name>com.woltlab.wcf.poll</name>
diff --git a/wcfsetup/install/files/lib/form/SearchForm.class.php b/wcfsetup/install/files/lib/form/SearchForm.class.php
deleted file mode 100644 (file)
index e71ec2f..0000000
+++ /dev/null
@@ -1,576 +0,0 @@
-<?php
-
-namespace wcf\form;
-
-use wcf\data\search\keyword\SearchKeywordAction;
-use wcf\data\search\Search;
-use wcf\data\search\SearchAction;
-use wcf\system\exception\IllegalLinkException;
-use wcf\system\exception\NamedUserException;
-use wcf\system\exception\PermissionDeniedException;
-use wcf\system\exception\SystemException;
-use wcf\system\exception\UserInputException;
-use wcf\system\language\LanguageFactory;
-use wcf\system\request\LinkHandler;
-use wcf\system\search\SearchEngine;
-use wcf\system\WCF;
-use wcf\util\HeaderUtil;
-use wcf\util\StringUtil;
-
-/**
- * Shows the search form.
- *
- * @author  Marcel Werk
- * @copyright   2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @deprecated 5.5
- */
-class SearchForm extends AbstractCaptchaForm
-{
-    /**
-     * list of additional conditions
-     * @var string[]
-     */
-    public $additionalConditions = [];
-
-    /**
-     * end date
-     * @var int
-     */
-    public $endDate = '';
-
-    /**
-     * true, if search should be modified
-     * @var bool
-     */
-    public $modifySearch;
-
-    /**
-     * search id used for modification
-     * @var int
-     */
-    public $modifySearchID = 0;
-
-    /**
-     * require exact matches
-     * @var int
-     */
-    public $nameExactly = 1;
-
-    /**
-     * search query
-     * @var string
-     */
-    public $query = '';
-
-    /**
-     * list of search results
-     * @var array
-     */
-    public $results = [];
-
-    /**
-     * @inheritDoc
-     */
-    public $sortField = '';
-
-    /**
-     * @inheritDoc
-     */
-    public $sortOrder = '';
-
-    /**
-     * user id
-     * @var int
-     */
-    public $userID = 0;
-
-    /**
-     * username
-     * @var string
-     */
-    public $username = '';
-
-    /**
-     * parameters used for previous search
-     * @var array
-     */
-    public $searchData = [];
-
-    /**
-     * search id
-     * @var int
-     */
-    public $searchID = 0;
-
-    /**
-     * PreparedStatementConditionBuilder object
-     * @var \wcf\system\database\util\PreparedStatementConditionBuilder
-     */
-    public $searchIndexCondition;
-
-    /**
-     * search hash to modify existing search
-     * @var string
-     */
-    public $searchHash = '';
-
-    /**
-     * selected object types
-     * @var string[]
-     */
-    public $selectedObjectTypes = [];
-
-    /**
-     * start date
-     * @var int
-     */
-    public $startDate = '';
-
-    /**
-     * search for subject only
-     * @var int
-     */
-    public $subjectOnly = 0;
-
-    /**
-     * mark as submitted form if modifying search
-     * @var bool
-     */
-    public $submit = false;
-
-    /**
-     * @var int[]
-     */
-    public $userIDs = [];
-
-    /**
-     * @inheritDoc
-     */
-    public function readParameters()
-    {
-        parent::readParameters();
-
-        if (isset($_REQUEST['q'])) {
-            $this->query = StringUtil::trim($_REQUEST['q']);
-        }
-        if (isset($_REQUEST['username'])) {
-            $this->username = StringUtil::trim($_REQUEST['username']);
-        }
-        if (isset($_REQUEST['userID'])) {
-            $this->userID = \intval($_REQUEST['userID']);
-        }
-        if (isset($_REQUEST['types']) && \is_array($_REQUEST['types'])) {
-            $this->selectedObjectTypes = $_REQUEST['types'];
-
-            // handle special selection to search in all areas
-            if (isset($this->selectedObjectTypes[0]) && $this->selectedObjectTypes[0] === 'everywhere') {
-                $this->selectedObjectTypes = [];
-                foreach (SearchEngine::getInstance()->getAvailableObjectTypes() as $typeName => $typeObject) {
-                    $this->selectedObjectTypes[] = $typeName;
-                }
-            } else {
-                // validate given values
-                foreach ($this->selectedObjectTypes as $objectTypeName) {
-                    if (SearchEngine::getInstance()->getObjectType($objectTypeName) === null) {
-                        throw new IllegalLinkException();
-                    }
-                }
-            }
-        }
-        $this->submit = (!empty($_POST) || !empty($this->query) || !empty($this->username) || $this->userID);
-
-        if (isset($_REQUEST['modify'])) {
-            $this->modifySearchID = \intval($_REQUEST['modify']);
-            $this->modifySearch = new Search($this->modifySearchID);
-
-            if (!$this->modifySearch->searchID || ($this->modifySearch->userID && $this->modifySearch->userID != WCF::getUser()->userID)) {
-                throw new IllegalLinkException();
-            }
-
-            $this->searchData = \unserialize($this->modifySearch->searchData);
-            if (empty($this->searchData['alterable'])) {
-                throw new IllegalLinkException();
-            }
-            $this->query = $this->searchData['query'];
-            $this->sortOrder = $this->searchData['sortOrder'];
-            $this->sortField = $this->searchData['sortField'];
-            $this->nameExactly = $this->searchData['nameExactly'];
-            $this->subjectOnly = $this->searchData['subjectOnly'];
-            $this->startDate = $this->searchData['startDate'];
-            $this->endDate = $this->searchData['endDate'];
-            $this->username = $this->searchData['username'];
-            $this->userID = $this->searchData['userID'];
-            $this->selectedObjectTypes = $this->searchData['selectedObjectTypes'];
-
-            if (!empty($_POST)) {
-                $this->submit = true;
-            }
-        }
-
-        // disable check for security token for GET requests
-        if ($this->submit) {
-            $_POST['t'] = WCF::getSession()->getSecurityToken();
-        }
-
-        // sort order
-        if (isset($_REQUEST['sortField'])) {
-            $this->sortField = $_REQUEST['sortField'];
-        }
-
-        switch ($this->sortField) {
-            case 'subject':
-            case 'time':
-            case 'username':
-                break;
-
-            case 'relevance':
-                if (!$this->submit || !empty($this->query)) {
-                    break;
-                }
-
-                // no break
-            default:
-                if (!$this->submit || !empty($this->query)) {
-                    $this->sortField = 'relevance';
-                } else {
-                    $this->sortField = 'time';
-                }
-        }
-
-        if (isset($_REQUEST['sortOrder'])) {
-            $this->sortOrder = $_REQUEST['sortOrder'];
-            switch ($this->sortOrder) {
-                case 'ASC':
-                case 'DESC':
-                    break;
-                default:
-                    $this->sortOrder = 'DESC';
-            }
-        }
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function readFormParameters()
-    {
-        parent::readFormParameters();
-
-        $this->nameExactly = 0;
-        if (isset($_POST['nameExactly'])) {
-            $this->nameExactly = \intval($_POST['nameExactly']);
-        }
-        if (isset($_POST['subjectOnly'])) {
-            $this->subjectOnly = \intval($_POST['subjectOnly']);
-        }
-        if (isset($_POST['startDate'])) {
-            $this->startDate = $_POST['startDate'];
-        }
-        if (isset($_POST['endDate'])) {
-            $this->endDate = $_POST['endDate'];
-        }
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function validate()
-    {
-        parent::validate();
-
-        // get search conditions
-        $this->getConditions();
-
-        // check query and author
-        if (empty($this->query) && empty($this->username) && !$this->userID) {
-            throw new UserInputException('q');
-        }
-
-        // build search hash
-        $this->searchHash = \sha1(\serialize([
-            $this->query,
-            $this->selectedObjectTypes,
-            !$this->subjectOnly,
-            $this->searchIndexCondition,
-            $this->additionalConditions,
-            $this->sortField . ' ' . $this->sortOrder,
-            PACKAGE_ID,
-        ]));
-
-        // check search hash
-        if (!empty($this->query)) {
-            $parameters = [$this->searchHash, 'messages', TIME_NOW - 1800];
-            if (WCF::getUser()->userID) {
-                $parameters[] = WCF::getUser()->userID;
-            }
-
-            $sql = "SELECT  searchID
-                    FROM    wcf" . WCF_N . "_search
-                    WHERE   searchHash = ?
-                        AND searchType = ?
-                        AND searchTime > ?
-                        " . (WCF::getUser()->userID ? 'AND userID = ?' : 'AND userID IS NULL');
-            $statement = WCF::getDB()->prepareStatement($sql);
-            $statement->execute($parameters);
-            $row = $statement->fetchArray();
-            if ($row !== false) {
-                HeaderUtil::redirect(LinkHandler::getInstance()->getLink(
-                    'SearchResult',
-                    ['id' => $row['searchID']],
-                    'highlight=' . \urlencode($this->query)
-                ));
-
-                exit;
-            }
-        }
-
-        // do search
-        $this->results = SearchEngine::getInstance()->search(
-            $this->query,
-            $this->selectedObjectTypes,
-            $this->subjectOnly,
-            $this->searchIndexCondition,
-            $this->additionalConditions,
-            $this->sortField . ' ' . $this->sortOrder
-        );
-
-        // result is empty
-        if (empty($this->results)) {
-            $this->throwNoMatchesException();
-        }
-    }
-
-    /**
-     * Throws a NamedUserException on search failure.
-     */
-    public function throwNoMatchesException()
-    {
-        @\header('HTTP/1.1 404 Not Found');
-
-        if (empty($this->query)) {
-            throw new NamedUserException(WCF::getLanguage()->get('wcf.search.error.user.noMatches'));
-        } else {
-            throw new NamedUserException(WCF::getLanguage()->getDynamicVariable(
-                'wcf.search.error.noMatches',
-                ['query' => $this->query]
-            ));
-        }
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function submit()
-    {
-        try {
-            parent::submit();
-        } catch (NamedUserException $e) {
-            WCF::getTPL()->assign('errorMessage', $e->getMessage());
-        }
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function save()
-    {
-        parent::save();
-
-        // get additional data
-        $additionalData = [];
-        foreach (SearchEngine::getInstance()->getAvailableObjectTypes() as $objectTypeName => $objectType) {
-            if (($data = $objectType->getAdditionalData()) !== null) {
-                $additionalData[$objectTypeName] = $data;
-            }
-        }
-
-        // save result in database
-        $this->searchData = [
-            'packageID' => PACKAGE_ID,
-            'query' => $this->query,
-            'results' => $this->results,
-            'additionalData' => $additionalData,
-            'sortField' => $this->sortField,
-            'sortOrder' => $this->sortOrder,
-            'nameExactly' => $this->nameExactly,
-            'subjectOnly' => $this->subjectOnly,
-            'startDate' => $this->startDate,
-            'endDate' => $this->endDate,
-            'username' => $this->username,
-            'userID' => $this->userID,
-            'selectedObjectTypes' => $this->selectedObjectTypes,
-            'alterable' => !$this->userID ? 1 : 0,
-        ];
-        if ($this->modifySearchID) {
-            $this->objectAction = new SearchAction([$this->modifySearchID], 'update', [
-                'data' => [
-                    'searchData' => \serialize($this->searchData),
-                    'searchTime' => TIME_NOW,
-                    'searchType' => 'messages',
-                    'searchHash' => $this->searchHash,
-                ],
-            ]);
-            $this->objectAction->executeAction();
-        } else {
-            $this->objectAction = new SearchAction([], 'create', [
-                'data' => [
-                    'userID' => WCF::getUser()->userID ?: null,
-                    'searchData' => \serialize($this->searchData),
-                    'searchTime' => TIME_NOW,
-                    'searchType' => 'messages',
-                    'searchHash' => $this->searchHash,
-                ],
-            ]);
-            $resultValues = $this->objectAction->executeAction();
-            $this->searchID = $resultValues['returnValues']->searchID;
-        }
-        // save keyword
-        if (!empty($this->query)) {
-            (new SearchKeywordAction([], 'registerSearch', [
-                'data' => [
-                    'keyword' => $this->query,
-                ],
-            ]))->executeAction();
-        }
-        $this->saved();
-
-        // forward to result page
-        HeaderUtil::redirect(LinkHandler::getInstance()->getLink(
-            'SearchResult',
-            ['id' => $this->searchID],
-            'highlight=' . \urlencode($this->query)
-        ));
-
-        exit;
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function assignVariables()
-    {
-        parent::assignVariables();
-
-        // init form
-        foreach (SearchEngine::getInstance()->getAvailableObjectTypes() as $objectType) {
-            $objectType->show($this);
-        }
-
-        $searchPreselectObjectType = 'everywhere';
-        if (\count($this->selectedObjectTypes) === 1) {
-            $searchPreselectObjectType = \reset($this->selectedObjectTypes);
-        }
-
-        WCF::getTPL()->assign([
-            'query' => $this->query,
-            'subjectOnly' => $this->subjectOnly,
-            'username' => $this->username,
-            'nameExactly' => $this->nameExactly,
-            'startDate' => $this->startDate,
-            'endDate' => $this->endDate,
-            'sortField' => $this->sortField,
-            'sortOrder' => $this->sortOrder,
-            'selectedObjectTypes' => $this->selectedObjectTypes,
-            'objectTypes' => SearchEngine::getInstance()->getAvailableObjectTypes(),
-            'searchPreselectObjectType' => $searchPreselectObjectType,
-        ]);
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function show()
-    {
-        if (\count($_POST) == 1 && $this->submit) {
-            if ($this->userID) {
-                $this->useCaptcha = false;
-            }
-            $this->submit();
-        }
-
-        parent::show();
-    }
-
-    /**
-     * Sets the conditions for a search in the table of the selected object types.
-     */
-    protected function getConditions()
-    {
-        if (empty($this->selectedObjectTypes)) {
-            $this->selectedObjectTypes = \array_keys(SearchEngine::getInstance()->getAvailableObjectTypes());
-        }
-
-        // default conditions
-        $userIDs = $this->getUserIDs();
-        $conditionBuilderClassName = SearchEngine::getInstance()->getConditionBuilderClassName();
-        $this->searchIndexCondition = new $conditionBuilderClassName(false);
-
-        // user ids
-        if (!empty($userIDs)) {
-            $this->searchIndexCondition->add('userID IN (?)', [$userIDs]);
-        }
-
-        // dates
-        $startDate = @\strtotime($this->startDate);
-        $endDate = @\strtotime($this->endDate);
-        if ($startDate && $endDate) {
-            $this->searchIndexCondition->add('time BETWEEN ? AND ?', [$startDate, $endDate]);
-        } elseif ($startDate) {
-            $this->searchIndexCondition->add('time > ?', [$startDate]);
-        } elseif ($endDate) {
-            $this->searchIndexCondition->add('time < ?', [$endDate]);
-        }
-
-        // language
-        if (!empty($this->query) && LanguageFactory::getInstance()->multilingualismEnabled() && \count(WCF::getUser()->getLanguageIDs())) {
-            $this->searchIndexCondition->add(
-                '(languageID IN (?) OR languageID = 0)',
-                [WCF::getUser()->getLanguageIDs()]
-            );
-        }
-
-        foreach ($this->selectedObjectTypes as $key => $objectTypeName) {
-            $objectType = SearchEngine::getInstance()->getObjectType($objectTypeName);
-            if ($objectType === null) {
-                throw new SystemException('unknown search object type ' . $objectTypeName);
-            }
-
-            try {
-                if (!$objectType->isAccessible()) {
-                    throw new PermissionDeniedException();
-                }
-
-                // special conditions
-                if (($conditionBuilder = $objectType->getConditions($this)) !== null) {
-                    $this->additionalConditions[$objectTypeName] = $conditionBuilder;
-                }
-            } catch (PermissionDeniedException $e) {
-                unset($this->selectedObjectTypes[$key]);
-                continue;
-            }
-        }
-
-        if (empty($this->selectedObjectTypes)) {
-            $this->throwNoMatchesException();
-        }
-    }
-
-    /**
-     * Returns user ids.
-     *
-     * @return  int[]
-     */
-    public function getUserIDs()
-    {
-        return $this->userIDs;
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function __run()
-    {
-        throw new IllegalLinkException();
-    }
-}
index f1596b237d16b2e22bf168a5d721ee53d83865cd..99f557af6f22ea7afd871b14d488578e208e7c6b 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace wcf\page;
 
-use wcf\system\search\ISearchProvider;
 use wcf\system\search\SearchEngine;
 use wcf\system\WCF;
 
@@ -41,11 +40,7 @@ final class SearchPage extends AbstractPage
         parent::assignVariables();
 
         foreach (SearchEngine::getInstance()->getAvailableObjectTypes() as $objectType) {
-            if ($objectType instanceof ISearchProvider) {
-                $objectType->assignVariables();
-            } else {
-                $objectType->show();
-            }
+            $objectType->assignVariables();
         }
 
         WCF::getTPL()->assign([
diff --git a/wcfsetup/install/files/lib/page/SearchResultPage.class.php b/wcfsetup/install/files/lib/page/SearchResultPage.class.php
deleted file mode 100644 (file)
index 9a6340d..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-<?php
-
-namespace wcf\page;
-
-use wcf\data\search\ISearchResultObject;
-use wcf\data\search\Search;
-use wcf\system\event\EventHandler;
-use wcf\system\exception\IllegalLinkException;
-use wcf\system\exception\ImplementationException;
-use wcf\system\page\PageLocationManager;
-use wcf\system\request\LinkHandler;
-use wcf\system\search\SearchEngine;
-use wcf\system\WCF;
-use wcf\util\HeaderUtil;
-
-/**
- * Shows the result of a search request.
- *
- * @author  Marcel Werk
- * @copyright   2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @deprecated 5.5
- */
-class SearchResultPage extends MultipleLinkPage
-{
-    /**
-     * @inheritDoc
-     */
-    public $itemsPerPage = SEARCH_RESULTS_PER_PAGE;
-
-    /**
-     * highlight string
-     * @var string
-     */
-    public $highlight = '';
-
-    /**
-     * search id
-     * @var int
-     */
-    public $searchID = 0;
-
-    /**
-     * search object
-     * @var Search
-     */
-    public $search;
-
-    /**
-     * messages
-     * @var array
-     */
-    public $messages = [];
-
-    /**
-     * search data
-     * @var array
-     */
-    public $searchData;
-
-    /**
-     * result list template
-     * @var string
-     */
-    public $resultListTemplateName = 'searchResultList';
-
-    /**
-     * result list template's application
-     * @var string
-     */
-    public $resultListApplication = 'wcf';
-
-    /**
-     * @inheritDoc
-     */
-    public function readParameters()
-    {
-        parent::readParameters();
-
-        if (isset($_REQUEST['highlight'])) {
-            $this->highlight = $_REQUEST['highlight'];
-        }
-        if (isset($_REQUEST['id'])) {
-            $this->searchID = \intval($_REQUEST['id']);
-        }
-        $this->search = new Search($this->searchID);
-        if (!$this->search->searchID || $this->search->searchType != 'messages') {
-            $this->redirectOrReject();
-        }
-        if ($this->search->userID && $this->search->userID != WCF::getUser()->userID) {
-            $this->redirectOrReject();
-        }
-
-        // get search data
-        $this->searchData = \unserialize($this->search->searchData);
-    }
-
-    /**
-     * Attempts to start a new search if the search id is invalid or unavailable, and the
-     * highlight parameter is available.
-     */
-    protected function redirectOrReject()
-    {
-        if (!empty($this->highlight)) {
-            HeaderUtil::redirect(
-                LinkHandler::getInstance()->getLink('Search', ['q' => $this->highlight])
-            );
-
-            exit;
-        } else {
-            throw new IllegalLinkException();
-        }
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function readData()
-    {
-        parent::readData();
-
-        // cache message data
-        $this->cacheMessageData();
-
-        // get messages
-        $this->readMessages();
-
-        // set active menu item
-        if (isset($this->searchData['selectedObjectTypes']) && \count($this->searchData['selectedObjectTypes']) == 1) {
-            $objectType = SearchEngine::getInstance()->getObjectType(\reset($this->searchData['selectedObjectTypes']));
-            $objectType->setLocation();
-        }
-
-        // add breadcrumbs
-        PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.Search');
-    }
-
-    /**
-     * Caches the message data.
-     */
-    protected function cacheMessageData()
-    {
-        $types = [];
-
-        // group object id by object type
-        for ($i = $this->startIndex - 1; $i < $this->endIndex; $i++) {
-            $type = $this->searchData['results'][$i]['objectType'];
-            $objectID = $this->searchData['results'][$i]['objectID'];
-
-            if (!isset($types[$type])) {
-                $types[$type] = [];
-            }
-            $types[$type][] = $objectID;
-        }
-
-        foreach ($types as $type => $objectIDs) {
-            $objectType = SearchEngine::getInstance()->getObjectType($type);
-            $objectType->cacheObjects($objectIDs, ($this->searchData['additionalData'][$type] ?? null));
-        }
-    }
-
-    /**
-     * Reads the data of the search result messages.
-     */
-    protected function readMessages()
-    {
-        for ($i = $this->startIndex - 1; $i < $this->endIndex; $i++) {
-            $type = $this->searchData['results'][$i]['objectType'];
-            $objectID = $this->searchData['results'][$i]['objectID'];
-
-            $objectType = SearchEngine::getInstance()->getObjectType($type);
-            if (($message = $objectType->getObject($objectID)) !== null) {
-                if (!($message instanceof ISearchResultObject)) {
-                    throw new ImplementationException(\get_class($message), ISearchResultObject::class);
-                }
-
-                $this->messages[] = $message;
-            }
-        }
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function countItems()
-    {
-        // call countItems event
-        EventHandler::getInstance()->fireAction($this, 'countItems');
-
-        return \count($this->searchData['results']);
-    }
-
-    /**
-     * @inheritDoc
-     */
-    protected function initObjectList()
-    {
-    }
-
-    /**
-     * @inheritDoc
-     */
-    protected function readObjects()
-    {
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function __run()
-    {
-        throw new IllegalLinkException();
-    }
-}
index 421e1b1d5449fed009d53426deac642f09b8ec20..8427864e26fbb66020d0022c7dabc636036eaa93 100644 (file)
@@ -119,15 +119,4 @@ abstract class AbstractSearchProvider extends AbstractObjectTypeProcessor implem
     {
         return '';
     }
-
-    /**
-     * @deprecated 5.5
-     */
-    public function getOuterSQLQuery(
-        string $q,
-        ?PreparedStatementConditionBuilder &$searchIndexConditions = null,
-        ?PreparedStatementConditionBuilder &$additionalConditions = null
-    ): string {
-        return $this->getFetchObjectsQuery($additionalConditions);
-    }
 }
diff --git a/wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php b/wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php
deleted file mode 100644 (file)
index 5f4b68e..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-<?php
-
-namespace wcf\system\search;
-
-use wcf\data\object\type\AbstractObjectTypeProcessor;
-use wcf\form\IForm;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-
-/**
- * This class provides default implementations for the ISearchableObjectType interface.
- *
- * @author  Marcel Werk
- * @copyright   2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @deprecated 5.5
- */
-abstract class AbstractSearchableObjectType extends AbstractObjectTypeProcessor implements ISearchableObjectType
-{
-    /**
-     * @inheritDoc
-     */
-    public function show(?IForm $form = null)
-    {
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function getApplication()
-    {
-        $classParts = \explode('\\', static::class);
-
-        return $classParts[0];
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function getConditions(?IForm $form = null)
-    {
-        return null;
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function getJoins()
-    {
-        return '';
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function getSubjectFieldName()
-    {
-        return $this->getTableName() . '.subject';
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function getUsernameFieldName()
-    {
-        return $this->getTableName() . '.username';
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function getTimeFieldName()
-    {
-        return $this->getTableName() . '.time';
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function getAdditionalData()
-    {
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function isAccessible()
-    {
-        return true;
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function getFormTemplateName()
-    {
-        return '';
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function getOuterSQLQuery(
-        $q,
-        ?PreparedStatementConditionBuilder &$searchIndexConditions = null,
-        ?PreparedStatementConditionBuilder &$additionalConditions = null
-    ) {
-        return '';
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function setLocation()
-    {
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function getActiveMenuItem()
-    {
-        return '';
-    }
-}
diff --git a/wcfsetup/install/files/lib/system/search/ISearchableObjectType.class.php b/wcfsetup/install/files/lib/system/search/ISearchableObjectType.class.php
deleted file mode 100644 (file)
index 3e0d3a4..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-<?php
-
-namespace wcf\system\search;
-
-use wcf\data\search\ISearchResultObject;
-use wcf\form\IForm;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-
-/**
- * All searchable object types should implement this interface.
- *
- * @author  Marcel Werk
- * @copyright   2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @deprecated 5.5
- */
-interface ISearchableObjectType
-{
-    /**
-     * Caches the data for the given object ids.
-     *
-     * @param array $objectIDs
-     * @param array $additionalData
-     */
-    public function cacheObjects(array $objectIDs, ?array $additionalData = null);
-
-    /**
-     * Returns the object with the given object id.
-     *
-     * @param int $objectID
-     * @return  ISearchResultObject
-     */
-    public function getObject($objectID);
-
-    /**
-     * Shows the form part of this object type.
-     *
-     * @param IForm $form instance of the form class where the search has taken place
-     */
-    public function show(?IForm $form = null);
-
-    /**
-     * Returns the application abbreviation.
-     *
-     * @return  string
-     */
-    public function getApplication();
-
-    /**
-     * Returns the search conditions of this message type or `null` if no special search conditions are necessary.
-     *
-     * @param IForm $form
-     * @return  PreparedStatementConditionBuilder|null
-     */
-    public function getConditions(?IForm $form = null);
-
-    /**
-     * Provides the ability to add additional joins to sql search query.
-     *
-     * @return  string
-     */
-    public function getJoins();
-
-    /**
-     * Returns the database table name of this message.
-     *
-     * @return  string
-     */
-    public function getTableName();
-
-    /**
-     * Returns the database field name of the message id.
-     *
-     * @return  string
-     */
-    public function getIDFieldName();
-
-    /**
-     * Returns the database field name of the subject field.
-     *
-     * @return  string
-     */
-    public function getSubjectFieldName();
-
-    /**
-     * Returns the database field name of the username.
-     *
-     * @return  string
-     */
-    public function getUsernameFieldName();
-
-    /**
-     * Returns the database field name of the time.
-     *
-     * @return  string
-     */
-    public function getTimeFieldName();
-
-    /**
-     * Returns additional search information.
-     *
-     * @return  mixed
-     */
-    public function getAdditionalData();
-
-    /**
-     * Returns true if the current user can use this searchable object type.
-     *
-     * @return  bool
-     */
-    public function isAccessible();
-
-    /**
-     * Returns the name of the form template for this object type.
-     *
-     * @return  string
-     */
-    public function getFormTemplateName();
-
-    /**
-     * Replaces the outer SQL query with a custom version. Querying the search index requires the
-     * placeholder {WCF_SEARCH_INNER_JOIN} within an empty INNER JOIN() statement.
-     *
-     * @param string $q
-     * @param PreparedStatementConditionBuilder $searchIndexConditions
-     * @param PreparedStatementConditionBuilder $additionalConditions
-     * @return  string
-     */
-    public function getOuterSQLQuery(
-        $q,
-        ?PreparedStatementConditionBuilder &$searchIndexConditions = null,
-        ?PreparedStatementConditionBuilder &$additionalConditions = null
-    );
-
-    /**
-     * Sets the location in menu/breadcrumbs.
-     *
-     * @since   3.0
-     */
-    public function setLocation();
-
-    /**
-     * Returns the name of the active main menu item.
-     *
-     * @return  string
-     * @deprecated  3.0
-     */
-    public function getActiveMenuItem();
-}
index f7aacb99671d8639d4787cf3de915faa0fd16009..92146d8b87eab1b53bcc5e4e7321aa4210aa9ce7 100644 (file)
@@ -25,7 +25,7 @@ class SearchEngine extends SingletonFactory implements IContextAwareSearchEngine
 
     /**
      * list of available object types
-     * @var ISearchableObjectType[]|ISearchProvider[]
+     * @var ISearchProvider[]
      */
     protected $availableObjectTypes = [];
 
@@ -53,7 +53,7 @@ class SearchEngine extends SingletonFactory implements IContextAwareSearchEngine
     /**
      * Returns a list of available object types.
      *
-     * @return  ISearchableObjectType[]|ISearchProvider[]
+     * @return  ISearchProvider[]
      */
     public function getAvailableObjectTypes()
     {
@@ -64,7 +64,7 @@ class SearchEngine extends SingletonFactory implements IContextAwareSearchEngine
      * Returns the object type with the given name.
      *
      * @param string $objectTypeName
-     * @return  ISearchableObjectType|ISearchProvider|null
+     * @return  ISearchProvider|null
      */
     public function getObjectType($objectTypeName)
     {
index 5af689ff7059642be746afe343034ae8366aa3d9..c683f4a14fb9ec32b02e8b33acd49fd934692539 100644 (file)
@@ -6,7 +6,6 @@ use wcf\data\search\keyword\SearchKeywordAction;
 use wcf\data\search\Search;
 use wcf\data\search\SearchAction;
 use wcf\data\user\UserList;
-use wcf\form\SearchForm;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\exception\PermissionDeniedException;
 use wcf\system\language\LanguageFactory;
@@ -175,8 +174,6 @@ final class SearchHandler
 
     private function buildTypeBasedConditionBuilders(): void
     {
-        $form = $this->getSearchFormEmulation();
-
         foreach ($this->objectTypeNames as $key => $objectTypeName) {
             $objectType = SearchEngine::getInstance()->getObjectType($objectTypeName);
 
@@ -185,26 +182,20 @@ final class SearchHandler
                     throw new PermissionDeniedException();
                 }
 
-                if ($objectType instanceof ISearchProvider) {
-                    $parameters = \count($this->objectTypeNames) === 1 ? $this->parameters : [];
-                    if (($conditionBuilder = $objectType->getConditionBuilder($parameters)) !== null) {
-                        $this->typeBasedConditionBuilders[$objectTypeName] = $conditionBuilder;
-                    }
-
-                    if (
-                        \count($this->objectTypeNames) === 1
-                        && ($newSortField = $objectType->getCustomSortField($this->parameters['sortField']))
-                    ) {
-                        $this->parameters['sortField'] = $newSortField;
-                    }
-
-                    if ($objectType instanceof IContextAwareSearchProvider) {
-                        $this->typeBasedContextFilter[$objectTypeName] = $objectType->getContextFilter($parameters);
-                    }
-                } else {
-                    if (($conditionBuilder = $objectType->getConditions($form)) !== null) {
-                        $this->typeBasedConditionBuilders[$objectTypeName] = $conditionBuilder;
-                    }
+                $parameters = \count($this->objectTypeNames) === 1 ? $this->parameters : [];
+                if (($conditionBuilder = $objectType->getConditionBuilder($parameters)) !== null) {
+                    $this->typeBasedConditionBuilders[$objectTypeName] = $conditionBuilder;
+                }
+
+                if (
+                    \count($this->objectTypeNames) === 1
+                    && ($newSortField = $objectType->getCustomSortField($this->parameters['sortField']))
+                ) {
+                    $this->parameters['sortField'] = $newSortField;
+                }
+
+                if ($objectType instanceof IContextAwareSearchProvider) {
+                    $this->typeBasedContextFilter[$objectTypeName] = $objectType->getContextFilter($parameters);
                 }
             } catch (PermissionDeniedException $e) {
                 unset($this->objectTypeNames[$key]);
@@ -213,32 +204,6 @@ final class SearchHandler
         }
     }
 
-    /**
-     * Will be removed with 6.0 once all search providers have switched to ISearchProvider.
-     * @deprecated 5.5
-     */
-    private function getSearchFormEmulation(): SearchForm
-    {
-        foreach ($this->parameters as $key => $value) {
-            $_POST[$key] = $value;
-        }
-
-        $form = new SearchForm();
-        $form->readFormParameters();
-        $form->userIDs = $this->getUserIDs();
-        if (\count($form->selectedObjectTypes) === 1) {
-            $this->objectTypeNames = $form->selectedObjectTypes;
-        }
-        if ($form->sortField) {
-            $this->parameters['sortField'] = $form->sortField;
-        }
-        if ($form->sortOrder) {
-            $this->parameters['sortOrder'] = $form->sortOrder;
-        }
-
-        return $form;
-    }
-
     private function getUserIDs(): array
     {
         if ($this->userIDs === null) {
index 6507e055043c492ab5aa1c592aaaad9865ee11ea..e5fcc062792b73798041eae6a90ed7cabf5e6dc2 100644 (file)
@@ -4,7 +4,6 @@ namespace wcf\system\search;
 
 use wcf\data\search\ISearchResultObject;
 use wcf\data\search\Search;
-use wcf\page\SearchResultPage;
 use wcf\system\exception\ImplementationException;
 
 /**
@@ -125,31 +124,17 @@ final class SearchResultHandler
     {
         if (\count($this->searchData['objectTypeNames']) === 1) {
             $objectType = SearchEngine::getInstance()->getObjectType($this->searchData['objectTypeNames'][0]);
-            if ($objectType instanceof ISearchProvider) {
-                if (($templateName = $objectType->getResultListTemplateName())) {
-                    return [
-                        'templateName' => $templateName,
-                        'application' => $objectType->getApplication(),
-                    ];
-                }
+            if (($templateName = $objectType->getResultListTemplateName())) {
+                return [
+                    'templateName' => $templateName,
+                    'application' => $objectType->getApplication(),
+                ];
             }
         }
 
-        return $this->getLegacyTemplateName();
-    }
-
-    /**
-     * Will be removed with 6.0 once all search providers have switched to ISearchProvider.
-     * @deprecated 5.5
-     */
-    private function getLegacyTemplateName(): array
-    {
-        $page = new SearchResultPage();
-        $page->assignVariables();
-
         return [
-            'templateName' => $page->resultListTemplateName,
-            'application' => $page->resultListApplication,
+            'templateName' => 'searchResultList',
+            'application' => 'wcf',
         ];
     }
 }
index d267fc8cd35a5b7f8327740548209f7c80cd29c1..ba822cf6727f7ba53c52240abcf0dc8bc55e1562 100644 (file)
@@ -7,7 +7,6 @@ use wcf\system\database\exception\DatabaseQueryExecutionException;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\search\AbstractSearchEngine;
 use wcf\system\search\exception\SearchFailed;
-use wcf\system\search\ISearchProvider;
 use wcf\system\search\SearchEngine;
 use wcf\system\search\SearchIndexManager;
 use wcf\system\WCF;
@@ -63,12 +62,7 @@ class MysqlSearchEngine extends AbstractSearchEngine
                 $sql .= "\nUNION ALL\n";
             }
             $additionalConditionsConditionBuilder = ($additionalConditions[$objectTypeName] ?? null);
-
-            if ($objectType instanceof ISearchProvider) {
-                $query = $objectType->getFetchObjectsQuery($additionalConditionsConditionBuilder);
-            } else {
-                $query = $objectType->getOuterSQLQuery($q, $searchIndexCondition, $additionalConditionsConditionBuilder);
-            }
+            $query = $objectType->getFetchObjectsQuery($additionalConditionsConditionBuilder);
             if (empty($query)) {
                 $query = "
                     SELECT      " . $objectType->getIDFieldName() . " AS objectID,
@@ -203,8 +197,7 @@ class MysqlSearchEngine extends AbstractSearchEngine
                 // - the word is quoted.
                 if (
                     !$this->isStopWord($word)
-                    && (
-                        $word[0] === '"'
+                    && ($word[0] === '"'
                         || \strlen($word) >= $this->getMinTokenSize()
                     )
                 ) {