Hi there,
under some circumstances (custom install profile) the installation of Drupal fails with the error:
FieldException: Attempt to create a field of unknown type [error]
text_long. in field_create_field() (line 298 of
W:\htdocs\eurocentres\drupal\modules\field\field.crud.inc).
FieldException: Attempt to create a field of unknown type <em class="placeholder">text_long</em>. in field_create_field() (line 298 of W:\htdocs\eurocentres\drupal\modules\field\field.crud.inc).
The error was thrown by the comment module which tries to create the needed entities without the "text" module installed/enabled.
To fix that behaviour I had to add a dependency into the comment.info file.
I'm not sure how to reproduce this issue, it seems to depend on the available modules in the module/ and sites/all/modules folder.
Cheers,
Peter
Comments
Comment #1
jody lynnText is a required module, so I don't think that we should need a dependency.
Comment #2
das-peter commentedThe problem was/is that the module enabling sequence was "wrong".
While I was debugging text was the last in the enabling list. Since the comment module needs it to create the its fields this caused the issue.
By adding the dependency the sequence order is actively maintained to prevent such issues.
Comment #3
jody lynnBut maybe the required core modules should install first. Otherwise we might have to keep adding more of these dependencies. Or it could be an issue in comment.install
Comment #4
das-peter commentedOk, I digged somewhat deeper - the root cause for the issue I experienced was that a contributed module declares "text" as dependency.
This dependency declaration has an impact on the whole module sequence.
The method _module_build_dependencies [module.inc] creates the order and relies on the declared dependencies.
The "text" module is normally not declared, because it's a core module - but if the "text" module is somewhere declared as dependency the sequence detection gets confused. It places the "text" module just before the declaring module - and that's definitely to late for a core module ;)
The question is now if the method to detect the correct sequence has to be modified (Add core modules always on top), or if this issue should stay with the module which declares the "text" module by mistake.
Cheers,
Peter
Comment #5
das-peter commentedI've tried to create a patch which respects the core/install modules.
It looks not really nice and any enhancement is highly welcome ;)
Question above is still valid - has this behaviour to be changed?
+ The fix shouldn't have high performance impact but covers a potentially nasty pitfall (Needs some time of debugging to find the root cause)
- The correct declaration of dependencies is up to the modules. (Module writes should have the knowledge that core modules must not be declared)
So long,
Peter
Comment #6
mfer commented@das-peter The dependency system uses graph.inc to figure out the order modules need to be installed. This is a great system. What we should do is actually declare the dependencies like you did for comment module and let it do what it does. Bolting on some solution on top of a dependency mapping system so we can try to avoid declaring dependencies in some cases is just not pretty. The dependencies make sure modules are installed in the correct order and provide a level of documentation on what dependencies a module is using.
I'm marking this as critical because basic install profiles just break in some cases.
The attached patch adds a bunch of dependency mapping that will provide graph.inc the level of detail it needs during the initial install process. For comment and fields anyway.
Comment #7
webchickEdge cases are not release-blockers.
Comment #8
mfer commentedSadly, this isn't as much of an edge case as it looks. The minimal profile doesn't install much so we don't see it there. The standard profile is lucky enough that we don't see it there.
If a profile has comment module but not color module as a dependency it will fail to install. If the following profiles were ported to D7 this issue would cause their installation to fail:
Is this really not critical?
Comment #9
mfer commentedFor anyone interested in replicating the problem with installing comment module. In the standard.info file (part of the standard profile) comment out the dependency on color module. Then try to install the profile.
Comment #10
sunProperly defining dependencies is a good idea for a multitude of reasons. Also think updates.
Comment #11
dries commentedCommitted to CVS HEAD. Thanks.
Comment #12
int commentedI can't upgrade my site.
Upgrading from D6 to D7 should not check if new modules are installed.
Comment #13
int commentedadd tag
Comment #14
damien tournoud commentedHm. Actually, we have end-to-end tests for the upgrade process. Why aren't those failing?
Comment #15
mfer commentedThe upgrade path should (in theory.. i'm not sure of the implementation) be able to handle enabling new dependencies if they are available.
Comment #16
moshe weitzman commentedOh fun. We are uncovering bugs all over the place :). Subscribe.
Comment #18
catchMoving to base system and re-titling.
Comment #19
damien tournoud commentedSo, the comment module now correctly depends on the text module, but our update process doesn't allow you to continue without first enabling the text module, and we cannot enable the text module without running the update process first.
The check was introduced in #228860: Upgrading a module with a newly added dependencies breaks things badly. I'm not sure of the way forward here except completely rolling back this other patch.
Comment #20
damien tournoud commentedComment #21
damien tournoud commentedWe discussed with catch on the IRC, and we don't see this working without removing the 'disabled dependency' check added by #228860: Upgrading a module with a newly added dependencies breaks things badly.
As a consequence, the plan could be:
Comment #22
catchI'll roll a patch.
Comment #23
catchHere's the patch, works for me locally. Not sure where the 'enable new dependencies in hook_update_N() should go apart from update docs.to a
Added the module_enable() to comment_update_7000() and just moved the variable deleting to a later update function rather than re-numbering just for a few variable_del(), hope that's alright.
Comment #24
damien tournoud commentedI would argue that we don't actually need the change in the comment module: those modules are enabled by the system module during its own upgrade process.
Comment #25
catchHmm, was thinking it was worth it for documentation even if redundant, but instead I just modified the comment in comment_update_dependencies() slightly.
Comment #26
quicksketchThis makes sense on so many levels. The check is completely unnecessary and doesn't make any sense. We already run updates for modules that are disabled. Why would a disabled module's dependency prevent the upgrade from running but the module being updated may be disabled itself? It doesn't make any sense that the update would fail if both are disabled.
Note that other checks remain in place, including checks to make sure the dependent module actually exists. This patch removes the unnecessary check.
Comment #27
damien tournoud commentedThis looks good for me too.
Comment #28
tstoecklerComing from the other issue, the reason this check was introduced was modules that were available but not installed.
Example:
New version of module A depends on module B. Module B is part of project C, which the user has downloaded for a different reason.
In #228860: Upgrading a module with a newly added dependencies breaks things badly it was argued that it might not be good to blindly enable module B, and install its schema with it, because the user should be given the choice which modules to enable. Maybe he doesn't trust module B or it conflicts with module D etc.
I haven't really read this issue enough to know whether this is only about (re)enabling previously installed modules or whether the above use-case is actually flawed in some aspect, just throwing this out there so that it does not get overlooked.
Hence, setting to needs review.
Comment #30
damien tournoud commentedWe had a test for this!
Comment #31
dries commentedFixing the upgrade path seems more important to me, but it we need to think about #28 some more.
Comment #32
dries commentedTalked to DamZ, and decided this was ready. Committed to CVS HEAD. Thanks all!
Comment #33
mlncn commentedI think a related problem: #890210: Cannot enable Comment module after a Drupal 6 to Drupal 7 upgrade