Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
field system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
20 Apr 2009 at 14:47 UTC
Updated:
16 Aug 2009 at 10:13 UTC
Jump to comment: Most recent file
Comments
Comment #1
alex_b commentedWrapping the field_attach_create_bundle call in node_type_save() fixes the error.
I am not sure whether this is the right level to address this issue though.
Comment #2
bjaspan commentedThis patch is not the right approach. field_attach_create_bundle() is loaded by field_init(), so the question is why field_init() has not run.
I see that the problem occurs during an update function. What module is updating? Is this part of a D6 to D7 upgrade, or is the site already fully D7?
Comment #3
alex_b commented#2:
It occurs in a D7 to D7 upgrade. #293318: Convert Aggregator feeds into entities introduces feeds as nodes, hook_update() adds a default feed content type when upgrading. Eventually, most people will upgrade D6 to D7 (I haven't tested this yet).
This is the particular patch that I applied that caused this bug to surface: http://drupal.org/node/293318#comment-1497410 (installed aggregator, applied patch, ran upgrade scripts).
Comment #4
alex_b commentedI did some more digging.
hook_init() is not invoked on update.php. This means that functions loaded in field_init() aren't available on updates.
Not sure what's the best way to solve this issue.
For details see:
update.php:
common.inc:
Comment #5
bjaspan commentedGood digging. Now we need to find out why hook_init is not called during update.php. Let's see if we can ask around for commentary from some of the Elder Ones. :-)
Comment #6
damien tournoud commentedThat hook_init() is not called on update is a bug, but the major bug is that the Field API uses hook_init() to include code while we now have a full-featured registry.
Related work: #445044: Try to remove the field autoload "feature".
Comment #7
bjaspan commentedcvs annotate to the rescue.
The decision not to invoke hook_init during update came from #179143: Do not fire bootstrap hooks during update. I did not read the entire issue so I do not yet fully understand why, though it seems that even at the time people were expressing reservations about it. I'll ping some of those people to see if they can chime in here.
Comment #8
moshe weitzman commentedThe justification for suppressing hook_init() starts at http://drupal.org/node/179143#comment-625762. But that problem is specific to the D5 => D6 major upgrade. Tossing hook_link() just for that one time problem seems excessive to me - we use update.php for every contrib minor upgrade, which is to say we use it a lot.
Except for that major upgrade, it will be safe to do anything you ant in hook_init() - we have just done a
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);.Personally, I think we can revert that part for D7.
Comment #9
gábor hojtsyThe less code we run on major upgrades, the better. And we are unfortunately not sure whether people upgrade from 6.0 to 7.0 or 6.11 to 7.5. So "except for the major upgrade" seems like non-trivial to implement (unless we just depend on the update function numbering or somesuch, but then update functions should be conditional on what kind of update is happening, ugh).
Comment #10
bjaspan commentedOkay, so how about not using hook_init() at all and just explicitly including the required files whenever field.module is loaded?
Comment #11
alex_b commented#10 fixes the problem I described in my initial post.
The approach seems sound, RTBC from my point of view.
Comment #12
moshe weitzman commentedGood enough for now. RTBC from me too.
Comment #14
alex_b commentedResolved conflicts and rerolled.
Comment #15
alex_b commented#14 merely resolves a conflict. Setting back to RTBC.
Comment #16
dries commentedCommitted to CVS HEAD. Thanks.