From e3c7ea846e0724edaa3ac286c5ed0f1ff27550dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 27 Aug 2021 12:06:07 +0200 Subject: [PATCH] Clean up the objectTypes emptiness check in MysqlSearchEngine --- .../lib/system/search/mysql/MysqlSearchEngine.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/system/search/mysql/MysqlSearchEngine.class.php b/wcfsetup/install/files/lib/system/search/mysql/MysqlSearchEngine.class.php index 9ddbe94a12..b8d6e46541 100644 --- a/wcfsetup/install/files/lib/system/search/mysql/MysqlSearchEngine.class.php +++ b/wcfsetup/install/files/lib/system/search/mysql/MysqlSearchEngine.class.php @@ -5,7 +5,6 @@ namespace wcf\system\search\mysql; use wcf\system\database\DatabaseException as LegacyDatabaseException; use wcf\system\database\exception\DatabaseException; use wcf\system\database\util\PreparedStatementConditionBuilder; -use wcf\system\exception\SystemException; use wcf\system\search\AbstractSearchEngine; use wcf\system\search\exception\SearchFailed; use wcf\system\search\SearchEngine; @@ -45,6 +44,10 @@ class MysqlSearchEngine extends AbstractSearchEngine $orderBy = 'time DESC', $limit = 1000 ) { + if (empty($objectTypes)) { + throw new \InvalidArgumentException('The $objectTypes parameter must not be empty.'); + } + // build search query $sql = ''; $parameters = []; @@ -97,9 +100,7 @@ class MysqlSearchEngine extends AbstractSearchEngine $sql .= $query; } - if (empty($sql)) { - throw new SystemException('no object types given'); - } + \assert(!empty($sql)); if (!empty($orderBy)) { $sql .= " ORDER BY " . $orderBy; -- 2.20.1