- ๐ณ๐ฟNew Zealand quietone
I tested on Drupal 11.x and, using the steps in the Issue Summary, I can confirm the problem still exists.
- ๐ท๐บRussia zniki.ru
zniki.ru โ made their first commit to this issueโs fork.
- Status changed to Needs work
about 1 year ago 1:02pm 12 November 2023 - ๐ท๐บRussia zniki.ru
Provided tests to display described issue.
I created draft MR. - First commit to issue fork.
- Status changed to Needs review
9 months ago 4:31pm 27 April 2024 - ๐ฎ๐ณIndia sukr_s
I'm not seeing an option to remove the draft status from MR.
- ๐ฎ๐ณIndia sukr_s
sukr_s โ changed the visibility of the branch 3208247-after-deleting-a to hidden.
- ๐ฎ๐ณIndia sukr_s
unable to change the draft status in MR so reverted the changes and created a new mr.
- Status changed to Needs work
9 months ago 4:47pm 28 April 2024 - ๐บ๐ธUnited States smustgrave
Not sure a hook is the best place for this. There's NodeSearch.php shouldn't that leveraged to handle a deletion. Or does content_translation need a search plugin as well?
- Status changed to Needs review
9 months ago 6:52am 29 April 2024 - ๐ฎ๐ณIndia sukr_s
When a node is deleted, it's removed from the search index in the node::preDelete event. It's not handled by NodeSearch or content_moderation. On the same lines when a translation is deleted, it must be removed from the search index using the translation_delete hook.
- Status changed to Needs work
9 months ago 12:40pm 30 April 2024 - ๐บ๐ธUnited States smustgrave
Still think there could be a better way to go about it. But at a minimum believe the change and test should belong in the search module. Not all sites use the search module and even though this hook wouldnโt do anything it will still get called every translation deletion.
- Status changed to Needs review
9 months ago 4:29am 1 May 2024 - ๐ฎ๐ณIndia sukr_s
w.r.t to alternate approach to solve this, it would be far more expensive to find what was deleted in a cron run e.g. run though list of languages configured for the site, then the list of languages currently available to for the node and then to clear the index for missing languages. So I believe it's best done at the time of deletion.
I also think that this should be in search module. However this would result in hard coding the type node_search (used in clear method) in search module which would not be right since search module does not own the 'node_search' plugin. I could not find a method to dynamically determine the search plugin type based on entity type. Therefore chose to place it in the node module.
is it possible to find search plugin type based on entity type or is it ok to hard code the type in search module?
- ๐บ๐ธUnited States smustgrave
Will see if the sub maintainer takes a look in a few weeks.
- ๐บ๐ธUnited States pwolanin
Node module is also responding to various changes in hooks (e.g. comment update) and calling
node_reindex_node_search()
This feels like a similar case, so I think the approach in the MR is reasonable given the limitations of the system.
- Status changed to RTBC
9 months ago 3:16pm 8 May 2024 - ๐บ๐ธUnited States smustgrave
Thanks @pwolanin for taking a look!
https://git.drupalcode.org/issue/drupal-3208247/-/jobs/1453892 shows the test coverage
Applied 1 more nitpicky change but this got sign off from the sub-maintainer so seems fine solution that addresses the problem.
- Status changed to Needs work
9 months ago 4:30pm 8 May 2024 - ๐บ๐ธUnited States smustgrave
smustgrave โ changed the visibility of the branch 11.x to hidden.
- Status changed to RTBC
9 months ago 5:26pm 8 May 2024 - ๐บ๐ธUnited States smustgrave
I have 0 idea how the suggestion of :void broke so many tests. But started a new MR as the branch name 11.x wasn't good for local (since that's the main branch). Applied the suggestion by @alexpott and tests are green again.
Still very weird.
- ๐ฌ๐งUnited Kingdom alexpott ๐ช๐บ๐
I think we should open a follow-up to add a post update to clean up the incorrect data. This issue stops the rot but the bogus data hangs about.
- ๐บ๐ธUnited States smustgrave
Opened ๐ Post update for clearing search index of deleted translations Active
- Status changed to Needs work
9 months ago 5:46pm 10 May 2024 - ๐ฌ๐งUnited Kingdom catch
Actually two questions.
Nodes are marked for reindex in Node::postSave()
// Reindex the node when it is updated. The node is automatically indexed // when it is added, simply by being added to the node table. if ($update) { node_reindex_node_search($this->id()); }
If we could detect that a translation is being deleted there (can we?) then we would not need to mark the node for indexing, and then delete it again in the hook implementation added here.
Or... is there somewhere else that has this information instead?
- Status changed to RTBC
9 months ago 4:51am 13 May 2024 - ๐ฎ๐ณIndia sukr_s
changed to postsave and invoking
node_reindex_node_search($this->id());
only if the translation was not deleted. - Status changed to Needs work
9 months ago 7:15am 13 May 2024 - ๐ฌ๐งUnited Kingdom alexpott ๐ช๐บ๐
Left a comment on the MR. I think we need to always mark for reindex. The reindexing is not language specific but doing this is not going to recreate any row.
- Status changed to RTBC
9 months ago 8:40am 13 May 2024 - Status changed to Fixed
8 months ago 12:54pm 23 May 2024 - ๐ฌ๐งUnited Kingdom catch
Committed/pushed to 11.x and cherry-picked back through to 10.3.x, thanks!
- Status changed to Needs work
8 months ago 7:03am 24 May 2024 - ๐ฌ๐งUnited Kingdom catch
I missed a test failure in the last pipeline here, which then broke HEAD, reverted from all four branches.
- Status changed to Needs review
8 months ago 8:09am 29 May 2024 - ๐ฎ๐ณIndia sukr_s
"commit db83ea46 - Better names and no need to pass translations around" broke the fix, which has now been resolved by reverting the relevant changes.
- Status changed to RTBC
8 months ago 2:41pm 29 May 2024 - ๐ณ๐ฟNew Zealand quietone
I read the issue summary, comments and the MR. The found two things that need attention
2) This needs a follow up for https://git.drupalcode.org/project/drupal/-/merge_requests/7966#note_310136 - ๐ฌ๐งUnited Kingdom alexpott ๐ช๐บ๐
@quietone the approach changed after that comment and is no longer relevant.
- ๐ฌ๐งUnited Kingdom alexpott ๐ช๐บ๐
I've moved the private function to be inline - keeping old translation objects around after \Drupal\Core\Entity\ContentEntityBase::postSave feels wrong.
- Status changed to Needs review
8 months ago 12:02am 13 June 2024 - ๐ฆ๐บAustralia larowlan ๐ฆ๐บ๐.au GMT+10
Left a comment on the MR - is there really no way to do this from search module or similar, putting it in a specific entity class feels wrong - what about other translatable nodes?
- ๐ฌ๐งUnited Kingdom catch
@larowlan all the search integration for nodes is in node module, like the NodeSearch plugin. I agree it would be much nicer if search module had entity support which was then enabled for nodes by default, but for now this should stay with the rest of the integration.
- Status changed to RTBC
7 months ago 12:11pm 13 June 2024 - ๐ณ๐ฟNew Zealand quietone
I tested this on 11.x today and found that this does remove the deleted item from the search index, but only after a cron run. It still adds it to the search index, so that the search page shows
98% of the site has been indexed. There is 1 item left to index.
after the deletion. That is incorrect. And not what I expected from reading the issue title and summary. I expected search to not want to re-index it.There are the steps I used with the diff applied.
- admin/config/search/pages - 100% of the site has been indexed. There are 0 items left to index.
- Create article
- admin/config/search/pages - 98% of the site has been indexed. There is 1 item left to index.
- Run cron
- admin/config/search/pages - 100% of the site has been indexed. There are 0 items left to index.
- Add translation
- admin/config/search/pages - 98% of the site has been indexed. There is 1 item left to index.
- Run cron
- admin/config/search/pages - 100% of the site has been indexed. There are 0 items left to index.
- Delete translation
- admin/config/search/pages - 98% of the site has been indexed. There is 1 item left to index.
- Run cron
- admin/config/search/pages - 100% of the site has been indexed. There are 0 items left to index.
If my testing is confirmed correct then it looks like a follow up is needed for correcting the information on /admin/config/search/pages. Or have I misunderstood something again on this issue?
- ๐ฎ๐ณIndia sukr_s
When any translation is removed, the original content is also added for index. This behaviour has not changed. Pervious to this fix, after the cron run the original article would get reindexed but the removed translation would be left hanging and still gets reported as "1 item requires indexing".
After this fix, the translation is removed from the index therefore before the cron run it shows 1 item which is the original article and after the cron run, it's zero items. - Status changed to Fixed
7 months ago 10:16am 5 July 2024 - ๐ฌ๐งUnited Kingdom catch
#60 makes sense to me, the entity will be re-indexed but the translation won't.
Since this caused a regression before, committed to 11.1.x and cherry-picked to 10.4.x, thanks!
Automatically closed - issue fixed for 2 weeks with no activity.