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.
here is a fix.
Comment | File | Size | Author |
---|---|---|---|
#72 | drupal.modules-installed.72.patch | 10.84 KB | scor |
#68 | drupal.modules-installed.68.patch | 7.78 KB | scor |
#66 | drupal.modules-installed.66.patch | 8.44 KB | sun |
#65 | drupal.modules-installed.65.patch | 8.48 KB | sun |
#64 | drupal.modules-installed.64.patch | 8.55 KB | sun |
Comments
Comment #1
Damien Tournoud CreditAttribution: Damien Tournoud commentedI don't get it. Why is "modules_installed" broken?
Comment #2
chx CreditAttribution: chx commentedBecause at this point the module list and the implementation list and the router and the actions list is not yet rebuilt that happens inside module_enable. Which is quite OK when you install a module to an existing install but when you create a child Drupal which has a significantly list to the parent Drupal and one of the modules in the parent Drupal happens to fire a cache clear against a cache table which is not in the child Drupal then you are in trouble. (Check the fields-in-core bzr repo for fields.module. Hint, hint.)
Comment #3
moshe weitzman CreditAttribution: moshe weitzman commented$disable_modules_installed_hook = FALSE
. This is ugly enough, without a double negative. Please use $modules_installed_hook = TRUE insteadComment #4
Damien Tournoud CreditAttribution: Damien Tournoud commentedSo the issue is that the module hook cache is not flushed after we call drupal_install_system(). Would the attached patch work?
Comment #5
Damien Tournoud CreditAttribution: Damien Tournoud commentedMore precisely, the issue is we preload the registry of the child site with information from the parent registry, making module_implements() believe that it should run those hooks.
The solution is to preload the registry way later, just before rebuilding it, not before enabling modules.
Comment #6
Damien Tournoud CreditAttribution: Damien Tournoud commentedA static modifier was missing in currentlyRunning().
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedhmm, so webchick was right, this performance hack did break something after all. bummer, it was so quick!
given that the preload stuff is pure, kitten-killing performance hackery, i don't like either of these solutions. the initial version of the preloadRegistry patch was a kitten-killer, and it was rejected. the patch that got in didn't change anything on the non-test side, and i think we should stick to that.
@chx: your patch makes the module install process different when installing modules, which is bound to bite us somewhere.
@Damien: your patch avoids any problems during install, but not if a test enables a module post-install. in that case, we have the same problem, as we can get bogus calls to
hook_modules_installed
, which is bound to bite us somewhere.here's a version of preloadRegistry that only preloads code from
includes/*
. this won't cause any of the issues with module implementations, and will save us about 700 queries for each setup, so still worth it i think.Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentednote, i did think about preloading the registry for all modules returned by
drupal_required_modules
as well, as none of them implementhook_modules_installed
, but this could produce subtle bugs later if this changes, and we don't remember this issue. thoughts?Comment #9
Damien Tournoud CreditAttribution: Damien Tournoud commentedOh, true, but that's easy to fix: simply $this->canPreloadRegistry = FALSE; after the registry is rebuilt.
I still like my approach better.
Comment #10
chx CreditAttribution: chx commentedDont we know perfectly well which modules will be enabled? We do. There is modules information in both the registry_files and the registry table.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedyes, but this suffers from the same problem - to avoid the overhead of building a modules registry entries, we need to load them before its enabled. currently, there's no way to do this after the call to
hook_modules_installed
but beforemodule_enable
(without changing module install/enable code just for our testing performance hack).attached patch only preloads a modules registry entries if the module doesn't implement
hook_modules_installed
. this keeps the hacks testing-side-only, and we get to keep most of the optimisation, as this hook is not implemented much.Comment #12
Damien Tournoud CreditAttribution: Damien Tournoud commented@justinrandell: I see no reason why an install function couldn't (at least indirectly) call a hook itself. So this is very fragile.
The way to go is what I implemented in #6, with the addition of a
$this->canPreloadRegistry = FALSE;
after module installation, so that we don't preload the registry at latter calls (it would be inefficient).Note that you were wrong in #7:
FALSE: in my approach, we only preload the registry at the very last moment: just before rebuilding it. It's 100% safe, in all cases.
Here is a reroll.
Comment #13
Damien Tournoud CreditAttribution: Damien Tournoud commentedShould I add that my patch also has the added benefit of implementing
DrupalWebTestCase::currentlyRunning()
which will prove useful (in a later issue) to cleanup some of the the crappy "simpletest" regexps that pollute core.Comment #14
Anonymous (not verified) CreditAttribution: Anonymous commented@Damien: i'm coming around to your way of thinking, though i still dislike changing registry code just to make things faster.
having said that, if we're going for a performance hack, lets get the best performance. we can still preload everything in
includes/*
unconditionally, and avoid 700-odd queries.so, lets preload these files before the first registry rebuild, otherwise this patch will slow down simpletest building quite a lot.
Comment #15
webchicksubscribe. :)
Comment #16
Damien Tournoud CreditAttribution: Damien Tournoud commented*sob* this is still an issue.
Comment #17
Damien Tournoud CreditAttribution: Damien Tournoud commentedRerolled.
Comment #19
Damien Tournoud CreditAttribution: Damien Tournoud commentedThe Field tests are already defining a $instance member variable. Moving to $this_instance.
Comment #20
Dries CreditAttribution: Dries commentedI'd still like to see an answer to #14, and ideally a final review from @justinrandell.
Investigating the different approaches, I thought justin's approach was less of a hack.
Comment #21
Anonymous (not verified) CreditAttribution: Anonymous commentedtagging with Registry
Comment #22
Anonymous (not verified) CreditAttribution: Anonymous commentedjust refreshing patch for HEAD, no changes.
Comment #23
Anonymous (not verified) CreditAttribution: Anonymous commentedon the child side, the registry isn't polluted by preloading from the parent at this point, so i don't understand the need for this first rebuild. DamZ, can you hit me with a cluebat?
if we can take this out, then my point at #14 is moot, because we'll get all of the includes resources pulled in from the parent.
also, can we can take out the $disable_modules_installed hack? i couldn't see anything else using that, so:
can go back to:
DrupalWebTestCase::setUp is still really fat. if this patch lands, we still run 4000+ queries in setup for each test. the low hanging fruit seems to be rebuilding the theme registry for each test (around 2228 queries).
i worked up a proof of concept patch to cache (keyed by theme name and test module list), but i'm not sure if thats just asking for more trouble.
Comment #24
moshe weitzman CreditAttribution: moshe weitzman commentedI wonder if we truly need the theme registry. I'd love to rip it out and just do real time template discovery - then benchmark. Don't think I will get to that soon, but someone should.
Comment #25
Anonymous (not verified) CreditAttribution: Anonymous commentedpatch attached does what i suggested in #23, lets see what the test bot thinks.
Comment #26
yched CreditAttribution: yched commentedSubscribe. I'm wondering if it's the same bug we're hitting in #372743-18: Body and teaser as fields (second paragraph) :
The 'body as field' patch is getting stale, so I'd need to reroll it first and test.
Comment #27
Dries CreditAttribution: Dries commented1.
I'd like to see us add a sentence that explains _why_ we do this.
2. The name "$this_instance" is rather poor. Can we think of a more descriptive name like $current_test or something?
3.
I'd like to see us add a sentence that explains _why_ it is now useful and/or why it wasn't useful before.
Comment #28
Damien Tournoud CreditAttribution: Damien Tournoud commentedRe: #23: we need to rebuild the registry as soon as possible, for two reasons: (1) static caches are full of information from the parent site and (2) the registry tables are empty, so hooks implemented by modules installed by drupal_install_system() will not be recognized.
This operation should be relatively cheap, especially if we decide to pre-copy include/* files.
Comment #29
JamesAn CreditAttribution: JamesAn commentedBump..
#515040: Simpletest throws exception on a fresh install that I filed a few days ago may stem from this problem. In short, simpletest doesn't work with a fresh install of head if the profile module is enabled.
A call to menu_rebuild() is made when simpletest is installing the toolbar module for the child site. Even though the profile module is not installed (and will not be installed), menu_rebuild() somehow knows that the profile module is enabled on the parent site, something that shouldn't happen.
Comment #30
scor CreditAttribution: scor commentedThis patch does not apply. Some hunks have been applied to HEAD already. What's the status of this issue?
I've created #594234: hook_modules_installed() not invoked during tests which I believe is a related problem.
Comment #31
sun$disable_modules_installed_hook argument was introduced in the monster Field API patch, but the registry is gone now, and disabling this hook for modules that are installed in SimpleTest totally breaks my tests in a contributed module.
This is a straight re-roll against HEAD. If this passes, then we don't really need to preload the class registry, and only do it for performance reasons. Which in turn would mean that we can simply remove the argument.
Comment #32
sunContinuing that conclusion, I can run tests just fine with a total revert of the $disable_modules_installed_hook argument.
Comment #34
sunI have no idea.
This patch also breaks #569326: Add hook_taxonomy_vocabulary_info()
Comment #35
sunstill no luck
Comment #36
sunSeems like http://api.drupal.org/api/function/rdf_install/7 had the same problem...
Comment #38
sunMore clean-ups, but Drupal render test is still failing for me (as for the bot).... chx mentions it passes for him... (?)
Comment #40
sunI'm really running out of ideas now... additionally synced with install_finished() now.
Comment #42
sunWe're calling $this->refreshVariables(); too late?
Comment #44
carlos8f CreditAttribution: carlos8f commentedsubscribing
Comment #45
sunLet's see whether #399642: Replace drupal_install_modules() with an improved module_enable() solved the problems.
Thus, re-rolled, no further changes. So this patch still updates setUp() to do exactly the same as http://api.drupal.org/api/function/install_finished/7
Comment #46
sunComment #48
sunMixing #685004: Cannot run tests under non-standard profile into the game.
Comment #49
carlos8f CreditAttribution: carlos8f commentedsubscribing
Comment #51
sun.
Comment #52
sun.core CreditAttribution: sun.core commented#48: drupal.modules-installed.48.patch queued for re-testing.
Comment #54
sunRe-rolled against HEAD and removed the change for unit tests (no modules installed here).
Comment #56
sunObviously, the theme system information is not reset at all for any test that is run.
Comment #57
sunComment #59
sunThis works locally, let's see what the testbot has to say.
Comment #61
Dries CreditAttribution: Dries commentedThe test bot doesn't like you anymore, sun. ;)
Comment #62
sunNo surprise... who doesn't hate me?
Actually, those entire RDF tests contain plenty of workarounds for the bug that this issue is fixing. Removed all of those. After doing so, it seems that the RDF functionality seems to work properly, but the tests are trying to verify totally weird stuff, which was true with previous workarounds, but not with a proper module installation behavior.
Comment #64
sunwell, so why don't you eat this?
Comment #65
sunor rather this? :P
Comment #66
sunoh my, it's getting late here, sorry.
Comment #68
scor CreditAttribution: scor commented@sun, yes, we really had a hard time getting the rdf tests to work and found out hook_modules_installed() was not invoked during testing (plus other caching issues). It obviously came form simpletest since everything worked when installing manually. These workarounds can be removed now the underlying issue is being fixed. The patch attached fixes the rdf test which failed in #66 (similar to patch in #65).
Comment #69
sun#66 failed, because I thought I could remove this rdf_mapping_save().
Why is it needed? Shouldn't rdf_entity_info_alter() store the mapping already?
EDIT: The result of that save operation is 0 (zero), returned by db_merge(), which (I think) means that nothing was inserted and nothing was updated.
Comment #70
scor CreditAttribution: scor commentedThe second mapping is for the blog bundle (see in rdf_test.module), and because the blog module is not enabled in this test there is no 'blog' bundle in the entity info cache to hold that mapping. That's why we need to have the explicit save operation (which is fine since that's the operation we're testing here).
EDIT: the above is not a good explanation since we're not using the entity info cache in this particular test. I'll rewrite the save operation test tomorrow morning.
Comment #72
scor CreditAttribution: scor commentedthe variable names in RdfCrudTestCase were confusing so I've refactored it. all rdf tests are now passing on my machine.
Comment #73
sunAwesome! Thanks for helping out, scor!
Comment #74
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.