[TikiWiki-commits] [Git][tikiwiki/tiki][30.x] [BP][FIX] Search: prevent invalid relevance scores after creating MySQL full-text indexes
"MAGENE Sem Joel \(@Jomagene\) via TikiWiki-cvs" <[email protected]> Thu, 23 Jul 2026 13:05:45 +0000
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6a6211a9a4b0c_3819d0fc1038cb@gitlab-sidekiq-low-urgency-cpu-bound-v2-7d8cd68bcd-z4qmr.mail> |
MAGENE Sem Joel pushed to branch 30.x at Tiki Wiki CMS Groupware / Tiki
Commits:
34ab785f by MAGENE Sem Joel at 2026-07-23T12:58:23+00:00
[BP][FIX] Search: prevent invalid relevance scores after creating MySQL full-text indexes
---
* [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
(cherry picked from commit dd8e0a336c23a484a5cf4e99db73c76263c6be3b)
See merge request tikiwiki/tiki!10775
- - - - -
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;
@@ -489,12 +490,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)
@@ -509,6 +512,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/34ab785f5d28681b15a019159a06f633bfb23a7d
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/34ab785f5d28681b15a019159a06f633bfb23a7d
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