by Crell's and eaton's requests i'm creating this issue.
the problem occurs when a module overrides admin/build/modules theme is being disabled.
during the disable process this module is still active and overrides the #theme attribute. then when page reloads and module is already disabled, the form is already altered and it tries to be rendered by the theme function that is specified in the #theme attribute by the disabled module. this causes notices and warnings to be displayed but everything else works 100%.
this problem was solved when i created hook_disable and ran drupal_rebuild_theme_registry inside of it. this however should be considered a hack.
themes, menus, and other system cached items should be rebuilt upon every module disable process.
Comment | File | Size | Author |
---|---|---|---|
#78 | clear.patch | 2.72 KB | moshe weitzman |
#60 | rebuilds-on-submit.D6.patch | 1 KB | stormsweeper |
#44 | system-modules-rebuild-on-submit-193366.patch | 3.34 KB | stormsweeper |
#41 | system-moles-rebuild-on-submit-193366.patch | 1.03 KB | stormsweeper |
#30 | 19336_rebuild_menu_on_modules_page_submission.patch | 579 bytes | Senpai |
Comments
Comment #1
eaton CreditAttribution: eaton commentedArguably, this sort of flush should appear when modules are enabled or disabled regardless of any other edge cases. Right now, we rely on the submit handler for the form, and that isn't always executed at the right time to make everything happen.
Comment #2
chx CreditAttribution: chx commentedSure. If there is a hook_menu_alter which plays with access or title callback you will be in trouble, I believe. So yes, this page needs to make a spring cleanup.
Comment #3
chx CreditAttribution: chx commentedGiven how trivial this patch is, I dare to RTBC it. We optimized and optimized... a page that is almost never loaded on a live site... until we have broken stuff. That's very bad optimization. Extra bonus: developers can just visit this page and get all their stuff recognized. Not bad.
Comment #4
Gábor HojtsySo we basically need to rebuild the caches before the form is handled, as the theme hook might be "scheduled to be called" before the submit handler and tried to be called after, when it is not available anymore? That's the problem?
Comment #5
eaton CreditAttribution: eaton commentedThat's correct. I have the feeling that this will bite us in a number of areas: update.php, module disabling, and so on.
Comment #6
Gábor HojtsyOK, committed.
Comment #7
sunQuestion (without knowing too much of update.php process): in update.php, shouldn't we link to admin/build/modules then after a database update instead of "Administration pages"?
Comment #8
(not verified) CreditAttribution: commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #9
moshe weitzman CreditAttribution: moshe weitzman commentedTHis patch turned out to be a bad idea IMO. The modules page is barely usable. See #311626: admin/build/modules very slow on some configurations. This contributes to the problem. Can we find an alternate solution and rollback this patch?
Comment #10
moshe weitzman CreditAttribution: moshe weitzman commentedFor starters, perhaps we only do a theme registry fix as the title of the issue suggests.
Comment #11
chx CreditAttribution: chx commentedAgreed and reopening.
Comment #12
sunFirst of all: Fix this in 7.x or 6.x? Unlike 6.x, admin/build/modules is pretty fast in 7.x. But OTOH, I always disliked this "magic" behavior triggered by _viewing_ this page, so I'd be +1 for removing it altogether.
Since 6.x users expect this functionality on this page now, can we turn it into a link or button at the top of the page?
Comment #13
moshe weitzman CreditAttribution: moshe weitzman commentedGood idea. Link to the clear cache feature of admin/settings/performance.
I would be surprised if this is fast in D7. All we did that i know of is remove some no-op queries in menu rebuild. Thats not the major problem. There are hardly any contrib modules available for 7, so no site's menu is very big. It will slow down once more menu items pour in.
Comment #14
smokrisGiven the dozens (hundreds?) of lengthy support forum posts I've seen on this topic, I think this issue can be considered critical, and in need of a fix in 6.x.
Comment #15
stormsweeper CreditAttribution: stormsweeper commentedI have a patch in #311626: admin/build/modules very slow on some configurations that moves the three rebuilds (the registry, node types, and menu) to the submit handler. Doing module development is really not a lot of fun with the current "magic" functionality.
Comment #16
stormsweeper CreditAttribution: stormsweeper commentedI'm actually going to bring the patch over here, on Moshe's suggestion. The main bugbear here seems to be the rebuilding of the menu cache, which for me is taking about half of the length page load time. The theme registry rebuild is pretty trivial, actually. I guess the issue is how drupal_get_form() works? I can see how that would affect the theme issue, but the menu should not need to be rebuilt at that point, I don't think.
Another issue as I pointed out there is that when enabling or disabling modules, all those rebuilds get done twice because of how the confirm process is structured.
Comment #17
stormsweeper CreditAttribution: stormsweeper commentedOk, some stats from my test machine. This is just viewing the page which has lots of modules (cck, views, etc):
from just timing bits of system_modules() and the whole function itself:
From devel.module:
On disabling a module:
So the menu build is taking up almost all system_modules()'s run time. The module rebuild is the only other bit that comes close, and that's with Update Status and CVS Deploy modules enabled.
Comment #18
catchWe have hook_modules_enabled() and hook_modules_disabled() now - why not try the rebuilds there?
Comment #19
stormsweeper CreditAttribution: stormsweeper commentedThose hooks are only in D7, no?
I guess I need to roll up a simple module that does what the issue above mentions - alters the system_modules form to have a theme function from that module. From there we can figure out a better way to handle that edge case - as it is we're using a howitzer to swat a fly.
Comment #20
stormsweeper CreditAttribution: stormsweeper commentedOK, I can't replicate the original issue here - I've commented out the rebuild operations in system_modules() and even added a status message to drupal_rebuild_theme_registry() to make sure nothing else is calling it on the page. I used a quick custom module for this purpose, as well as system_module.module (which I presume was what generated the original error, I commented out the theme rebuild in the disable hook). At this point, I'm going to say sometime between when this was filed and the official release, the theme delegation was cleaned up a bit.
Can anyone else replicate the original issue here?
Comment #21
moshe weitzman CreditAttribution: moshe weitzman commentedWell, I would start by deferring the menu_rebuild() only to submit handler. Thats the real killer. I think thats our best bet for getting this backported. I'm not opposed to moving all 3 though.
Thanks for working on this.
Comment #22
stormsweeper CreditAttribution: stormsweeper commentedTotally scratching my own back here. I've been doing intense module development, so a lot of enable, disable, uninstall, enable, etc. This issue has been maddening as it locks up my browser for a minute or two every time I hit submit.
I agree, the menu rebuild is what's killing us here. The code in module_rebuild_cache() could probably be tuned up a bit so it's not always doing a full row update for every module, but it's not quite the low hanging fruit.
So two patches attached, one is the same as posted to the other issue, it moves all four (the fourth forces a schema rebuild next time drupal_write_record() is called, or doing any kind of CCK work); the second only moves the menu rebuild.
All of them moved:
Just the menu rebuild:
Comment #23
stormsweeper CreditAttribution: stormsweeper commentedIt also occurs to me the menu rebuild may be less of a problem in D7 if it's using transactions. The indexes and such would only be rebuilt on commit, as opposed to every insert or update.
Comment #24
catchD7 isn't using transactions yet.
Comment #25
chx CreditAttribution: chx commentedAgreed. Currently admin/build/modules serves a recovery purpose, that should be a separate PHP (in a separate issue, if someone wants, I drafted a start http://drupalbin.com/9754 ) and admin/build/modules should not do all this. However, let's first fix D7 and then backport.
Comment #27
anarcat CreditAttribution: anarcat commented@chx - shouldn't that kind of recovery be part of the devel module anyways?
I agree a solution must be found regarding the load time of the modules page, it's pretty crazy (i'm so used to older drupals ... ;).
Comment #28
chx CreditAttribution: chx commentedNope, ordinary people can run into crashes when enabling/disabling strange modules.
Comment #29
EvanDonovan CreditAttribution: EvanDonovan commentedSubscribe. I like the recovery script linked from #25. I wrote a similar script just for when the {menu_router} table is trashed, but this one is more inclusive.
Comment #30
Senpai CreditAttribution: Senpai commentedIt seems that the patch in #22, the
system-module-menu-on-submit-19336-D6.patch
is the preferred method, so I went to apply it to D7, but it won't apply at all. So I attempted to re-roll it.What I found is that the old patch attempted to move menu_rebuild() from the form hook to the form_submit hook, but when I tried to re-roll this patch for D7 I realized that there's no menu_rebuild() anywhere near the form hook for admin/build/modules.
What happened to it? Is there another issue that has already removed the call to this function in favor of a stand-alone PHP recovery script like http://drupalbin.com/9754 demonstrates?
The attached patch adds a menu_rebuild() back into core, rather than moving it as the #25 patch did.
I'm not sure the if() that tests for a mismatch between $old_module_list and $current_module_list is the best place to put this, since it currently does nothing but a drupal_set_message() if the condition evaluates, and it seems to me that we'd want this call to fire upon every form submission if it's being used as a "recovery" tool.
Your thoughts on it's placement? Inside or outside of the if()? FYI, system_themes_form_submit() does this call on every form submission.
Comment #31
Senpai CreditAttribution: Senpai commentedWoops. Setting to Needs Review.
Comment #33
Senpai CreditAttribution: Senpai commentedOk, with the help of CHX in #drupal, I was able to figure out where this function call was removed from core. It happened about five months ago, in #306316: Regression: node_types_rebuild should rebuild menu by beeradb, and the core commit message was 'Rebuild the menu from node_types_rebuild() to assist with programmatic node creation'.
The core diff can be seen at http://cvs.drupal.org/viewvc.py/drupal/drupal/modules/system/system.admi...
I will now try and figure out why it was removed from D7, and why there are so many requests for it to be moved from the hook_form to the hook_form_submit in D6, yet the latest issue posted by Robert Douglass http://drupal.org/node/509516 was marked as a duplicate of this one even with the express understanding that patches to core must happen in D7 and be backported to D6.
Seems to me that it's gonna be impossible to make D6's admin/build/modules page faster in light of the above.
Comment #34
stormsweeper CreditAttribution: stormsweeper commentednode_types_rebuild() is called in system_modules(), so the menu_rebuild() still executes on the page view, it just happens to be located in a different place.
So you still have the same pattern where on submission of the form you will execute all those rebuilds 2+ times (when prompted to enable dependencies they also get executed).
Comment #35
Senpai CreditAttribution: Senpai commentedhttp://drupal.org/node/306316#comment-1773226 needs to be reverted before this current issue can progress any further.
Comment #36
stormsweeper CreditAttribution: stormsweeper commentedWell, I guess I won't submit this d7 patch then. It was to be along the lines of the other one - if we're going to do recovery functionality, I would say we do it on form submit.
Comment #37
EvanDonovan CreditAttribution: EvanDonovan commented@stormsweeper: Do you foresee any problems with moving these function calls to the submit handler in 6.x, though? Because I'm thinking of doing that in my own copy of Drupal 6.x, if there aren't any ill effects.
Side note: The Drupal community stresses you should never hack core, but when issues like this take years to get fixed, it really makes me wonder how valid a sentiment that is.
Comment #38
stormsweeper CreditAttribution: stormsweeper commented@Evan: None that I have experienced. You don't need to do any of those rebuilds to display the modules form, but you definitely want to do them if you're changing your module selection.
Comment #39
EvanDonovan CreditAttribution: EvanDonovan commentedThanks. I'll make that change to my site on Monday, after I upgrade to Drupal 6.13 :)
Comment #40
chx CreditAttribution: chx commentedI do not think so. The need for a recover php and moving all those rebuild call from system_modules minus the theme to submit is still valid. It's more than just the menu rebuild.
Comment #41
stormsweeper CreditAttribution: stormsweeper commentedPatch attached moves all the rebuild functions to the submit handler.
Comment #43
stormsweeper CreditAttribution: stormsweeper commentedHmm, the menu test uses the magic functionality in testMenuName(). Will see if I can rewrite that test.
Comment #44
stormsweeper CreditAttribution: stormsweeper commentedOK, I think that may just be a bad test. It's using the magic functionality and a wacky use case of setting a menu title by a get parameter.
modules/simpletest/tests/menu_test.module
modules/simpletest/tests/menu.test
So it's going to the modules listing to call menu_rebuild(), which then causes that menu hook to have a value. Attached is a new patch with a modified way to do the same test.
Comment #45
stormsweeper CreditAttribution: stormsweeper commentedAnd let's see if the test bot likes it.
Comment #46
stormsweeper CreditAttribution: stormsweeper commentedAlso, should we re-title this issue?
Comment #48
EvanDonovan CreditAttribution: EvanDonovan commented#41 gives a very nice speed improvement on 6.x. Thanks!
I haven't tested it to see if there are any weird edge cases with things not being properly rebuilt/cleared when modules are enabled or disabled, though.
Comment #49
stormsweeper CreditAttribution: stormsweeper commentedAs I posted upthread, I could not replicate the original issue. I suspect the theme registry was fixed somewhere along the line.
Comment #50
chx CreditAttribution: chx commentedOK this is good. Hope someone will write the recovery.php as I mentioned.
Comment #51
stormsweeper CreditAttribution: stormsweeper commentedIs there already an issue for that, chx?
Comment #52
donquixote CreditAttribution: donquixote commentedI really don't see the need for the ridiculously high number of queries happening during one menu_rebuild.
I propose to rewrite the menu_rebuild function, see
Rewrite the function menu_rebuild
Basic idea:
- One big query to load part of menu_links and full menu_router tables into php arrays.
- Do some computations (without touching the DB).
- Write the changes to the DB, if any.
Comment #53
webchickI'll try and look at this tomorrow.
It seems to me that this was originally how it worked and we changed it so that these caches were cleared on every load of this page. Now we're changing it back.
Does someone have a good summary of what issues we hit that caused us to move the code to the modules page in the first place and why we won't run into them again if this patch is committed?
Comment #54
stormsweeper CreditAttribution: stormsweeper commentedTo my understanding, when this was filed a module could alter the system_modules form with its own theme functions, and then after being disabled, the form was still cached with references to those functions, now unavailable. However, I tried and failed to recreate the issue for a few hours, with a custom module and with an edited version of util.module, which I presume was the original cause for the report. I expect the problem was solved elsewhere.
I'll see if I can build a test for this case. I'm not familiar with how to simulate form submits in SimpleTest - my test writing experience is from Java MVC's (e.g. Spring or Struts) where we don't usually allow for mutable forms.
Comment #55
pwolanin CreditAttribution: pwolanin commented@webchick - I think the idea was that in part visiting this page might let you recover if you manually rm'd a module and were left with fatal errors from missing functions and the like.
At the least we should make sure drupal.sh includes such a facility for clearing all after manul module/theme removal.
Comment #56
EvanDonovan CreditAttribution: EvanDonovan commentedI think that the idea of having a recovery page is a good one, but should not be given to the modules page to perform. I am using a module called "Rebuild" which works great, but unfortunately is not available in the Drupal.org CVS repository. But this functionality should be fairly easy to make.
Comment #57
stormsweeper CreditAttribution: stormsweeper commented@ EvanDonovan - it'd basically be update.php w/o running any updates.
Comment #58
webchick@#55: Ok, if that's the only reason, I can think of lots of places we could stick that functionality. For example, update.php, as #57 suggests.
Committed #44 to HEAD, with a couple of small comment clean-ups (wrapping at 80 chars, ending with period).
I believe the idea is to backport this to D6 too?
Comment #59
stormsweeper CreditAttribution: stormsweeper commentedYep, I can roll that patch. The one upthread would work, too, but I actually ended up moving the rebuilds to a different part of the submit function.
As to update.php, it already runs all these on a form submit by calling drupal_flush_all_caches():
http://api.drupal.org/api/function/drupal_flush_all_caches/6
Which I guess we could have used here, as well.
Comment #60
stormsweeper CreditAttribution: stormsweeper commentedD6 version of the D7 patch
Comment #61
sunLooks good.
I didn't test it on an existing site, so I'm not marking it RTBC.
Comment #62
pauldawg CreditAttribution: pauldawg commentedCan someone give me a quick way to get this patch applied to my Drupal 6 site? I am at the end of my rope. I cannot proceed. This is a problem on my Production site, although it didn't present itself on my Dev site. No matter what I do (extend the max time or memory) I cannot get my admin/build/modules page to load -- and strangely there are no errors in the apache error log. I am not familiar with applying patches and even a quick and dirty way of getting the page to load would be a big help. Thank you so much.
Comment #63
EvanDonovan CreditAttribution: EvanDonovan commentedAll: I have been running this patch on my production D6 site since the 16th, and have not experienced any negative effects from it. I think it's a good patch, but I'll wait for someone with more experience to change status.
On the test site, I have occasionally gotten "MySQL has gone away" errors from CiviCRM, but I don't think those are related to this patch.
pauldawg: If you don't know how to apply patches, then I recommend you look at the changes the patch makes (indicated by + and - signs) and make them manually in system.admin.inc. There's a good guide to applying patches at http://drupal.org/patch/apply, though, so I strongly suggest that you try one of the methods in there. It will serve you well in the future.
Comment #64
donquixote CreditAttribution: donquixote commented@pauldawg(#62):
I can explain how to read and make sense of a patch, so you can apply it manually. I hope that helps!
http://drupal.org/node/534548
(I created this page right now!)
Comment #67
Senpai CreditAttribution: Senpai commentedWe also have http://drupal.org/patch/apply if that helps.
Comment #68
pauldawg CreditAttribution: pauldawg commentedThanks Senpai, EvanDonovan and Donquixote for all of your help.
Yesterday the problem with the modules page "magically" disappeared for me. What I suspect is that even though .htaccess changes are supposed to take effect right away, my adjustments to the max_memory and max_time values didn't take effect on the previous day. Now the build/module page shows up and I am able to proceed. I'll still test out the patch in my Dev environment to see how it affects the performance.
Ironically I am actually a software configuration professional and a seasoned Java programmer, but I never have dealt with the diff/patch format first hand. Also I am not a Unix/Linux person, and am new to both PHP and Drupal development, so although it's all still new to me it's making me see that this should all be really easy and I think I am going to start testing out and developing more patches for modules. I love Drupal and am dying to become a part of the team of open source programmers. Any good suggestions on how to create a patch file to submit to a forum? You can reply offline to my profile so we don't go too far off-topic.
Thanks again!
Comment #69
sunStill takes pretty long, but is a bit faster than before.
Comment #70
espirates CreditAttribution: espirates commentedHow is the above patch different from this one
Which one is better ?
Comment #71
Gábor HojtsyHum, I'd share @sun's concerns from http://drupal.org/node/193366#comment-1399508 which were not yet resolved. People are used to this page rebuilding stuff and now we'd suddenly have a release where this is not true anymore. We got them used to it which resulted in all kinds of documentations, screencasts, books, etc. include tips on this. Is the best we can do is to roll back this *feature* in a Drupal 6 point release?
Comment #72
moshe weitzman CreditAttribution: moshe weitzman commentedwe also got people used to the their sites being down for 1-2 minutes whenever you *visit* the modules page. I routinely get alerts from my monitoring service anytime someone visits that page. And this is without admin_menu module. We really do have to remove these rebuilds.
We could add a link to the clear cache button on admin/settings/performance for people who were misusing this page as a cache clearing mechanism.
Comment #73
Gábor HojtsyWell, as @sun said above, let's give users some indication as to how they can achieve what they used to achieve with this page before.
Comment #74
pwolanin CreditAttribution: pwolanin commentedAdding locks to menu rebuild would also help prevent this from bringing sites down - and alone might be enough to alleviate the problem without removing this as a known feature.
Comment #75
donquixote CreditAttribution: donquixote commentedI completely agree with sun here:
Put a link on top of the modules page, saying "if you want to rebuild your modules and menu registry, click here".
And yes, it needs to be on the modules page. Having it in the performance page or as a sub-item of "flush all caches" makes sense, but is not enough, because people will have no idea finding it there.
Comment #76
EvanDonovan CreditAttribution: EvanDonovan commentedI agree w/moshe: add a link to the cache clearing page from the modules page. But the issues with the modules page have to be fixed. Adding locks to menu rebuild alone doesn't solve the problem that it's not necessary to rebuild the menu just to load the page.
Comment #77
webchickWell either way we go, this needs work.
Comment #78
moshe weitzman CreditAttribution: moshe weitzman commentedOK, now with a link to the clear button on Performance page.
Comment #79
Gábor HojtsyCommitted this to Drupal 6, thanks. I believe we are fine with not having that link on D7, since in D6, we need to re-educate people on the behavior here, so we need the extra note. By D7, they will be educated hopefully.
Comment #81
ksavage31 CreditAttribution: ksavage31 commentedAfter reading through this thread i am still unsure whether there is a solid fix for this issue or which patch is official. can someone please point me in the right direction?