Implicit FULLTEXT indexes from e_search#5566
Open
Deltik wants to merge 1 commit intoe107inc:masterfrom
Open
Conversation
After the migration from MyISAM to InnoDB (issue e107inc#4501), the search functionality broke because InnoDB requires explicit FULLTEXT indexes, while MyISAM supported them implicitly. This commit introduces automatic detection and creation of FULLTEXT indexes based on the `search_fields` configuration in e_search addons: ## New Components - `e_search_fulltext_indexer_class.php`: Parses e_search addon configs to derive required FULLTEXT indexes. Handles complex table aliases and JOIN clauses to map search fields to their actual tables. ## Changes to Existing Components - `db_verify_class.php`: - Integrates the FULLTEXT indexer into the comparison flow - `init(true)` now clears all dependent caches (MySQL table list, core preferences, and db_verify's own cache) for programmatic use - Missing FULLTEXT indexes are detected and can be fixed via the existing db_verify repair mechanism - `plugin_class.php`: - New `createSearchIndexes()` method called during plugin installation - Automatically creates FULLTEXT indexes for plugins with e_search addons immediately after table creation - `install.php`: - Creates FULLTEXT indexes for core e_search addons during fresh installation ## How It Works 1. When db_verify compares tables, it calls `getSearchFieldIndexes()` 2. The indexer loads all e_search addon configs via `getAddonConfig()` 3. For each config, it parses the `table` clause to extract table/alias mappings (handling JOINs like `news AS n LEFT JOIN #user AS u ON...`) 4. It maps `search_fields` (e.g., `n.news_title`) to actual table.column 5. Generates FULLTEXT index definitions with naming convention `ft_{table}_{column}` 6. These derived indexes are merged with file-defined indexes for comparison ## Testing - Unit tests for the FULLTEXT indexer (19 tests) - Integration test verifying plugin installation creates indexes - Manual testing with forum plugin installation via web interface Fixes: e107inc#5209
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
After the migration from MyISAM to InnoDB (#4501), the search functionality broke with the error:
This is because InnoDB requires explicit FULLTEXT indexes while MyISAM supported FULLTEXT search implicitly. Users reported that searching for content in news, downloads, forums, and other areas returned no results (#5209).
The workaround was to manually run
ALTER TABLE ... ADD FULLTEXTfor each search field, but this is error-prone and requires database expertise.Fixes: #5209
Description
This PR introduces automatic detection and creation of FULLTEXT indexes based on the
search_fieldsconfiguration ine_searchaddons.New Components:
e_search_fulltext_indexer_class.php: Parsese_searchaddon configs to derive required FULLTEXT indexes. Handles complex table aliases and JOIN clauses to map search fields to their actual tables.Changes to Existing Components:
db_verify_class.php:init(true)now clears all dependent caches (MySQL table list, core preferences, and db_verify's own cache) for programmatic useplugin_class.php:createSearchIndexes()method called during plugin installationinstall.php:How It Works:
getSearchFieldIndexes()getAddonConfig()tableclause to extract table/alias mappings (handling JOINs likenews AS n LEFT JOIN #user AS u ON...)search_fields(e.g.,n.news_title) to actual table.columnft_{table}_{column}For Existing Sites:
Users can go to Admin → Database → Verify SQL, select the affected plugins, and click "Fix Selected Items" to create the missing FULLTEXT indexes.
How Has This Been Tested?
Unit tests: 19 tests for the FULLTEXT indexer covering:
Integration test: Verifies that installing the forum plugin (which has e_search) automatically creates FULLTEXT indexes with no pending migrations afterward
Manual testing:
Types of Changes
Checklist