namespace wcf\system\search\mysql;
-use wcf\system\database\DatabaseException;
+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;
use wcf\system\search\SearchIndexManager;
use wcf\system\WCF;
$sql .= " ORDER BY " . $orderBy;
}
- // send search query
- $messages = [];
- $statement = WCF::getDB()->prepareStatement($sql, $limit);
- $statement->execute($parameters);
- while ($row = $statement->fetchArray()) {
- $messages[] = [
- 'objectID' => $row['objectID'],
- 'objectType' => $row['objectType'],
- ];
+ try {
+ $messages = [];
+ $statement = WCF::getDB()->prepareStatement($sql, $limit);
+ $statement->execute($parameters);
+ while ($row = $statement->fetchArray()) {
+ $messages[] = [
+ 'objectID' => $row['objectID'],
+ 'objectType' => $row['objectType'],
+ ];
+ }
+ } catch (DatabaseException $e) {
+ throw new SearchFailed('MySQL search query failed.', $e);
}
return $messages;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
$row = $statement->fetchArray();
- } catch (DatabaseException $e) {
+ } catch (LegacyDatabaseException $e) {
// fallback if user is disallowed to issue 'SHOW VARIABLES'
$row = ['Value' => 3];
}