The Drupal 6-7 upgrade path does not attempt to preserve the description and required settings for node types. These are required fields by field API, so it leads to notices on node/n/edit as well as the loss of configuration data.
Sites that have already upgraded can work around this by saving the node type field settings again - which will fill in the default and remove the notices. We can't restore data for those sites though because it's already been destroyed on any site that upgraded.
The patch here adds those settings back if available, and adds some assertions to the existing node body upgrade test.
Original report:
Here's how I got the error:
1. clean d6.19 install
2. created a page (inserted title and body only)
3. upgraded to d7.x-dev (4 oct)
4. browsing to previous node edit page "/node/1/edit" gives the following error:
* Notice: Undefined index: description in field_multiple_value_form() (line 146 of /var/www/testsite//modules/field/field.form.inc).
* Notice: Undefined index: required in field_multiple_value_form() (line 164 of /var/www/testsite/modules/field/field.form.inc).
* Notice: Undefined index: required in field_multiple_value_form() (line 191 of /var/www/testsite/modules/field/field.form.inc).
running PHP Version 5.3.2-1ubuntu4.5
Comment | File | Size | Author |
---|---|---|---|
#56 | with_tests.patch | 1.5 KB | catch |
#55 | tests_only.patch | 877 bytes | catch |
#55 | with_tests.patch | 1.5 KB | catch |
#54 | tests_only.patch | 761 bytes | catch |
#54 | with_tests.patch | 1.38 KB | catch |
Comments
Comment #1
ahwebd CreditAttribution: ahwebd commentedSame error on "create" pages ("node/add/page" and "/node/add/story")
Comment #2
ahwebd CreditAttribution: ahwebd commentedAdded new content type and the error does not show on create/edit pages for nodes of the new content type, it shows only on create/edit pages for nodes of upgraded content types
Comment #3
BerdirThe problem is http://api.drupal.org/api/function/node_update_7006/7, that needs to define description/required (and probably other things), similiar to http://api.drupal.org/api/function/system_update_7060/7
Comment #4
ahwebd CreditAttribution: ahwebd commentedYes you're right, and this concerns the "body" field instances, there is missing data that should be created for it in the node update function:
we can see that "description" and "required" are missing in code above.
When creating new content type the body field instance is created with this code:
(modules/field_ui/field_ui.admin.inc)
where we can see that "description" and "required" are present
To find missing items in instances of fields created by an update, I'm putting here two entries from database table `field_config_instance` , one created by an upgrade from d6 and the other newly created in d7
we can see clearly that a number of items are missing on the upgraded one.
Don't know if this concerns other fields or only "body"
Note: the error disappears when: enabling module "field_ui", browsing to "manage fields" of content type and hitting "save'
Comment #5
KarenS CreditAttribution: KarenS commentedChanging the title to be more descriptive.
Comment #6
tobiasbComment #7
tobiasbComment #9
tobiasbComment #10
steinmb CreditAttribution: steinmb commentedI reported this dup #952970: Undefined index: required in field_default_form() and have tested the patch but it do not fix the problem. Still got the error message on both nodes with and without comments. The small patch do it's thing with getting the description in but I'm missing `min_word_count` col from my node_type.
SELECT `min_word_count` FROM `node_type`;
ERROR 1054 (42S22): Unknown column 'min_word_count' in 'field list'
Comment #11
tobiasbmin_word_count isn#t anymore in D7.
Comment #12
steinmb CreditAttribution: steinmb commentedOK, any other ideas why the patch did not fix the problem?
Comment #13
upandrunning CreditAttribution: upandrunning commentedDid an upgrade from 6.19 to 7 beta 2 and received the following msg when creating content:
* Notice: Undefined index: description in field_multiple_value_form() (line 146 of /home/mysite/public_html/mydir/modules/field/field.form.inc).
* Notice: Undefined index: required in field_multiple_value_form() (line 164 of /home/mysite/public_html/mydir/modules/field/field.form.inc).
* Notice: Undefined index: required in field_multiple_value_form() (line 193 of /home/mysite/public_html/mydir/modules/field/field.form.inc).
Comment #14
tobiasbComment #15
upandrunning CreditAttribution: upandrunning commentedInstalled 7.x-dev as suggested. Same issue.
* Notice: Undefined index: description in field_multiple_value_form() (line 155 of /home/mysite/public_html/mydir/modules/field/field.form.inc).
* Notice: Undefined index: required in field_multiple_value_form() (line 173 of /home/mysite/public_html/mydir/modules/field/field.form.inc).
* Notice: Undefined index: required in field_multiple_value_form() (line 202 of /home/mysite/public_html/mydir/modules/field/field.form.inc).
Comment #16
tobiasbYou need the patch for D7 before you upgrade from D6 -> D7.
Comment #17
jcarlson34 CreditAttribution: jcarlson34 commentedThis isn't a fix but offers a temporary solution / workaround for avoiding this error message. Seems obvious but this got me around the error:
Before upgrading, just re-add a body field to the content types that don't have them. This is as simple as re-adding the word 'Body' in the Submission Form Settings section of the Content Type edit screen.
Also, add a description to all content types that didn't have them.
Upgrade the site to Drupal 7.
Delete the Body field in Manage Fields in Drupal 7 content types.
Comment #18
jcarlson34 CreditAttribution: jcarlson34 commentedThe patch in #9 (or some other core fix) must have worked because I tried again and upgraded my site with a post D7 beta 3 dev build and forgot to give my node's bodies before I did so.
I have not received the errors in #15 that I did on a previous earlier 7.x dev upgrade. Since no one has posted about this for a while (and I assume people are upgrading their sites in greater numbers) I think it is safe for someone to make this on RTBC.
Comment #19
bojanz CreditAttribution: bojanz commentedThe fix is correct.
Might be better as:
but that's nitpicking.
Leaving the RTBC to someone who has an opinion on the above.
Comment #20
catchOr to continue the nitpicking, just:
'required' => (int) !empty($node_type->min_word_count),
Comment #21
anselm.marie CreditAttribution: anselm.marie commentedOk something strange just happen but in a good way and I need someone to confirm that this works. Follow these steps:
1. Click on Structure > Content types.
2. Click on manage fields for either "page" or "story".
3. Create a new field. Label -> "test", Name -> field_"test", Field -> "Long text and summary", Widget -> "Text area with a summary"
4. Hit save. Now go to an existing story/page or create a story/page.
5. At this step the errors disappeared for me. Go back to the field you just created and delete it.
6. Return back to an existing story/page or create a story/page. The errors should still be gone.
I did this for both story and page nodes and it worked. I hope it does the same for you.
Comment #22
nitmd CreditAttribution: nitmd commentedRan into this problem this morning and tried anselm.marie's solution; easy and it worked for me.
Comment #23
rack88 CreditAttribution: rack88 commentedYeah, I had the same problem with a D7 upgrade. anselm.marie's solution worked for me. Seems like a strange issue though.
Comment #24
KarenS CreditAttribution: KarenS commentedEven simpler fix -- go the the Manage fields page and just save it. No need to add a new field. Just do that for each content type and the error is gone.
The Manage fields page does not alter the content type definition itself, and it appears that making almost any change to anything fixes this, so I suspect we need to do something like run field_cache_clear() (which happens when you add a field, save the Manage fields page, etc.)
Comment #25
KarenS CreditAttribution: KarenS commentedConfirming part of what I said above, there should be no need to add a value for 'required' or 'description' to the array when the body is created. The docs in field.info.inc clearly say that it is not necessary to add either of those values, that defaults will be created. And the defaults are created in _field_write_instance() in field.crud.inc.
The problem is not that the field was not created correctly, it is that we are still using a (cached) value that is wrong until the caches get cleared.
I tried adding field_cache_clear() to the end of the process that created the field but that didn't quite work. It may requiring manually clearing the cache table where the field settings are stored (as entity_info). There are some static caches in there too, so it may be tricky trying to get this cleared out properly in the update hook.
Comment #26
KarenS CreditAttribution: KarenS commentedAh, the real problem is that the update process uses _update_7000_field_create_instance() instead of field_write_instance(), bypassing those default settings. A better fix would be to ensure that this function sets the same default values that the normal one sets. Because other modules might be relying on this function during the update process.
Comment #27
markandrewsuttonFor those of you just looking to get rid of the error, KarenS solution from #24 worked for me .. .
Comment #28
Mapi99 CreditAttribution: Mapi99 commented#24 works for me aswell.
Comment #29
EnjoyLife CreditAttribution: EnjoyLife commented#24 works for me too. For anyone else having this problem: Go to "Administration > Structure > Content Types." For each content type click on "Manage fields" and just press the save button at the bottom. If you do this for each content type this should fix the problem. Thanks KarenS.
Comment #30
joergent CreditAttribution: joergent commented#29 does not work for me
Comment #31
randallnet CreditAttribution: randallnet commented#24 works for me too, a thousand thanks ;)
Comment #32
Janne CreditAttribution: Janne commented#21 seems to have worked for me. Strange issue, though.
Comment #33
deajan CreditAttribution: deajan commentedSolution #24 worked fine for me. Got that error after D6.15 to D6.20 to D7.0 upgrades.
Comment #34
hcderaad CreditAttribution: hcderaad commented#24 did remove the notices, but now i'm stuck with a different field order (attached files are above the body) and reordering them doesnt work.
Comment #35
Dave Sandilands CreditAttribution: Dave Sandilands commentedIs this another example of basically the same issue?
I had an auto-install done by Fantastico (via CPanel) mistakenly thinking I'd get the latest version. Turned out to be 6.18.
Apart from a few settings in settings.php, which I kept a copy of, I made no changes at all.
Set Drupal to maintainance mode , deleted all the files , copied over latest stable release ,7.1, copied back my settings.php and ran update.php.
No errors reported
Turned on some modules, added a new theme (Danland) and all seemed fine.
Decided to create my 1st piece of content ,using the story type.
instantly got this:
I tried the method mentioned above regarding going to Structure>content types>edit>save(without changing anything) but it didn't have any effect.
Hope you clever people in Drupal land can help because I'm lost (and I can hear the Devil whispering to me,"should have gone to WordPress,O brainless one" )
Update:
I reviewed the suggestion in #24 and noticed I didn't actually do what it said. Having tried again, I can report that it worked perfectly. Faith restored :)
Comment #36
mobonobomo CreditAttribution: mobonobomo commentedConfirming that #24 worked for me as well. I cleared my caches at Configuration > Performance before navigating to the "Manage fields" page for the particular content type and only clicking the "Save" button.
The errors on node/*/edit are gone, but is there some underlying problem that might rear its head in the future?
Comment #37
ryivhnn CreditAttribution: ryivhnn commented#24 worked. Glad it's a relatively simple fix (for most people), hopefully just as easy to find and fix whatever causes that to happen in the first place :)
Comment #38
philosurfer CreditAttribution: philosurfer commentedI confirm #24 works as well.
This was a 6.2 to 7.x upgrade.
Comment #39
enfineitz CreditAttribution: enfineitz commented#5 worked for me. BUt I am getting another error for the CKeditor, which I’ll need to examine.
Comment #40
Garmisch CreditAttribution: Garmisch commentedConfirmed. Solution #24 works fine. Got error after D6.20 to D7.0 upgrade.
Comment #41
bug_over CreditAttribution: bug_over commented#9: drupal_931512.patch queued for re-testing.
Comment #43
craigtockman CreditAttribution: craigtockman commented#24 worked for me as well. Thanks.
Comment #44
Lugir CreditAttribution: Lugir commentedConfirmed. Solution #24 works fine. Got error after D6.20 to D7.0 upgrade.
Comment #45
steinmb CreditAttribution: steinmb commentedNeed to get fixed in D8 and then backported according to http://drupal.org/node/767608.
Comment #46
Kev CreditAttribution: Kev commentedUpgraded from drupal 6.20 to 7 and run into the same error and it took quite some time to find this report.
#24 solved the issues for me, too.
This should be included in the upgrade instructions.
Comment #47
lishaw1968 CreditAttribution: lishaw1968 commentedSame situation as Kev, Upgraded from 6.2 to 7, ran into the error, applied the solution
#24, the error is now gone.
Comment #48
senortim CreditAttribution: senortim commented#24 worked for me as well. (Thanks KarenS!) But I think mine was an upgrade from D7.dev to D7. I was trying a fresh start with D7 for this project! :-)
Comment #49
robinoz CreditAttribution: robinoz commented#24 worked for me as well. Thanks Karen! My problem followed a fresh install of D7 with Fantastico so I don't think the problem is related to upgrades.
Comment #50
steinmb CreditAttribution: steinmb commented@robinoz: Why did you change version back to 7?
Comment #51
catchComment #52
catchRe-uploading #9, moving back to 7.x since this is upgrade path only and 8.x no longer contains the 6.x-7.x upgrades.
If that patch passes tests, ideally we can add an upgrade path test to confirm it fixes the issue. Since there's workaround for existing installs just fixing future upgrades from 6.x-7.x seems OK here, it' s configuration loss rather than proper data loss but enough people ran into it that it's annoying enough to stay major.
Comment #53
k4rtik CreditAttribution: k4rtik commentedIs this patch required anymore?
#21 worked for me, not sure whether I will face any future problems in this regard.
Comment #54
catchTests only, tests + patch.
@kartiksinghal - if you have a site and you've done the workaround, you don't need to worry about it. However we need to fix it for sites that are yet to upgrade.
Comment #55
catchI thought I'd need to change data in the upgrade path to test required, but that was wrong, so extra assertion added - should have two exceptions and two fails without the fix.
Comment #56
catchShould use assertIdentical since we have that.
Comment #57
clemens.tolboomI reopened #952970: Undefined index: required in field_default_form() as that differs from this issue and patch #56 did not solve it either :-(
This is about
and not
Comment #58
marcingy CreditAttribution: marcingy commentedPatch in 55 looks good
Comment #59
webchickCommitted and pushed to 7.x. Thanks!
Comment #61
raefrog CreditAttribution: raefrog commentedI just did a clean install to 7.7 and I am getting these errors on both the story and Page content, as well as the Product and Product kit from Ubercart.
Comment #62
steinmb CreditAttribution: steinmb commentedThat could be Übercart related. pls. verify that you have them on a clean D7 without any extra modules installed.
Comment #63
rolandu CreditAttribution: rolandu commentedUpgraded from 6.19 to 7.7 a while ago and later to 7.8. Had the problem all the time until I found this thread.
Reply #24 solved the problem.
However, is this issue really to be considered fixed if the db-upgrades didn't solve it?
Comment #64
egfrith CreditAttribution: egfrith commentedI've also had this problem, even after an upgrade from 7.7 to 7.8. The solution at #24 worked for me too.
Comment #65
kbell CreditAttribution: kbell commentedI'm in 7.8 (this is NOT an upgrade from D6 either, just straight D7), latest version of CKEditor, and I'm having the same problem. Solution #24 did NOT work for me, however. What did change was that now when I try to edit or create a new node, the Body field outlines in red before disappearing(!). Ring a bell, anyone? Does this issue belong elsewhere or am I in the right place?
Thanks,
Kelly Bell
Comment #66
ssace CreditAttribution: ssace commentedI just did a upgrade from 6 to 7.12. Got the same error in the POLL content type.
#24 above worked for me to clear the field.form.inc errors
Comment #66.0
ssace CreditAttribution: ssace commentedUpdated issue summary.