Existing node IDs; User IDs; created and changed timestamps

vik4 - December 7, 2005 - 13:59
Project:Import-export
Version:4.6.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

I'm trying to use this module to import data from another CMS, but was hoping to keep existing Node IDs. After some stuffing about, I managed to import some stories, but only using newly created node IDs. If I set the ALLOW_FORCE_NEW_NODE_ID to 1 as another forum topic suggests, it comes up with an error message:

user error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '0 = '', nid = '101111', type = 'story', title = '...
query: UPDATE node SET 0 = '', nid = '101111', type = 'story', title =
...
in /var/www/drupal/includes/database.mysql.inc on line 66.

for each node I try to import.

Inspecting the database afterwards, the new nodes are created in the node table, but only nid, type, and title fields are correct; all the remaining numeric fields are 0 and the text fields are empty. I can't work out what is going on here.

Another issue involved user IDs - the <user uid="x">username</user> xml field seems to be ignored when the import is successful, and the admin user (uid=1) is used (or perhaps the uid of the user doing the importing). Is it possible to import the user field correctly? Further, is it possible to do this with only the username? i.e. without the numeric uid?

Lastly, I modified the code on lines 676 and 677 of import_export.module to allow for setting the created and changed timestamps for imported stories:
if( !$node->changed) { $node->changed = time(); }
if( !$node->created) { $node->created = time(); }
This is useful for importing stories off an existing system where timestamps need to be kept as they were.

 
 

Drupal is a registered trademark of Dries Buytaert.