namespace wcf\system\search\mysql;
-use wcf\system\database\DatabaseException;
+use wcf\system\database\exception\DatabaseQueryExecutionException;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\SystemException;
use wcf\system\search\AbstractSearchEngine;
*/
protected $ftMinWordLen;
+ /**
+ * @var int
+ */
+ private $minTokenSize;
+
/**
* @inheritDoc
*/
protected function getFulltextMinimumWordLength()
{
if ($this->ftMinWordLen === null) {
- $sql = "SHOW VARIABLES LIKE 'innodb_ft_min_token_size'";
+ $this->ftMinWordLen = $this->getMinTokenSize();
+ }
+
+ return $this->ftMinWordLen;
+ }
+ private function getMinTokenSize(): int
+ {
+ if (!isset($this->minTokenSize)) {
try {
+ $sql = "SELECT @@innodb_ft_min_token_size";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
- $row = $statement->fetchArray();
- } catch (DatabaseException $e) {
- // fallback if user is disallowed to issue 'SHOW VARIABLES'
- $row = ['Value' => 3];
+ $this->minTokenSize = $statement->fetchSingleColumn();
+ } catch (DatabaseQueryExecutionException $e) {
+ $this->minTokenSize = 3;
}
-
- $this->ftMinWordLen = $row['Value'];
}
- return $this->ftMinWordLen;
+ return $this->minTokenSize;
}
}