[5.4] Fix duplicate term index error in com_finder by excluding existing terms#47472
Closed
SRV-KILLER09 wants to merge 1 commit intojoomla:5.4-devfrom
Closed
[5.4] Fix duplicate term index error in com_finder by excluding existing terms#47472SRV-KILLER09 wants to merge 1 commit intojoomla:5.4-devfrom
SRV-KILLER09 wants to merge 1 commit intojoomla:5.4-devfrom
Conversation
Contributor
|
Thanks for the PR, could you imagine to make a new one for 6.2 with your fix and additional refactoring for the DB query stuff like here (not tested): $select = $db->getQuery(true)
->select([
'ta.term',
'ta.stem',
'ta.common',
'ta.phrase',
'ta.term_weight',
'SOUNDEX(ta.term) AS soundex',
'ta.language',
])
->from($db->quoteName('#__finder_tokens_aggregate', 'ta'))
->leftJoin($db->quoteName('#__finder_terms', 'ft'), 'ft.term = ta.term AND ft.language = ta.language')
->where($db->quoteName('ta.term_id') . ' = :termid')
->andWhere('ft.term_id IS NULL')
->group($db->quoteName('ta.term') . ', ' . $db->quoteName('ta.stem') . ', ' . $db->quoteName('ta.common') . ', ' . $db->quoteName('ta.phrase') . ', ' . $db->quoteName('ta.term_weight') . ', SOUNDEX(ta.term), ' . $db->quoteName('ta.language'));
$insert = $db->getQuery(true)
->insert($db->quoteName('#__finder_terms'))
->columns([
$db->quoteName('term'),
$db->quoteName('stem'),
$db->quoteName('common'),
$db->quoteName('phrase'),
$db->quoteName('weight'),
$db->quoteName('soundex'),
$db->quoteName('language'),
])
->select($select);
$select->bind(':termid', 0, ParameterType::INTEGER);
$db->setQuery($insert);
$db->execute();It would be a good time to do it now that we're already working on it. |
Contributor
|
I have tested this item 🔴 unsuccessfully on 9c93e82
No error on indexing This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/47472. |
5 tasks
Author
|
Hii! Thanks for the review feedback..!! and As requested, I've opened a new PR (#47531) targeting 6.2-dev with the query-builder refactor and regression test coverage. Thankyou! |
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.
Pull Request resolves #47447
Summary of Changes
This PR fixes an issue in the Finder indexer where duplicate term entries could cause the indexing process to fail.
The INSERT query in
administrator/components/com_finder/src/Indexer/Indexer.phphas been updated to prevent duplicate term errors. A LEFT JOIN is added to the#__finder_termstable along with anIS NULLcondition, ensuring that only terms that don’t already exist are inserted.Changed file:
administrator/components/com_finder/src/Indexer/Indexer.php— updated INSERT query to safely handle duplicatesTesting Instructions
Before this fix:
Indexing stops with the error:
Duplicate entry
X-*for keyidx_term_languageAfter this fix:
Indexing completes successfully, and duplicate terms are handled without errors.
Actual Result (Before this PR)
When content includes terms that normalize to the same value (such as accented vs. non-accented versions), the Finder indexer attempts to insert duplicate entries into the
#__finder_termstable.This causes a database error:
Duplicate entry
X-*for keyidx_term_languageAs a result, the indexing process stops entirely, and the search index remains incomplete.
Expected Result (After this PR)
Indexing completes successfully even when duplicate normalized terms are present.
IS NULLcondition).Result: More reliable and error-free indexing across supported databases (MySQL, PostgreSQL, SQL Server).
Link to Documentation
Please select:
Documentation link for guide.joomla.org:
No documentation changes needed for guide.joomla.org
Pull Request link for manual.joomla.org:
No documentation changes needed for manual.joomla.org