This patch: http://drupal.org/node/176003 (Contrib module's hook_requirements are not called when installing) causes this error (as seen in Drupal 6) to appear for us: http://drupal.org/node/176003 (Installation failed w/ max execution time of 30 seconds)
What seems to happen is that we have a large number of default installed modules, These modules, on install, have each of their folders checked recursively for .module and .install files. These file existence checks are done about 38 times various ways in install.php.
A simple solution would be to add a max_depth parameter to file_scan_directory() in includes/file.inc since we can be fairly sure that there are no modules more than 3 folders deep inside of modules, sites/all/modules, or sites/default/modules. This solution would still allow modules that contain sub modules to function correctly.
I'll attach my simple patch, but it might require more in depth analysis by someone involved with the installer.
Normally, this isn't a problem on hosts with fast file systems, but as speed decreases, these file look-ups build up and cause the execution time to run out. Another solution would be to cache the look-ups after they are performed.
Comments
Comment #1
harking commentedComment #2
drummInteresting idea.. this is probably an issue in all versions of Drupal, so it is best to start with the development version, where more new code will get reviewed, and backport from there.
Are any of the files being checked twice?
Comment #3
dave reidPatch needs work, the extra parameter needs to be second to last, since the last parameter is used internally in the function to determine it's current recursion depth. There's also a call to file_scan_directory inside the function that needs to be changed as well.
Comment #4
drewish commentedit'd be great to postpone this until after #255551: DX: Array-itize file_scan_directory()'s parameters gets committed.
Comment #5
codecowboy commentedThe parameterizing is complete. Here's a new patch to get the ball rolling.
Comment #6
drewish commentedneed to document the new parameter and add unit tests.
Comment #7
superspring commentedI have rewritten this patch, including documentation and a test.
Comment #9
superspring commented#7: file_scan_directory_max_depth-343444-7.patch queued for re-testing.
Comment #11
superspring commentedSame patch as above for the new 8.x-dev.
Comment #12
tim.plunkettI would just have one comment above the function, and make it less conversational :) Though it does sound friendlier
This should still be JavaScript.
Start with "Checks"
----
The functional changes of this make sense.
Comment #13
superspring commentedThis new patch adds in Tim's review.
Comment #14
suns/number/integer/
This is RTBC after adjusting that.
Comment #15
sunThat said. On a second look:
Can we flip the second condition, so that it becomes
$depth > 'max_depth'?This inherently leads me to the question whether the condition shouldn't be
>=or not?Because it is not really clear for potential users of this function whether max_depth is inclusive or exclusive (unlike the min_depth argument, which is relatively clear), we should add an example to the phpDoc for the option that explains the effect on a hypothetical directory scan.
Additionally, the needs some more love, since it only verifies the special condition of 0, which of course won't ever return anything (but is still good to test, since that is a possible value, so let's keep that).
The test should additionally verify that scan that has files in depth = 0, depth = 1, as well as depth = 2, does not return files from depth = 2 if max_depth = 1.
E.g., you can scan /core/modules/node with the above parameters and you should only get files from:
/core/modules/node/*
/core/modules/node/templates/*
/core/modules/node/...
but not from:
/core/modules/node/lib/Drupal/...
Comment #16
superspring commentedSame as the patch above with the improved comments and additional tests.
Comment #17
sun1) This still does not clarify whether max_depth is inclusive or exclusive.
2) The particular case being described in the phpDoc is actually identical to the 'recurse' => FALSE option, so I don't think it makes sense to describe that case.
3) Given the above, I wonder whether it would even make sense to merge 'recurse' into 'max_depth'. We can potentially keep 'recurse' as a simple convenience helper option, but its only effect would be that 'max_depth' is set to 0 (zero).
Mmm... this will cause test failures for many other innocent patches in the queue ;)
Instead of testing the count, we should verify that the path names of the returned files are limited in the expected way; i.e., as outlined above, verifying that files up to a certain depth appear, but no files beyond that depth.
Comment #18
superspring commentedSo I've added some more to the documentation, merged the recurse option and changed the tests.
Comment #27
kim.pepperClosing as outdated. Please re-open if you feel this is still relevant.