I ran into a problem with node_import and tracked it down to date_selector_make_dbdate() in date.inc. When previewing the imported nodes, the $array argument to this function is actually a properly formatted ISO date string, not an array. This is necessarily the case because node_import allows the user to submit anything which strtotime() can parse, and uses the date module functions themselves to ensure the input is valid before calling node_view() to preview the imported data.
The problem is that node_view invokes date's date_widget() because nodes are shown in preview mode, with no nid present in the node object. With text field date fields, this is not a problem, since date_text_make_dbdate() effectively sees that the input is already a valid ISO date and returns it. However, date_selector_make_dbdate() assumes the field is an array, and if given a valid ISO date as input returns an empty date, thus dropping the date field from the imported content.
There are obviously several places where this could be averted, but I believe the most robust in terms of making the date APIs easy to use from other modules which programmatically create nodes would be to check in date_selector_make_dbdate() for input which is already a valid date, and in that case make no changes.
| Comment | File | Size | Author |
|---|---|---|---|
| date.inc_.patch | 1.03 KB | mvc |
Comments
Comment #1
mvcOops, I forgot to link the problem description from the node_import issue queue: http://drupal.org/node/254943
I've create this as a new issue here in case it's decided that this problem is better solved in that module.
Comment #2
HallSL commentedI believe I'm having this same problem, but I'm using 5.x-2.x-dev so I can't try the patch. My situation -- I'm importing a set of dates using node_import. All seems well in the preview, but when the import actually occurs, the until date is NULL. Thanks.
Comment #3
karens commentedI'm not making changes to the 5.1 version. I'm officially recommending you move to the 5.2 version now. If you have problems in that version you can check for existing issues or add new ones. Feature requests are now getting posted to the D6 version to be back-ported to 5.2.