Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
node system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
2 Jul 2025 at 09:48 UTC
Updated:
1 Aug 2025 at 07:14 UTC
Jump to comment: Most recent
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/node/...
The function node_reindex_node_search() is called from Node.php, mixing procedural code with object-oriented code. This doesn't align with modern Drupal practices.
Deprecate the node_reindex_node_search() function in node.module.
Move the search reindexing logic to a more appropriate place, into a proper hook such as hook_node_update()
node_reindex_node_search()Node.php, move into a #[Hook('node_update')] hook on NodeEntityHooksnode_reindex_node_search() will be deprecated.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
acbramley commentedThere is only 1 usage of this function according to http://codcontrib.hank.vps-private.net/search?text=node_reindex_node_sea... and that module doesn't have a release, looks unmaintained.
I don't think we need a replacement here, we'll just do all the work in a new Hooks file. Have updated the proposed solution.
Comment #5
libbna commentedHey, in #4 I have done the following changes:
Let me know if everything looks good or if any changes are needed, or if I’ve missed anything. I'm changing the status to "Needs Work" for now so the work can continue in case the pipeline fails or test cases need to be added.
Comment #6
acbramley commentedActioned feedback and fixed up linting.
Only thing I'm not sure on is if we should even mention the new replacement in the CR, it's in a Hooks class so it's a bit weird but it does technically mean there's a way to do it without us having to add yet another service.
Comment #7
berdirI'm generally not very fond of modules implementing their own entity hooks but I think this is a good example for when it makes sense: Optional integration with another module, this allows us to encapsulate and group all related hooks for that in one service. And with #3524377: Allow to skip OOP hooks and services for modules that are not installed, we plan to have a means for dynamically registering this hooks service only when the search module is installed, something that for now would either require a node_search glue module or custom ServiceProvider code.
And then with this we also have a real use case in core that we can test it with.
I think mentioning the replacement in the CR is fine, personally I wouldn't really have bothered with the Why section. Realistically speaking, we plan to deprecate basically all runtime procedural code by deprecating .module files, doesn't really matter where it's called from.
Comment #8
catchThe replacement doesn't seem right to me - asked a question on the MR. fwiw I'd also be fine with 'deprecated with no replacement'.
Comment #9
acbramley commentedAgreed, also made the hooks method protected.
Comment #10
catchCommitted/pushed to 11.x, thanks!