I figured out what was causing my problem, and it was these two lines:
global $language; $node->language = ($language) ? $language->language : LANGUAGE_NONE;
Apparently, if $node->language is not set to LANGUAGE_NONE, then not all data for the node gets saved. I tried it with Locale enabled, with Locale and Content translation enabled, and with both of them disabled. The behavior is the same in all three cases.
So, I'm wondering if there is a "more correct" way of doing this. I want to be able to give people the option of sending messages in different languages and archive them as nodes in the language they were sent in. Unfortunately, based on what I've read on a.d.o, I'm not clear on how to do this.
On Sat, 17 Sep 2011 09:27:36 -0700 Jason Flatt drupal@oadaeh.net wrote:
For Drupal 7, I'm attempting to create a new node and save it in code. It was working at one time, but now is not and I cannot figure out what it is I did to break it.
The node object appears to be correct both before and after the save.
The node gets created and saved in the database, but only the title is saved with it. None of the data for the body or any of the custom fields gets saved.
I've been over the code a hundred times, tweaking this and that. I've reviewed a.d.o, blog postings, tutorials and various code, and I can't figure out what I've done wrong.
The code is here: http://drupalbin.com/19810
Thank you for any help or pointers anyone can offer me.