Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Since the function registry's gone out, there are quite a number of files that the registry can safely skip for parsing, but still appear in info files. This patch attempts to get em all out.
Did this all by hand, so there may well be some errors.
Comment | File | Size | Author |
---|---|---|---|
#20 | info-files-915174-20.patch | 2.82 KB | David_Rothstein |
#4 | drupal.info-files.4.patch | 54.51 KB | sun |
strip_unnecessary_file_declaration.patch | 18.58 KB | sdboyer | |
Comments
Comment #1
sunVery good idea. Some .module files need to be kept though, as they contain entity controller classes.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedstrip_unnecessary_file_declaration.patch queued for re-testing.
Comment #4
sunManually went through all module .info files throughout core and contextually double-checked which files[] declarations are actually needed.
Comment #5
sunLast patch passed.
Comment #6
moshe weitzman CreditAttribution: moshe weitzman commentedThis speeds up registry building with no ill side effects. And even if it did have a side effect, it is easily remedied.
Comment #7
moshe weitzman CreditAttribution: moshe weitzman commentedIt is important that core sets a good example here since the parsing will get really expensive if all contrib modules add all their files regardless of contents.
Comment #8
webchickI advocated doing this a long time ago and was shot down, on the grounds that having a full registry table of all compiled code could be useful to contrib. Removing it now would represent a regression from what's been in D7 for the entire life of its release since the registry patch was committed (roughly 2 years ago).
I don't see how we can do this now.
Comment #9
sdboyer CreditAttribution: sdboyer commentedUm - who shot it down? Can I argue with them? :) Really because, we don't have a fully compiled dataset of all the code in the drupal instance. The only thing about contents of files that are currently captured (in {registry}) are classes/interfaces, and only files that are explicitly included for parsing are listed in {registry_files}. So all we actually have is a list of files that happened to have been mentioned in a .info file or alter()d in. No contrib module could reasonably expect that the file list be either a) a complete list of all files (since afaik, it's not currently complete) or b) contain anything MORE than classes/interfaces. All this patch does is bring the actual dataset down in line with what that reasonable expectation. So, honestly, I don't get where the regression is.
Comment #10
moshe weitzman CreditAttribution: moshe weitzman commentedLets reserve the word regression to refer to a bug that existed, was fixed, and has now returned. This task does not represent a regression. This is a performance fix for drupal, and a low risk one at that. I get that we want to be conservative right before release but low risk performance fixes are always eligible, IMO.
Comment #11
sunI also don't think that the current information is of any substantial use for anyone. From a technical perspective, it is incomplete and insufficient. And if you'd really need all files, then a manual file_scan_directory() is much more faster than retrieving a manually compiled registry of files per module, which still needs to be completed because it's incomplete. It simply makes no sense. ;)
Also, on slow machines and/or file systems (especially Windows), there should be a larger performance impact, because every single file that is listed in files[] is
- checked for file_exists()
- checked for its file modification date
- possibly read into memory
- grepped for PHP OO constructs through a regular expression
upon registry rebuilds. Admittedly, registry rebuilds don't happen very often, but when they happen, the entire request is very slow anyway already, so it's definitely worth cut off any unnecessary overhead.
Comment #12
webchickI don't totally recall who it was who shot this down before, but it seems like a good idea to get chx to sign off on this patch. If he wasn't the person who shot it down, he at least did a lot of work to put the registry there in the first place.
Comment #13
webchickComment #14
chx CreditAttribution: chx commentedare the files that contain a class. Only system.queue.inc has an interface. I reviewed and these files are present in the info files after the patch.
Comment #15
webchickOk, I talked to Dries about this given how late it was, and he said:
"for the love of god, please commit that :)"
:D
I noticed at least one problem (dashboard.test is removed and shouldn't be). Could we get one more pass at this and then I can commit it later tonight?
Comment #16
sunum, but dashboard.test is not removed?
Powered by Dreditor.
Comment #17
webchickOh. I noticed another critical problem. With my reading comprehension level. I was reading Sam's patch and not yours. ;P~
Committed to HEAD. YAYYYY!!!
Now we need to update the documentation in about 50,000 places that you no longer need this stupid index.
Also tagging as an "API change" because this needs to be announced.
Randy: Change is that you no longer need the stupid files[] declaration in .info files unless you are defining a class. (so .test files, entity controllers, etc.) Someone else can likely come up with a better, more copy/pastable summary.
Comment #18
rfayYeah, I'd like more clear direction on how to announce:
"All files[] directives can be removed unless there is a class defined within. So you *can't* remove *.test or other files that provide a class definition" ???
But what files[] would have to remain?
Comment #19
sunThe
files[]
property in module .info files should only contain files that contain any PHP classes and/or interfaces. Most commonly, these are test classes, exception classes, select query extenders, or mail system implementations.Comment #20
David_Rothstein CreditAttribution: David_Rothstein commentedAwesome.
It looks like there are several more we can remove; I looked to see which .module files we had left after this (there are very few) and the attached patch removes the remaining obvious ones that don't have any classes or interfaces in them.
(Come to think of it, we could maybe just remove all .module files from the registry anyway, since they should never need to be autoloaded. But this patch doesn't go that far.)
Comment #21
sunoh, thanks, @David_Rothstein! Those modules must have been introduced along the way (or my checkout was stale, perhaps).
Comment #22
webchickCommitted to HEAD. Thanks!
Comment #23
jhodgdonThis also needs to be updated in the module dev guide for D7 in the Handbook, which I'm pretty sure said something about the files array in .info files (though I don't have the page handy).
Comment #24
David_Rothstein CreditAttribution: David_Rothstein commentedRight, I guess this is still "needs work" for documentation.
Comment #25
webchicksorry, my bad!
Comment #26
catchVery late to this one but woo!
Comment #27
jhodgdonIn the Module dev guide, the page on .info files already seems to be correct:
http://drupal.org/node/542202
It says you need files[] only for classes/interfaces.
Also, the 6/7 guide looks correct:
http://drupal.org/update/modules/6/7#registry
So, looks like the doc is updated.