The standard install profile installs several blocks into the dashboard, but if you visit the dashboard after installation, no blocks display there.
This is a regression and appears to have been introduced as a side effect of #235673: Changes to block caching mode not caught
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 831080-7-dashboard-empty.patch | 591 bytes | carlos8f |
| #6 | 831080-6-dashboard-empty.patch | 2.23 KB | carlos8f |
| #2 | 831080-2-dashboard-empty.patch | 1.3 KB | carlos8f |
Comments
Comment #1
carlos8f commentedI'm looking at this right now. I don't have a good explanation for why this bug happens, still working that out. It has to do with _block_rehash() being called in block_flush_caches(). My first thought to avoid conflict with the profile is to wrap it in
but the installer runs cron through a mechanism that routes through index.php, bypassing MAINTENANCE_MODE, and cron flushes caches, which means the bug still persists. We don't really need to rehash during the installer, so the above is the preferred workaround. Now wrapping in:
avoids the bug, but means blocks aren't rehashed when clearing caches in other ways, such as on the performance page.
The vital thing is that modules are able to update the cache mode, and updating modules normally involves running update.php, so the workaround should be OK on that front.
If anyone has any insight on the order that things run here in the installer and why the regions are getting reset from dashboard_sidebar/main (set by the profile) to -1 (probably by block_rehash), please enlighten us :)
Comment #2
carlos8f commentedI did a bunch of debugging today in attempt to track this down. What I came up with is that:
system/timezone/PST/-25200/1, and another I can't figure out) . Here's the stack dump:I tried to unravel the caching layers in system_region_list(), but it would take ages to determine the best way to get the region list to be fresh there.
Here's the second workaround from #1, just resigning to rehash blocks for update.php. Anything more than that would take a lot of painful cache dissection :)
Comment #3
David_Rothstein commentedWow, thanks for tracking that down. I'm still a little puzzled, though, because I've seen this with the command-line installer also (which definitely doesn't hit index.php via AJAX, and I'm having trouble imagining other ways it could hit it?). Plus, install.php itself explicitly avoids storing things in the cache (and even tries clearing out the cache every chance it gets, specifically to try to help get rid of stale stuff that index.php might have put in there), so this is definitely a tricky one.
The one other piece of info I can offer is that in testing this out in Drupal Gardens (we have not pushed it live yet, but have an up-to-date D7 HEAD in the version we are developing) it doesn't look like we've come across this bug there. We are using a custom install profile, so hopefully I can take some time to try to figure out what that install profile is doing differently that doesn't trigger this bug.
It would be ideal to get to the bottom of this, because the problem with the workaround solution is that although it's best practice to visit update.php, not everyone necessarily does it (e.g. if they are just updating code and don't have any database updates). That said, it does sound like actually tracking this down all the way might be very painful :)
Comment #4
carlos8f commentedI found that this works, although fairly superfluous:
The weird thing is that this is coming after system_rebuild_theme_data() was already called in drupal_flush_all_caches(), and means it apparently didn't cache the altered $theme->info['regions'] in {system} correctly the first time. I think if MAINTENANCE_MODE is not set (which is the case here, strangely, because we're still installing) system_regions_list() falls back on cached stuff in the {system} table which would've been created by system_rebuild_theme_data(). Hmmm.....
Comment #6
carlos8f commentedThis patch fixes test's assumption that drupal_flush_all_caches() always calls _block_rehash().
I'll try debugging why index.php -> cron are happening during install, if that turns out to be a bug it would make a better solution.
Comment #7
carlos8f commentedCreated #833094: Ajax requests in installer cause cron to run prematurely and posted a patch. With that applied, this issue can be fixed with a nice little one-liner! Took hours of searching, but there it is.
Comment #8
carlos8f commentedI haven't tested, but #7 alone should fix the command line install. With the web install, you would need #833094: Ajax requests in installer cause cron to run prematurely applied also to prevent _block_rehash() from running too early and permanently reseting dashboard regions to -1.
drupal_static_reset('list_themes') seems like a logical addition to system_list_reset(), since that gets called when modules are enabled/disabled or when rebuilding module/theme data. Modules can alter theme .info so when modules change, the static theme data should be discarded.
Comment #9
catchThis patch looks fine by itself, RTBC.
Comment #10
David_Rothstein commentedAgreed, looks like a good start, even if not a complete fix.
Also, it turns out Drupal Gardens does experience this bug when using the web installer (I had forgotten that I had only tried it from the command line). So, no great help there - probably our profile was just clearing the list_themes() cache via other code at some point, and therefore had the same effect as this patch on the command line installs.
Somewhat frighteningly, I think I've managed to reproduce this bug while running 'drush updatedb' on a test Drupal Gardens site as well - the dashboard blocks were all removed. Granted, that's a HEAD to HEAD update, so not supported, but it doesn't seem like that should ever happen... If it can be reproduced further, we'll have to look into that more.
I think the underlying cause of this whole bug might have something to do with #651086: Cache clearing is an ineffective mess in module_enable() and system_modules_submit() - basically, when the Dashboard module is enabled, module_enable() never gives it a chance to run hook_system_info_alter() and add the dashboard regions? That would explain it, but a quick attempt to just add system_rebuild_theme_data() every time a new module is enabled didn't seem to solve this either, so I'm really not sure what's going on.
Comment #11
carlos8f commentedHmm, I'll revisit #651086: Cache clearing is an ineffective mess in module_enable() and system_modules_submit() and see if I can come up with a general test case. I think with the more frequent static reset of 'list_themes' we are in much better shape, but sometimes it's hard to determine whether a stale cache bug is due to a static, a cache_get(), an old {system} entry, or some weird combination of the three :)
Comment #13
carlos8f commented@David you're on the right track, but the issue is tricky because we're running into *two* stale caches: list_themes() in install.php, and {system} in index.php. I'll outline why these are stale:
First up, list_themes(). When called from install.php it has a static that is primed very early:
This comes long before modules are bootstrapped, which means the data is inherently stale because dashboard hasn't had a chance to alter it after the themes are scanned from the filesystem.
Under a normal page load (MAINTENANCE_MODE not defined), list_themes() uses either cache_get() or info cached in the {system} table and doesn't call drupal_alter() on the fly -- so it won't matter if modules aren't bootstrapped yet. That leads us to our second stale cache.
Maybe we've operated under the assumption that module_enable() is self-sufficient. In reality it requires system_rebuild_module/theme_data() afterward to rebuild the {system} table with altered info. That is usually done somewhere on the module submit page, after install.php finishes, after update.php, etc., so we don't worry about it. But on the 'configure site' step of the installer (which is where the ajax requests run) module/theme data hasn't been rebuilt yet (it is rebuilt with drupal_flush_all_caches() on 'finished' step), so we can't consider those modules 'fully installed' yet.
I think adding {system} rebuilding to module_enable() would be great if we could minimize the performance impact like so:
(adding this to the bottom of module_enable(), before hook_modules_installed():
For the installer though, which installs modules one at a time in a batch, it might be better to delay the rebuild with if (MAINTENANCE_MODE == 'install') and do a single rebuild after the batch completes. That would allow stuff during the 'configure' step to use fully installed modules.
And I tested the above code, and without the ajax/cron patch the ajax request during 'configure' ran cron and was able to find the dashboard regions. Except, without the list_themes() reset patch, install.php can't see the dashboard regions and the bug would surface anyway.
Comment #14
carlos8f commentedRenamed the cache clearing mess to #651086: Cache clearing is an ineffective mess in module_enable() and system_modules_submit(), and I think @David and I agree that that is the underlying cause of why we're seeing these confusing issues, because module_enable() alone isn't enough to refresh the system_info_alter cache. So the gap of code running between module_enable() (including hook_modules_enabled() and installed) and drupal_flush_all_caches() or system_rebuild_*_data() doesn't have access to the current altered info. In the case of the installer, that gap is as long as the whole 'configure' task! Ideally we close that gap in a way that doesn't break performance. Will follow up at #651086: Cache clearing is an ineffective mess in module_enable() and system_modules_submit().
Comment #15
ksenzeeI can confirm what carlos is saying in #13. If you're running CLI install or update without the patch, by the time you get to drupal_flush_all_caches() at the end of the process, you're still using list_themes() information that was gathered when drupal_maintenance_theme() first ran. The patch in #7 fixes that problem.
Comment #16
webchickOk, committed #13 to HEAD. (and also #833094: Ajax requests in installer cause cron to run prematurely.)
I'm a bit turned around by the subsequent replies... it sounds like this is still "needs work", but the required follow-up will happen in #651086: Cache clearing is an ineffective mess in module_enable() and system_modules_submit() instead.
So, marking fixed. Please change the status as appropriate if I'm incorrect.
Comment #17
webchickOops. See above about turned around. ;)
Comment #18
carlos8f commentedThis is an issue for dashboard.module, (which acted as the canary for a bigger problem) and after this commit (and the ajax/cron one) dashboard is fixed. We're tackling the source problem in #651086: Cache clearing is an ineffective mess in module_enable() and system_modules_submit(). Full-blown install profiles (Drupal Gardens is a good example) could get tripped up by the source issue, so it would be great to get that fixed soon too.
Comment #20
gábor hojtsyFYI looking at the commit logs, @webchick committed #7, not #13 (#13 has no patch even :).