From: Alexander Ebert Date: Thu, 10 Jan 2019 19:36:30 +0000 (+0100) Subject: Use the highlight parameter to start a new search if the result is unavailable X-Git-Tag: 5.2.0_Alpha_1~365^2~13 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=20fe91318f92e8ee4c80bf3fb6e3a39e44ae503b;p=GitHub%2FWoltLab%2FWCF.git Use the highlight parameter to start a new search if the result is unavailable See #2792 --- diff --git a/wcfsetup/install/files/lib/page/SearchResultPage.class.php b/wcfsetup/install/files/lib/page/SearchResultPage.class.php index 7d56638b42..ea04dee6a5 100644 --- a/wcfsetup/install/files/lib/page/SearchResultPage.class.php +++ b/wcfsetup/install/files/lib/page/SearchResultPage.class.php @@ -8,14 +8,16 @@ 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-2018 WoltLab GmbH + * @copyright 2001-2019 WoltLab GmbH * @license GNU Lesser General Public License * @package WoltLabSuite\Core\Page */ @@ -47,7 +49,7 @@ class SearchResultPage extends MultipleLinkPage { * search object * @var Search */ - public $search = null; + public $search; /** * messages @@ -59,7 +61,7 @@ class SearchResultPage extends MultipleLinkPage { * search data * @var array */ - public $searchData = null; + public $searchData; /** * result list template @@ -83,16 +85,33 @@ class SearchResultPage extends MultipleLinkPage { if (isset($_REQUEST['id'])) $this->searchID = intval($_REQUEST['id']); $this->search = new Search($this->searchID); if (!$this->search->searchID || $this->search->searchType != 'messages') { - throw new IllegalLinkException(); + $this->redirectOrReject(); + } if ($this->search->userID && $this->search->userID != WCF::getUser()->userID) { - throw new IllegalLinkException(); + $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 */