Needs work
Project:
Drupal core
Version:
main
Component:
extension system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Dec 2025 at 12:01 UTC
Updated:
7 May 2026 at 16:41 UTC
Jump to comment: Most recent
Comments
Comment #5
quietone commentedHi, in Drupal core changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies. Thanks.
I am restoring standard issue template so we can track progress on this issue.
@dotoree, There are instructions for rebasing a merge request. on drupal.org.
Comment #8
berdirDo you have a backtrace for this error to see where it originates?
11.3 supports OOP hooks for themes, so that could be related, but that's only attributes, not annotations?
Instead of this, it should probably be higher up and respect the scan setting
Comment #9
dotoree commented@berdir here is the backtrace:
and some errors:
Comment #10
berdirOk, so it is confirmed to be Drupal\Core\Hook\ThemeHookCollectorPass.
That's where we should look into this. \Drupal\Core\Hook\ThemeHookCollectorPass::filterIterator and the ModuleHookCollectorPass() should respect the file scan setting. Probably doesn't hurt to add your extra check too, but I think that alone won't fix the possibly considerably performance issue here.
Using the Assigned field to ping @nicxvan.
Comment #11
nicxvan commentedYeah we should add node module's to the disallow list.
https://git.drupalcode.org/project/drupal/-/blob/main/core/lib/Drupal/Co...
https://git.drupalcode.org/project/drupal/-/blob/main/core/lib/Drupal/Co...
Those are the two places we need to update.
Comment #12
nicxvan commentedComment #15
nicxvan commentedI'm going to clean up the mr since it's against 11.3 and doesn't follow the approach we should take.
Comment #19
richard.thomas commentedAfter updating to 11.3, we noticed significant performance degradation when clearing caches on a development site with a very large node_modules folder inside our site theme.
It looks to be due to the theme hook scanning going through the entire folder structure.
I've pushed up a simple MR https://git.drupalcode.org/project/drupal/-/merge_requests/15629 to make both HookCollectorPass and ThemeHookCollectorPass respect the file_scan_ignore_directories setting by merging that into the default list of excluded directories they had.
Doesn't seem to cause any issues with the existing tests and my local testing shows a big speedup (~30sec down to ~4sec for a cache rebuild with a populated node_modules directory that is configured to be ignored).
I'll see if I can add a specific test for the ignore directories option.
Comment #20
richard.thomas commentedI've added a couple of tests to https://git.drupalcode.org/project/drupal/-/merge_requests/15629 to check that directories configured in settings are ignored for both theme and module hook collection.
Comment #21
berdirThis looks good I think, not sure extensive the tests should be, we're about to deprecate .theme files on main, which would require at least a small change either here.
Maybe we can just add a SkipDeprecations attribute and a todo to remove in D13 to the tests and test modules as I *think* we can remove this when we remove BC as we know all extension directories already so we will _only_ need to look at their src/Hooks folder then, which should significantly simplify this in D13 as we can directly and only process that directory.
Comment #23
nicxvan commentedYeah, I am tempted to just hardcode node_modules and bower_components.
The ignore file setting is for a different purpose and I'm not sure we should conflate this.
I'm not super convinced as I write this, so I think it's worth discussing.
Comment #24
richard.thomas commentedI'd definitely prefer to give developers the option to configure additional exclusions (or remove the defaults). We could add an additional setting I guess, but I feel like the existing file_scan_ignore_directories would cover the same use-case.
The description in default.settings.php is:
It does mention extensions, but I think it's serving much the same purpose as what we need here (marking directories that won't have any Drupal code in them so don't bother recursively scanning them).
Comment #25
nicxvan commentedI think you're right, but let's also take a moment to update the comment there too then.
Comment #26
richard.thomas commentedI've had a go at updating the comment in the default.settings.php file to better reflect what the setting is doing.
I've also marked the new tests with #[IgnoreDeprecations] for when procedural hooks are deprecated and added a TODO comment to the new test theme/module files to remove them when procedural hooks are removed.
Comment #27
nicxvan commentedI have a few more comments on the MR, this is getting close! Thanks for working on this!
Here is the gist of the changes requested:
The comment should preserve the bit about the file api since that is still accurate
We only need to test the ignore directory bit since we already have tests for collection hooks, so we can drop the included_directory directories
Don't worry about the deprecation ignore, we'll add that when necessary if that issue gets in first, and we would do it by adding the attribute, if this gets in first I'll update the other issue.