I've disabled the overlay to test stuff for a different bug and then enabled it again. Now I get an overlay with all page renderings and out of the space of the screen where it should be. All overlay JS is loaded and the page inside the overlay is requested with render=overlay, so it is even more perplexing. Any reloading of the page or loading other admin pages in overlay result in the same. Clicking on toolbar does not work. Broken the same way in Firefox and Safari.
Comment | File | Size | Author |
---|---|---|---|
#126 | upgrade.test.rej_.txt | 448 bytes | jonhattan |
#116 | 651086-116-cache-mess.patch | 14.58 KB | carlos8f |
#108 | 651086-108-cache-mess.patch | 12.85 KB | carlos8f |
#107 | 651086-107-cache-mess.patch | 12.7 KB | David_Rothstein |
#104 | 651086-104-cache-mess.patch | 12.77 KB | carlos8f |
Comments
Comment #1
roborn CreditAttribution: roborn commentedClearing the cache solves this problem.
That’s something that overlay module should do when enabled through the admin UI. Maybe something like this:
Comment #2
David_Rothstein CreditAttribution: David_Rothstein commented@roborn: Thanks for tracking this down! That looks like it was a tricky one to figure out.
However, it is not up to the overlay module to clear the cache - that is something that Drupal needs to do correctly for all modules when they are enabled. So I spent some time looking at itand I think the attached patch is closer to what we want.
Notes:
(and more) actually belongs in the appropriate API functions, not in a submit handler. That may be a separate issue, though.
Overall, this is a total mess.... :(
Comment #4
David_Rothstein CreditAttribution: David_Rothstein commentedOK, I cannot for the life of me understand why a function like _system_rebuild_theme_data() should ever have a static variable, so I removed it. I think the testbot will like this one better.
Note that the actual changes in this patch are much smaller than it now looks (most of it is just indentation changes within the above-mentioned function).
Comment #5
catch#651736: Overlay recursive fun! marked as duplicate. I hadn't disabled and re-enabled or anything but seems like the same underlying issue.
Comment #6
seutje CreditAttribution: seutje commentedsubscribe
Comment #7
roborn CreditAttribution: roborn commentedTested with a new installation and everything is working fine :)
Comment #8
Damien Tournoud CreditAttribution: Damien Tournoud commentedIf you install without enabling the update module at the end of the installation, the issue can be reproduced consistently.
I'm reluctant about the patch, because I do not understand it. Do we really need to rebuild *all* those caches? At the very minimum, we need to remove the clearing in the submit function if it is now redundant.
Comment #9
David_Rothstein CreditAttribution: David_Rothstein commentedBetter title, given what Damien found.
I thought I understood the patch, but I understand it less knowing that the update module can affect things :) I'm guessing at the end of the installation, update module must do something that calls system_list_reset()... which we now solve in the patch by doing so whenever the theme data is rebuilt instead.
To rebuild the caches less often, I guess we could keep a list of relevant hooks (hook_system_info_alter being one), and only clear them if the newly-enabled module implements that hook? Otherwise I'm not sure how to avoid it - we allow modules to alter data stored in these database tables, so the newly-enabled module never gets a chance to have its hook run unless that database cache is rebuilt.
Comment #10
bleen CreditAttribution: bleen commentedsuperscribe
Comment #11
catchIf update.module is enabled at the last stage, then that ought to call system_list_reset() via module_enable() no?
Comment #12
moshe weitzman CreditAttribution: moshe weitzman commentedYeah, module installation is very tricky business. We really need a long whiteboard session to rearchitect it. We need to list all the caches and systems that are dependant and note when they need to be flushed during a multiple module change like submitting module/theme form.
Comment #13
cburschkaThis performance issue would probably tie into that as well: #661420: Installation of modules is hugely inefficient
Comment #14
David_Rothstein CreditAttribution: David_Rothstein commentedYes, at the moment those two patches are at cross-purposes, since here we are adding calls to system_rebuild_module_data() that are being removed there because they are slow...
It's partly a question of how much we're willing to refactor things in order to speed up the installation. We don't actually need to do a full system_rebuild_module_data() here every time, but we do need to make sure hook_system_info_alter() gets invoked on the newly-installed modules. It should be possible to make that happen if we really want to.
Comment #15
Anonymous (not verified) CreditAttribution: Anonymous commentedsubscribe, just noticed this is related to #661420: Installation of modules is hugely inefficient.
/me shakes fist at submit handlers that are pseudo-API function messes...
Comment #16
Anonymous (not verified) CreditAttribution: Anonymous commentedre #2, just came across another reason why clearing caches in the module page submit handler is evil.
drupal_theme_rebuild() is currently not called in any of the module API functions, yet without it, the theme registry will be stale after installing modules. the test suite doesn't use the form submission to enable modules, so doesn't call drupal_theme_rebuild().
how is this not broken? the first call to build the theme registry on the test-site side just happens to come after all the modules are installed.
menu_execute_active_handler --> call_user_func_array --> system_batch_page --> _batch_page --> _batch_do --> _batch_process --> call_user_func_array --> _simpletest_batch_operation --> DrupalTestCase::run --> BookTestCase::setUp --> DrupalWebTestCase::setUp --> drupal_install_modules --> module_enable --> array_filter --> _drupal_install_module --> module_invoke --> call_user_func_array --> default_install --> module_invoke_all --> call_user_func_array --> dashboard_permission --> l --> drupal_theme_initialize --> _drupal_theme_initialize --> _theme_load_registry --> _theme_save_registry
yay for brittle APIs that are coupled with form submission handlers....
Comment #17
casey CreditAttribution: casey commentedI'd say we get patch from #1 in and remove it when module install system is up to it.
Comment #18
catch@justin: I'm pretty sure the reason all those cache clears are in the submit handler is because they were originally in the admin/build/modules page callback itself but removed due to dozens of reports on that page taking ages to load.
@moshe's #12, I'd like to see us move cache clearing from just adding a cache_clear_all() each time we add a new cache, to something like cache_invalidate('module', 'install'), see #636454: Cache tag support.
Comment #19
Anonymous (not verified) CreditAttribution: Anonymous commented@catch: ok, so we have two issues. first, how to pick up new modules/filesystem changes for admin pages like the module list. second, moving cache clearing out of form submit handling and in to API functions where it belongs.
Comment #20
pwolanin CreditAttribution: pwolanin commentedpatch no longer applies. fails on includes/module.inc
Comment #21
pwolanin CreditAttribution: pwolanin commentedsimple re-roll for changes to module.inc
Comment #22
aspilicious CreditAttribution: aspilicious commentedWorks as promissed!
Comment #23
David_Rothstein CreditAttribution: David_Rothstein commentedIt works, although now we're in a situation where this patch would effectively roll back all the gains from #661420: Installation of modules is hugely inefficient ...
If we want to avoid that, seems like we still have two solutions:
Comment #24
pwolanin CreditAttribution: pwolanin commentedDo we care if installation of modules is inefficient? It should be very rare.
Comment #25
cburschkaYes. It's not so rare - the first thing anyone sees of Drupal is exactly that, around 20 times in a row.
Even if the installation time were not an issue, we are extremely close to the 32M memory limit on the web installer, and still over on all CLI installers (36M on drush if I remember right). Reverting the above fix could make this worse...
Comment #26
bleen CreditAttribution: bleen commented@pwolanin: I think we do because Drupal requires a huge amount of memory simply to be installed and this is one of the areas identified that was contributing to that.
Comment #27
casey CreditAttribution: casey commentedMaking installation more efficient doesn't seem to be fixed in a week. Lets commit patch in #1, so overlay works properly in alfa release.
Comment #28
moshe weitzman CreditAttribution: moshe weitzman commented#21 - No way are we rolling back to a despicable delay on the Modules page so that overlay can work a little better.
Comment #29
pwolanin CreditAttribution: pwolanin commentedCan we disable the overlay on the modules page and overlay can trigger this refresh next time it needs it? Honestly - do we need it on the modules page anyway? I find it a real annoyance.
Comment #30
carlos8f CreditAttribution: carlos8f commentedI vote for using the approach in #1, since:
The mess needs to be cleaned up in D8, IMO.
On a side note, I would love to see the results of system_rebuild_module_data() cached sometime in the future. The info returned there is super useful although the function basically costs the poor server an arm and a leg. It should only actually run if the filesystem is suspected to contain new modules, i.e. loading the modules page.
Comment #31
David_Rothstein CreditAttribution: David_Rothstein commentedI think something like #1 works as a temporary measure if the goal is to make the alpha release not look like it has noticeably ridiculous bugs :)
But that seems like a really bad habit to get into. This bug will affect any module that implements these hooks, so we really should try to fix it the right way, and in D7.
I don't follow how changing the pages the overlay displays on would affect this issue one way or another?
Comment #33
casey CreditAttribution: casey commentedComment #34
catchLet's do this for now.
Comment #36
carlos8f CreditAttribution: carlos8f commentedShould the cache clear be inside
if (strpos(current_path()...
as in #1?Powered by Dreditor.
Comment #37
carlos8f CreditAttribution: carlos8f commentedOMG, wait a second.
drupal_goto() should NOT be used in hook_enable(). That effectively aborts the rest of the code in module_enable(), and all subsequent code in that request!!
The only reason this slipped by the tests is because the goto only happens inside the browser, when the URL is actually admin/modules. WTF!
I recommend overlay.module sets some kind of flag instead, with the redirect happening after the module enable process completes.
Comment #38
David_Rothstein CreditAttribution: David_Rothstein commented@carlos8f: That issue is already filed at #658118: Overlay prevents other modules turned on at the same time from being enabled correctly
I don't believe it's related to the problem here. I can reproduce this bug even with that line of code commented out.
Comment #41
carlos8f CreditAttribution: carlos8f commented@David_Rothstein: sorry for getting excited, I haven't been aware of that bug 'till now. Posted a patch there.
webchick has stated she won't commit any more overlay patches for alpha, so maybe a quick-fix is not as important now. Changing the title to reflect our actual problem.
Fixing module_enable() is very necessary and very delicate work. Before we attempt that, I would recommend some serious test coverage to verify that all the caches and system lists refresh as expected during and after module_enable().
Comment #42
carlos8f CreditAttribution: carlos8f commentedI think we need to write some tests to detect the problem, instead of relying on overlay/toolbar to be the canary. Those tests would hopefully cover cache/list clearing with module_enable/disable() as thoroughly as possible to avoid breakage like this in the future.
Comment #43
carlos8f CreditAttribution: carlos8f commentedAlso the tests should probably address theme_enable/disable() as well, as #2 suggests.
Comment #44
moshe weitzman CreditAttribution: moshe weitzman commentedGood thought ... I'm not certain how you test this, but I want to make sure we don't clear the same cache multiple times. In my experience, developers start clearing shit all over the place when they don't grok all the caches that their code impacts. And in D7, it is gotten very hard to grok this.
Comment #45
deggertsen CreditAttribution: deggertsen commentedsubscribe
Comment #46
casey CreditAttribution: casey commentedCan somebody give patch in #33 (with the note in #36) a reroll? I currently cant write patches.
We're getting an awful lot of duplicate issues/WTFs on the duplicate toolbar in the the overlay.
Comment #47
aspilicious CreditAttribution: aspilicious commentedIm on the job
Comment #48
aspilicious CreditAttribution: aspilicious commentedPatch...
This a temporary quickfix (see the comment).
Rerolled #33 (with the note in #36).
Lets fix this BIG issue for new users and alpha testers. (untill we find better solution)
Comment #49
aspilicious CreditAttribution: aspilicious commentedComment #50
catchAgreed, we should get the quick fix in for now, I'm not sure the overall mess of module and theme rebuilding can be solved in D7.
Comment #51
David_Rothstein CreditAttribution: David_Rothstein commentedThe above patch doesn't actually fix things even for the overlay... See Damien's description in #8 of how the overlay bug can be reliably reproduced. The patch in #48 won't help with that.
Also, if we are going to do a hack here, let's at least not limit it to the overlay. There are 8,000 contrib modules out there - I hear some of them like to implement hooks also :)
The attached patch should address both issues.
Comment #52
David_Rothstein CreditAttribution: David_Rothstein commentedAlso, I'm really not convinced the overall bug is that hard to solve. I don't see why we can't just cache_set() the original .info file data at the end of system_rebuild_module/theme_data(), then load it in module_enable(), run it through hook_system_info_alter(), and insert it into the {system} table if it changed, something like that?
As for getting stuff out of system_modules_submit() in general - which doesn't really have much to do with the original bug - well, in the worst case for D7 we could just move all that to a shutdown function instead, then register the shutdown function from inside module_enable()...
Comment #53
jbrown CreditAttribution: jbrown commentedComment #54
David_Rothstein CreditAttribution: David_Rothstein commentedReroll... the drupal_static_reset() is no longer necessary since that static cache doesn't exist anymore.
Comment #55
catchOK let's get this in.
Comment #56
aspilicious CreditAttribution: aspilicious commentedcan you write a comment in the patch? (I just wonna make sure that it gets commited the first time Dries/Webchick looks at it)
Comment #57
catchI don't think this needs an extra comment, it has a comment saying we clear all caches, we're adding two extra ones.
Comment #58
aspilicious CreditAttribution: aspilicious commentedI thought cache_clear_all('system_list', 'cache_bootstrap'); ment all except for those two...
Well for me #54 is fine
Comment #59
Dries CreditAttribution: Dries commentedA mess indeed. Committed to CVS HEAD.
Comment #60
David_Rothstein CreditAttribution: David_Rothstein commentedLet's keep this open for the general problem (since there are patches above that at least start to go down the painful road of fixing this). I think we can safely downgrade it from 'critical' though.
Comment #61
RobLoachI've run into this ever since the Overlay and the Toolbar has been around.
Comment #62
carlos8f CreditAttribution: carlos8f commentedOK, I think it took me 6 months to finally understand what's going on here! I have some ideas for a patch, I'll see what I can do.
Comment #63
carlos8f CreditAttribution: carlos8f commentedRewriting the title to be more descriptive :)
I think it's safe to focus on the hook_system_info_alter() problem, and if we find other hooks that are effected, create a followup patch or other issue to address it. The system_info_alter problem is unique in some ways because 1) refreshing the cache involves an expensive rescanning the filesystem for .info files, and 2) the cache is stored in the {system} table, immune to normal cache clears. I'm pretty sure we can figure something out though. It might involve some special logic for the installer since it installs modules one at a time, and it'd be much faster to rebuild {system} after all that is done.
Comment #64
carlos8f CreditAttribution: carlos8f commentedHere's an initial patch, which addresses point 1 of comment #23. The next step is to do some tracking of how much the filesystem is actually scanned, and implement a cache if possible. That would be point 2.
I found that the module_implements() static cache was stale inside the install tasks, and was interfering with system_rebuild_*_data() using drupal_alter(). This is the kind of thing that is hard to write a SimpleTest case for, because it's virtually impossible to simulate the the static cache state of install.php in a test case. A test case should be written anyway though, which would have a basic "test if module's hook_system_info_alter() effects the {system} table after it is enabled" situation. I'll work on that next.
Comment #66
carlos8f CreditAttribution: carlos8f commentedHere's another try, this time with tests. Note I rolled in the one-liner from #831080: Dashboard is completely empty after installation, or else list_themes() won't reflect the new {system} table.
Comment #67
carlos8f CreditAttribution: carlos8f commentedsending to the bot...
Comment #68
carlos8f CreditAttribution: carlos8f commentedFixed some bugs in the tests.
Comment #69
carlos8f CreditAttribution: carlos8f commentedI realized that the setUp() method shouldn't be used in these tests--it would trigger $enable_dependencies in module_enable() which would call system_rebuild_module_data(), and therefore unintentionally refresh caches that we want to test. Calling module_enable(array('module_test'), FALSE) explicitly in the test fixes that scenario.
Also attaching a patch with the tests only, to see how many of them are broken without the fixes.
Comment #70
carlos8f CreditAttribution: carlos8f commentedRerolled without #831080: Dashboard is completely empty after installation, which was just committed. (yay)
Comment #71
moshe weitzman CreditAttribution: moshe weitzman commentedWe're at a point IMO where only a couple people understand WTF is going on during module enable/disable. Hopefully Rothstein can review this patch soon. I can't think of other experts. The test in the patch is comprehensive so thats a good sign.
Comment #72
carlos8f CreditAttribution: carlos8f commentedI forgot the module_test.module hunk in the "tests only" patch, but that wouldn't have made a difference since I tested it locally and know all the tests are broken anyway even with the hunk:
Altered theme info was added to {system}.info.
Altered theme info was returned by system_region_list().
Altered theme info was returned by system_list().
Altered theme info was returned by list_themes().
I'm working on incorporating other *_list() functions into the test case, such as block_list($region). It would be nice to rest assured that none of those require obscure static/cache flushes to pick up the new info.
@moshe, yes, D7 in general is about twice as complex under the hood as D6, and the addition of about a gazillion static caches means half of the code never even runs dynamically... difficult indeed.
Something to take note of: static caches are *a bitch* to debug! There are still static caches that have been subtly stale in various situations and arise as critical bugs once a complex module or install profile is built with the API (dashboard, overlay, Drupal Gardens). #831080: Dashboard is completely empty after installation is a great example of that. The static issue is compounded because we use the batch API to install modules, which over HTTP has an isolated static cache per operation, and on command line has a unified static cache per invocation. So installation bugs may be command-line specific, or HTTP install specific, or even SimpleTest specific. Further, static cache state in install.php/index.php can't be reliably reproduced in a test case, and sometimes a bug only arises in install.php because static cache X is primed earlier than in index.php or in SimpleTest.
Other @todo stuff (possibly after the patch has landed) is to look at how much redundancy we have, in terms of cache flush mess in system_modules_submit(), etc. Also look at redundancy in scanning the filesystem during the installer, and other places. It would be nice to decrease the redundancy, but not necessarily required.
I'm sure @David will poke is head in here sometime ;)
Comment #73
carlos8f CreditAttribution: carlos8f commentedAlso: a full drupal_static_reset() is never done in install.php, in fact it's *only* ever done in SimpleTest, which means test cases could very well be avoiding lots of caching bugs that actual installs might experience. I've tried at various times to introduce a full drupal_static_reset() in the installer, only to see that it screws up the maintenance theme (no CSS is rendered at all). That only further illustrates the frustration that static caching can induce, although it's certainly a boon for performance.
Comment #74
Anonymous (not verified) CreditAttribution: Anonymous commentedstill digesting this patch. nasty stuff.
just so we don't forget the chat in #drupal:
the drupal_static_reset('module_implements'); looks redundant to me.
Comment #75
Anonymous (not verified) CreditAttribution: Anonymous commentedhmm, not strictly related to this patch, but something i've noticed with the different ways we run module_enable for install vs form is: if you get the *order* of the list of dependencies wrong in your profile's .info file, the installer breaks in weird and wonderful ways. is that a bug in code, or documentation?
Comment #76
Anonymous (not verified) CreditAttribution: Anonymous commentedwant to see what i mean? this patch kills the installer:
Comment #77
carlos8f CreditAttribution: carlos8f commented@justinrandell: i noticed the same bug a couple days ago and posted an issue/patch: #833192: Installer might install modules in wrong order. Discussed it with @catch and he agreed that it seemed like a bug.
Comment #78
David_Rothstein CreditAttribution: David_Rothstein commentedHah, you think I understand how this all works? I'm pretty sure no one does :)
As far as I can tell this patch looks really great though. To summarize how I understand it, before this patch, when enabling modules (let's leave disabling modules alone) there are two types of cache clears that go on:
The first type is bug free and we'd do that with everything if we didn't care about performance. The second type is more or less senseless because it means module_enable() is broken as an API function.
What this patch does is introduce a third category of cache clearing, with the following properties:
Although by definition this will still leave some theoretical bugs behind, it seems like it's probably a good compromise for D7 and could hopefully even be applied to other caches as well.
My only questions are:
Given that hook_system_info_alter() is implemented so rarely, I wonder if it would make sense to go ahead and make this particular one like the first category (allow it to potentially be called after each newly enabled module), based on the theory that in practice this wouldn't actually hurt performance much? May or may not be worth it (but even if we can do that here, we can't get away with it for most other caches).
Can we now just remove the calls to system_rebuild_module_data() and system_rebuild_theme_data() that currently occur within system_modules_submit()? If we really believe that hook_system_info_alter() is the correct condition for when these actually need to be rebuilt, then it seems like we should be daring and go ahead and try to remove them :)
Comment #79
David_Rothstein CreditAttribution: David_Rothstein commentedAlso, a minor comment:
I think this can probably use http://api.drupal.org/api/function/drupal_installation_attempted/7 instead. And could probably use a code comment as well.
Comment #80
Anonymous (not verified) CreditAttribution: Anonymous commentedwell, after kicking the tires on this one and throwing questions at carlos8f in #drupal, i'm ok with this patch as it is (once #74 is addressed).
the only thing i'd consider changing is the
if (variable_get('install_task') == 'done')
check. most modules don't implement hook_system_info_alter(), so that just makes for another difference between installer code and normal drupal. i'm ok if that's not changed though, because i can't see how that is going to bite us yet, but i'd feel more comfortable just eating the (small) performance hit.Comment #81
Anonymous (not verified) CreditAttribution: Anonymous commentedcross posted. i agree with #78 and #79. we should probably convert
system_run_automated_cron()
to use drupal_installation_attempted() as well.i agree with taking the rebuild calls out of system_module_submit().
Comment #82
carlos8f CreditAttribution: carlos8f commentedThanks for the good reviews.
#78 explained the idea of the patch a lot better than I could. With those cache clear "types" in mind, I'm hoping that type 2 (cache clearing in submit handlers, which for the module API is a terrible practice) can be phased out by the introduction of type 3.
In the installer, module_enable() is arguably misused (instead of passing an array of modules like you're supposed to, it passes them one at a time so it can divide the install into batch API operations). With type 3 cache clearing (once per module_enable() if needed) that could cause type 3 to effectively revert to type 1 (too many system_rebuild_*_data() calls would be expensive), which is why I added the "clever code" for the installer to rebuild only once after the batch. This satisfies the requirement of not reverting performance improvements from #661420: Installation of modules is hugely inefficient. Before those improvements the installer took ~1 minute to finish because of all the unnecessary system_rebuild_module_data() calls, and we don't want to go back to that with this patch :P
One could argue that hook_system_info_alter() is not often implemented and therefore the gain is minimal, but I say it's a hook like any other, and making that assumption is not taking a good approach because if we can easily optimize, let's optimize. Plus, we might want to add other hooks to that list eventually which are more commonly implemented, or maybe regardless of hook implementation we perform a type 3 clear (conceivably even running drupal_flush_all_caches()). This way we at least have a framework for performing that type of clear if we need to, down the road.
I realize this is some esoteric stuff but looks like with @David_Rothstein and @justinrandell in here we have enough brainpower to drive a patch home :) I'll follow up soon.
Comment #83
carlos8f CreditAttribution: carlos8f commented@justinrandell, #833094: Ajax requests in installer cause cron to run prematurely couldn't use drupal_installation_attempted() because the ajax requests actually hit index.php during the install (no MAINTENANCE_MODE defined). Using drupal_installation_attempted() should be fine here because the install batch uses install.php-based ajax requests. I hope I didn't just make anyone's head hurt :)
Comment #84
carlos8f CreditAttribution: carlos8f commentedSo after thinking about this issue for a while, I decided to go a different direction with it. Instead of assuming that module_enable() should do everything for us and clear all conceivable lists and registries, I am realizing that drupal_flush_all_caches(), used once after one or more calls to module_enable(), may substitute for the heavy rebuilding. It is called in 2/3 places where we install modules: the installer ('finished' step) and SimpleTest. In system_modules_submit(), we have a slew of seemingly random cache clear calls (thus the "ineffective mess" that I actually think is an appropriate title for this issue). I think we can use one call to drupal_flush_all_caches() in system_module_submit() instead, and then we are being consistent and have established a "one-two punch" of module_enable() and drupal_flush_all_caches(). If the modules in question don't implement hook_system_info_alter(), or other less-used hooks, it might be sufficient to just call module_enable() in a particular circumstance. I hope we can get those requirements ironed out and documented.
This patch is still a little experimental and I will explain the details after we have some bot details back.
Comment #86
carlos8f CreditAttribution: carlos8f commentedI've simplified this one down a bit, and the installation failure should be fixed now.
The failure was from calling menu_rebuild() and actions_synchronize() from module_enable(), because module_enable() is used in the installer to install user.module before the full bootstrap, and menu.inc and actions.inc aren't loaded yet. I removed those calls, but the interesting side-effect was that SimpleTest had an installation failure on shortcut.module. That module calls some menu API functions indirectly in hook_enable() that need the menu built, which caused a PDO exception. I ended up adding a menu_rebuild() to DWTC::setUp() before the profile modules are installed, which seems to make it work.
Comment #88
carlos8f CreditAttribution: carlos8f commentedMoved system_update_7037() (Rename action description to label) to update_fix_d7_requirements() to fix the upgrade problem. The patch adds actions_synchronize() to drupal_flush_all_caches(), and that was getting called before the column rename, causing an error.
I still need to write an analysis of the patch, but unfortunately I might not have time for a few more days. At least the tests should pass now :)
Comment #89
carlos8f CreditAttribution: carlos8f commentedOops... the bot seems to have lost track of the last one. Here it is again, just updated with HEAD.
So, this patch hits a number of points:
module_enable($actions['install']);
. Moved actions_synchronize() from system_modules_submit() to drupal_flush_all_caches(). That change required system_update_7037 to be moved to update_fix_d7_requirements().In summary, this is an attempt to reduce cache clear clutter and create some consistency, while fixing some of the places where caches are known to be stale ('configure' install step doesn't have access to altered {system}.info, system_region_list() has a stubborn static that never resets).
Comment #90
carlos8f CreditAttribution: carlos8f commentedActually this is what I meant to upload, here I stripped out some of the unessential details to hopefully make a more reviewable and solid patch.
Comment #91
Anonymous (not verified) CreditAttribution: Anonymous commentedwow, that testing fail without menu_rebuild() is wild ;-) investigationing.
Comment #92
Anonymous (not verified) CreditAttribution: Anonymous commentedcarlos8f: i'm not sure we can do the cache clearing per list of modules :-(
we're failing at module_invoke('shortcut', 'install'), because shortcut module relies on menu.module being installed and enabled. menu_enable() calls menu_rebuild().
in HEAD module_enable(), we do (pseudocode):
with the patch, we do:
so any module that relies on one of it dependencies being installed, enabled, *and caches cleared/rebuilt* to function properly, fails. i don't think we get away with changing the cache calls this late in the cycle.
Comment #93
sunRe-rolled against HEAD.
Comment #94
sunCan we get this done?
Comment #95
carlos8f CreditAttribution: carlos8f commentedYeah, sorry I've been M.I.A. :-/ I'll give it another go soon.
Comment #96
carlos8f CreditAttribution: carlos8f commentedSo #358437: Filter system security fixes from SA-2008-073 not applied to Drupal 7.x attempted to clean up the system_modules_submit() mess using drupal_flush_all_caches(), and that got rolled back in favor of this issue. Looking at the re-roll in #93, there are remnants of that change which no longer apply to HEAD.
I started from #90 again and rolled back the module_enable() changes, as per @justinrandell's review. That leaves us with:
Plus I restored a piece that got lost somewhere around #90, which calls drupal_flush_all_caches() in a 'finished' callback of the module installation batch. I consider this important because otherwise, installation tasks don't have access to dashboard regions or anything else that is done with system_info_alter().
Comment #98
carlos8f CreditAttribution: carlos8f commentedThe reason why the module dependency test is failing is quite interesting. It shows that system_modules_submit() determines dependencies, but fails to sort the module list and instead depends on $enable_dependencies in module_enable() to sort. This incurs two extra system_rebuild_module_data() calls for enable and disable, just for the purposes of sorting. I'd like to add the sorting to system_modules_submit(), similarly to how I added it to the installer in #833192: Installer might install modules in wrong order. That will reduce 3 system_rebuild_module_data() calls to 1, and fix the test failures.
Comment #99
sunSounds awesome. Additionally, shouldn't we consider to replace
in module_list() with system_list_reset(), and afterwards, remove the system_list_reset() from module_enable()? (it already calls module_list(TRUE))
This looks incorrect to me -- the system_region_list static should already be cleared by system_rebuild_theme_data() or something.
Not sure how this change is related to this issue...?
Powered by Dreditor.
Comment #100
carlos8f CreditAttribution: carlos8f commentedI tried the static reset proposal and it appears to work. I agree using the encapsulation rather than directly calling the static reset is probably better.
The drupal_static_reset('system_region_list') is actually badly needed... as far as I can tell, this static is not reset anywhere in core, making it impossible for regions returned from system_region_list() to change during runtime! I realized this when debugging #831080: Dashboard is completely empty after installation, and figured I would include it here since we've been circling around the 'system_info_alter() -> add regions -> regions can't be found after module is enabled' problem in relation to the overlay and dashboard modules. Reseting the static fixes this bug in some situations, while calling drupal_flush_all_caches() actually rebuilds the region list and that's part of why I added a 'finished' callback to the installation batch.
The update_fix_d7_requirements() change was necessary to add actions_synchronize() to drupal_flush_all_caches(). This is because drupal_flush_all_caches() is called early in the D6-D7 upgrade code, and triggers a fatal if the actions table is not up to date.
Re: the module sorting, I discovered that the module list *is* sorted, but it's backwards :) We need dependencies sorted before dependents for the enable list (the disable list is correct though), fortunately we can just rsort(). I'm getting deja vu here :D http://drupal.org/node/399642#comment-2460022
Removing tags because I don't think they're relevant now.
Comment #101
carlos8f CreditAttribution: carlos8f commentedcome here, bot
Comment #102
carlos8f CreditAttribution: carlos8f commentedNice to see the pass. Just remembered to remove system_list_reset() from module_disable() as well.
Comment #103
sunThe static system_region_list cache is not built in system_list(), so it's technically not correct to clear it in system_list_reset(). But I understand that http://api.drupal.org/api/function/system_region_list/7 merely is based on list_themes(), and that is affected here.
However, it seems like that the static cache in system_region_list() can be entirely removed. All that function is doing is to iterate over the result of list_themes(). One too many static cache.
1) Please remove the first sentence from the summary.
2) Please also remove the underscore from the method name.
Powered by Dreditor.
Comment #104
carlos8f CreditAttribution: carlos8f commentedRemoved the system_region_list() static cache. Agreed that it didn't do a whole lot, just save some php iterations. Did the other changes too.
Comment #105
sunAwesome. Another confirmation would be nice to have, but not strictly required. Also, let's wait for green light, of course.
Comment #106
moshe weitzman CreditAttribution: moshe weitzman commentedCode looks great and bot likes it. RTBC for sure.
Comment #107
David_Rothstein CreditAttribution: David_Rothstein commentedI rerolled with a minor fix - system_update_7037() was empty after this patch, so I removed the function completely, since we decided in #909272: Remove stub update functions and renumber the remaining ones not to keep empty update functions around anymore.
Still RTBC. I haven't studied the latest versions extremely closely, but the patch seems to make a lot of sense.
***
Only if rerolling for another reason, I did notice this:
Since we don't have a static cache anymore, seems like this could be simplified a bit - i.e., the [$theme_key][$show] part of the nested array doesn't serve any purpose anymore?
Comment #108
carlos8f CreditAttribution: carlos8f commentedThanks David! I didn't know about #909272: Remove stub update functions and renumber the remaining ones so that's nice.
I deleted the [$theme_key][$show] part, I was initially lazy but now that you mention it, might as well do it right.
Comment #109
David_Rothstein CreditAttribution: David_Rothstein commentedLooks good to me - thanks.
Comment #110
catchactions_synchronize() - can't this go in hook_flush_caches? It'd have to be system_flush_caches() but that's slightly better than hard coded in common.inc
Apart from that fully agreed with RTBC, this is really nice.
Comment #111
carlos8f CreditAttribution: carlos8f commentedTechnically it could go in hook_flush_caches(), but I'm not sure if that's preferable. Following that logic, wouldn't we want to move node_types_rebuild() and menu_rebuild(), etc. as well? If we hard-code the core parts we can ensure that implementations of hook_flush_caches() have access to rebuilt/fresh .inc stuff without resorting to module weighting.
Comment #112
catchnode_types_rebuild() should definitely go. menu_rebuild() is more of a tricky one since the menu system is a .inc - so it's whether we consider common.inc to have a dependency on menu.inc or not (common.inc already has a dependency on system.module, but that's for #679112: Time for system.module and most of includes to commit seppuku). None of this has to be done here.
Comment #113
sunApparently, doing that might solve another quirk. As of now, menu_rebuild() invokes node_menu(), which in turn requires to rebuild its node types to generate menu items. Oddly enough, this currently seems to work "somehow", even though menu_rebuild() comes before node_types_rebuild() in http://api.drupal.org/api/function/drupal_flush_all_caches/7
Thinking through this, I guess the following would make sense: (stripped down for the details of interest)
Thus, we only rebuild the menu (which should be the most expensive operation by far) only after invoking all modules. And outsourcing into node_flush_caches() at the very least allows modules to adjust their hook position via hook_module_implements_alter(), if required and not possible via regular module weights already.
Leaving RTBC, because all of this can be done in a follow-up patch, and might require further analysis/discussion.
Comment #114
carlos8f CreditAttribution: carlos8f commentedAlright, I'm fine with removing common.inc's dependencies on other .inc's, but let's figure that out in a different issue ;)
Comment #115
catchAgreed, let's commit this as is, deal with hook implementations later.
Comment #116
carlos8f CreditAttribution: carlos8f commentedI found a few cases where actions_synchronize() is called directly after drupal_flush_all_caches(): the installer, upgrade test, and SimpleTest. That's unnecessary now since drupal_flush_all_caches() does it all.
Comment #117
carlos8f CreditAttribution: carlos8f commentednote: #116 just added minor cleanup and should still be considered RTBC.
Comment #118
sun#116: 651086-116-cache-mess.patch queued for re-testing.
Comment #119
catchYep, still RTBC.
Comment #120
sunAlthough badly needed, this is D8 material according to the rules (I had to learn today).
Comment #121
moshe weitzman CreditAttribution: moshe weitzman commentedrecover from temper tantrum
Comment #122
Anonymous (not verified) CreditAttribution: Anonymous commentedfor what its worth, i think this is RTBC as well.
i know this is not for this patch, but do we ever want a call to module_enable() that will install a module not to trigger locale_system_update() ?
Comment #123
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #124
David_Rothstein CreditAttribution: David_Rothstein commentedNo actual commit?
Comment #125
carlos8f CreditAttribution: carlos8f commentedNo actual commit indeed.
Comment #126
jonhattanpatch doesn't apply clean
Comment #127
jonhattanComment #128
ilo CreditAttribution: ilo commented#116: 651086-116-cache-mess.patch queued for re-testing.
Comment #129
carlos8f CreditAttribution: carlos8f commented@jonhattan: Patch still applies OK for me after updating:
Comment #130
jonhattanyeah carlos8f, it applies. I was wrong. I was waiting for the result of ilo's requeue to mark it again as RTBC.
sorry for the noise.
Comment #131
jonhattanComment #132
webchickOk. Really committed #116 to HEAD this time. :)
Comment #133
carlos8f CreditAttribution: carlos8f commentedWoo hoo! Thanks for the work and reviews, all.