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

jody lynn’s picture

Text is a required module, so I don't think that we should need a dependency.

das-peter’s picture

The 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.

jody lynn’s picture

But 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

das-peter’s picture

Ok, 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

das-peter’s picture

StatusFileSize
new982 bytes

I'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

mfer’s picture

Priority: Normal » Critical
Status: Active » Needs review
StatusFileSize
new3.38 KB

@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.

webchick’s picture

Priority: Critical » Normal

Edge cases are not release-blockers.

mfer’s picture

Priority: Normal » Critical

Sadly, 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:

  • Open Atrium
  • Open Publish
  • Well, some others

Is this really not critical?

mfer’s picture

For 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.

sun’s picture

Status: Needs review » Reviewed & tested by the community

Properly defining dependencies is a good idea for a multitude of reasons. Also think updates.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

int’s picture

Status: Fixed » Active
StatusFileSize
new50.8 KB

I can't upgrade my site.

Upgrading from D6 to D7 should not check if new modules are installed.

int’s picture

Issue tags: +D7 upgrade path

add tag

damien tournoud’s picture

Hm. Actually, we have end-to-end tests for the upgrade process. Why aren't those failing?

mfer’s picture

The upgrade path should (in theory.. i'm not sure of the implementation) be able to handle enabling new dependencies if they are available.

moshe weitzman’s picture

Oh fun. We are uncovering bugs all over the place :). Subscribe.

catch’s picture

Title: Missing dependency "text" » Specifying dependencies for required modules breaks updates
Component: comment.module » base system

Moving to base system and re-titling.

damien tournoud’s picture

Title: Specifying dependencies for required modules breaks updates » Cannot upgrade Drupal core if the comment module is enabled
Component: base system » comment.module
Status: Active » Needs work

So, 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.

damien tournoud’s picture

Component: comment.module » base system
damien tournoud’s picture

We 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.

  • We cannot automatically enable dependencies during the update process, because that would be unreliable (those would be enabled before the real upgrade is performed...
  • Currently you cannot enable those modules at all manually (except by manually messing up with the database)

As a consequence, the plan could be:

  • Remove the 'disabled dependency' check
  • Document that a module that defines new dependencies needs to call module_enable($my_new_dependencies) during its own update process. Those modules are guaranteed to exist and to be in the correct versions because of the checks in system_requirements().
catch’s picture

Assigned: Unassigned » catch

I'll roll a patch.

catch’s picture

Status: Needs work » Needs review
StatusFileSize
new2.1 KB

Here'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.

damien tournoud’s picture

I 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.

catch’s picture

StatusFileSize
new1.6 KB

Hmm, was thinking it was worth it for documentation even if redundant, but instead I just modified the comment in comment_update_dependencies() slightly.

quicksketch’s picture

Status: Needs review » Reviewed & tested by the community

This 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.

damien tournoud’s picture

This looks good for me too.

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs review

Coming 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.

Status: Needs review » Needs work

The last submitted patch, comment_upgrade.patch, failed testing.

damien tournoud’s picture

Status: Needs work » Needs review
StatusFileSize
new3.22 KB

We had a test for this!

dries’s picture

Fixing the upgrade path seems more important to me, but it we need to think about #28 some more.

dries’s picture

Status: Needs review » Fixed

Talked to DamZ, and decided this was ready. Committed to CVS HEAD. Thanks all!

mlncn’s picture

Status: Fixed » Closed (fixed)
Issue tags: -D7 upgrade path

Automatically closed -- issue fixed for 2 weeks with no activity.