[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Search: prevent invalid relevance scores after creating MySQL full-text indexes
"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]> Wed, 22 Jul 2026 12:35:36 +0000
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6a60b918ae519_3819d17456817@gitlab-sidekiq-low-urgency-cpu-bound-v2-7d8cd68bcd-k28hc.mail> |
Victor Emanouilov pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
dd8e0a33 by MAGENE Sem Joel at 2026-07-22T12:18:31+00:00
[FIX] Search: prevent invalid relevance scores after creating MySQL full-text indexes
---
* [FIX] Search: prevent invalid relevance scores after creating MySQL full-text indexes
See merge request tikiwiki/tiki!10751
- - - - -
1 changed file:
- lib/core/Search/MySql/Table.php
Changes:
=====================================
lib/core/Search/MySql/Table.php
=====================================
@@ -37,6 +37,7 @@ class Search_MySql_Table extends TikiDb_Table
private $schemaBuffer;
private $dataBuffer;
private $tfTranslator;
+ private $fullTextTablesToAnalyze = [];
private $max_columns_per_table = -1;
@@ -493,12 +494,14 @@ class Search_MySql_Table extends TikiDb_Table
$this->schemaBuffer->push("ADD FULLTEXT INDEX $escapedIndex ($escapedField)");
// InnoDB presently supports one FULLTEXT index creation at a time
$this->schemaBuffer->flush();
+ $this->fullTextTablesToAnalyze[$this->definition[$fieldName]['table']] = true;
}
private function emptyBuffer()
{
$this->schemaBuffer->clear();
$this->dataBuffer->clear();
+ $this->fullTextTablesToAnalyze = [];
}
private function addToBuffer($table, $keySet, $valueSet)
@@ -513,6 +516,26 @@ class Search_MySql_Table extends TikiDb_Table
{
$this->schemaBuffer->flush();
$this->dataBuffer->flush();
+
+ /*
+ * Tiki creates FULLTEXT indexes lazily, after the search table has been populated.
+ * On affected MySQL and MariaDB versions, adding another FULLTEXT index can make an
+ * existing MATCH() return an invalid relevance value. Using that value in Tiki's
+ * weighted score calculation then fails with "DOUBLE value is out of range"
+ * (error 1690, SQLSTATE 22003).
+ *
+ * MySQL tracks this trigger and error in https://bugs.mysql.com/bug.php?id=118535.
+ * ANALYZE TABLE is a tested workaround for Tiki's MySQL/MariaDB backend, not a
+ * permanent upstream fix.
+ */
+ foreach (array_keys($this->fullTextTablesToAnalyze) as $table) {
+ $table = $this->escapeIdentifier($table);
+ $this->db->query(
+ "ANALYZE TABLE $table",
+ options: [TikiDb::QUERY_OPTION_LOG_GROUP => self::UNIFIED_MYSQL_WRITE_LOG_GROUP]
+ );
+ }
+ $this->fullTextTablesToAnalyze = [];
}
private function calculateMaxColumnsPerTable()
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/dd8e0a336c23a484a5cf4e99db73c76263c6be3b
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/dd8e0a336c23a484a5cf4e99db73c76263c6be3b
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs