I am running into a strange issue where I can't export some of the cck types I make. Here is the steps I have gone through to reproduce the error.
Create a content type, with the following:
-Name: Topic
-Type: topic
-Description: A topic is the top-level organizational placeholder
-Body field label: Description
Everything else I left at default
Exporting this content type works just fine. My issue is with the next one.
I create another content type with the following:
-Name: Goal
-Type: goal
-Description: Goals belong to a particular topic.
-Body field label: Description
Create the content type and then go back and add a field to it with these settings:
-Name: goal_topic
-Field type: Node Reference -> Select List
Click 'Create Field' then then fill out the next form with these settings:
-Label: Topic
-Check the box next to required
-Check the box next to topic
Click 'Save Field Settings'
Now go try to export the Goal content type. I get the following errors:
* Topic : This post can't be referenced.
* The default value is invalid.
I thought maybe because the field is required, and I haven't set a default value, things weren't working so I went back and unchecked Required, but I still get the same errors. Any Ideas? Anyone else able to reproduce this?
As a sidenote, I have a bunch of other CCK types to create this hierarchy where
Topics have Goals, Goals have Objectives, Objectives have Action Steps.
I use node references on the rest on down and they export just fine. Goals is just being stubborn and won't export. Any insight is appreciated.
Thanks,
-Steve
Comments
Comment #1
verbal@drupal.org commentedI narrowed the problem down a bit, but I dont understand why this export would work in the first place.
from line 113 of nodereference.module
doing some debugging I was able to produce this output
doing some reading of the _nodereference_potential_references() function, the part of the code that is returning an empty array, which subsequently gets stored into $refs is:
So my understanding is that because there are no nodes of the Topics content type, the select statement returns Nothing in the query. And a check is done to see if 0 is in the empty array, which it isn't, and an error is returned. So how would you export a type where a nodereference is required, but there are no nodes of the referenced type yet? It seems like there needs to be a modification to how cck nodereference deals with required fields that do not have any nodes of the required type yet. During the use case of my CCK types, the user will be probably create a "Topic" and then create a "Goal", but the nodereference field is still required because a Goal belongs to a Topic, and should not be able to be created without the reference to the topic. Anyone else having this issue, or at least understand the problem here?
-Steve
Comment #2
verbal@drupal.org commentedUgh.. this still isn't working. I went as far as using devel module and recorded the macro of submitting these two content types and that is even crashing on the Goals content type.
-Steve
Comment #3
jdevoid commentedI ran into this problem as well. My solution to get around it was to add an check to the validation if statement(see the 2nd if statement).
it appears that this validation function is being run even on the admin pages for output and that is the cause of the problem(kinda hope I am wrong but the fix still works as I have used it).
Hope this helps out.
Jeremy Devoid
Comment #4
rokrSteve, are you using "Auto Nodetitles"? I recently ran into the same problem. When i disable "Auto Nodetitles" for the specific content type, node referencing works fine. While enabled an error appears after previewing/submitting which tells: "This post can't be referenced." Can't really tell if this is an issue of CCK, Auto Nodetitle, maybe Token.
Please tell me if you got news about that issue.
ciao, Ronald
Comment #5
rokrIn addition to my last comment i have to say that it works fine with a fresh install of drupal using only the few modules needed (cck node reference, token, auto nodetitles) in current versions (stable and dev). The nice side of this fact is i got this working in general. The bad: something still is wrong with the other instance of drupal and i don't know which kind inconsistence happened and which module was guilty. I stumbled upon this issue while i was looking for error message "This post can't be referenced."
cheers, shibby
Comment #6
aangel commentedI'm having the same problem and upgrading the modules did not get rid of the error.
However, your workaround did get rid of the error. Thanks for providing it.
Comment #7
gregglesI just ran into this problem as well. It's a really old installation I use for development. CCK was on 5.x-1.5 so I upgraded it (I know that was insecure and buggy, but this was just local and runs behind multiple firewalls...).
I can't really offer any advice on what might have caused this. I've installed and uninstalled so many modules that it could have been anything. I followed the advice from comment #3 to add
&& arg(0)!='admin'to the second if and that "fixed" the problem by letting me export the data.Comment #8
gregglesSome more information on the topic - I exported this (using the suggested workaround/hack) and then imported it into a new site that was a completely fresh install. The import failed. I then manually recreated the field and tried to export this new definition and it failed again. So, I think that limits it down to something specific to this field and no longer related to my old system nor a cck field that gets upgrade.
Interestingly, this only affects one of my fields on a site that uses nodereference three times.
So, that last line is what helped me figure this out. To fix the problem I added a second field "dummy" to this content type. Then it exported the data (I didn't try an import yet).
I'm changing this to a bug report though I'm not sure how to fix it at least we have more solid steps to repeat.
Comment #9
scor commentedI'm facing the same problem, it seems to happen with any 'nodereference_select' widget type, even if there already exists nodes of the referenced type.
marked http://drupal.org/node/186579 as duplicate.
@greggles: have you tried to reimport the content type with the second 'dummy' field? did it work?
EDIT: reposting greggles' fields in table layout:
Comment #10
gregglesThanks for the reformat - somehow my formatting got lost. No - I haven't tried an import with that content type again.
Comment #11
colanJust thought I'd point out that this has nothing to do with the Automatic Nodetitles module. I've run into this without using it.
Comment #12
isaac77 commentedLike scor (comment #9), my experience leads me to believe this issue is related use of the select list widget. After changing my nodereference field to use the autocomplete widget, I was able to export the content type without the "This post can't be referenced" and "The default value is invalid" errors.
Comment #13
karens commentedThis is the a part of the problem in #128038: Critical failures using drupal_execute() on nodes with CCK fields, so we'll work on it there.