Jump to:
| Project: | Node export |
| Version: | 7.x-3.x-dev |
| Component: | Node export |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed |
Issue Summary
In conversations throughout the years it was decided that importing nids was a really bad idea. However, the node_export_relation module relies on nids. For example, here's an export of a basic page node A that has a relation on a basic page node B on a fresh D7 install with the reference field as field_reference
array(
array(
'vid' => '1',
'uid' => '1',
'title' => 'a',
'log' => '',
'status' => '1',
'comment' => '1',
'promote' => '0',
'sticky' => '0',
'vuuid' => '138ee511-1397-ec64-417e-a5b2e8d4dd35',
'nid' => '1',
'type' => 'page',
'language' => 'und',
'created' => '1320864620',
'changed' => '1320864690',
'tnid' => '0',
'translate' => '0',
'uuid' => 'eed010a9-082e-5c84-b913-b6e7f0f4a69f',
'revision_timestamp' => '1320864690',
'revision_uid' => '1',
'body' => array(
'und' => array(
'0' => array(
'value' => 'a',
'summary' => '',
'format' => 'filtered_html',
'safe_value' => '<p>a</p>
',
'safe_summary' => '',
),
),
),
'field_reference' => array(
'und' => array(
'0' => array(
'nid' => '2',
),
),
),
'rdf_mapping' => array(
'rdftype' => array(
'0' => 'foaf:Document',
),
'title' => array(
'predicates' => array(
'0' => 'dc:title',
),
),
'created' => array(
'predicates' => array(
'0' => 'dc:date',
'1' => 'dc:created',
),
'datatype' => 'xsd:dateTime',
'callback' => 'date_iso8601',
),
'changed' => array(
'predicates' => array(
'0' => 'dc:modified',
),
'datatype' => 'xsd:dateTime',
'callback' => 'date_iso8601',
),
'body' => array(
'predicates' => array(
'0' => 'content:encoded',
),
),
'uid' => array(
'predicates' => array(
'0' => 'sioc:has_creator',
),
'type' => 'rel',
),
'name' => array(
'predicates' => array(
'0' => 'foaf:name',
),
),
'comment_count' => array(
'predicates' => array(
'0' => 'sioc:num_replies',
),
'datatype' => 'xsd:integer',
),
'last_activity' => array(
'predicates' => array(
'0' => 'sioc:last_activity_date',
),
'datatype' => 'xsd:dateTime',
'callback' => 'date_iso8601',
),
),
'cid' => '0',
'last_comment_timestamp' => '1320864620',
'last_comment_name' => NULL,
'last_comment_uid' => '1',
'comment_count' => '0',
'name' => 'admin',
'picture' => '0',
'data' => 'b:0;',
'path' => FALSE,
'menu' => array(
'link_title' => '',
'mlid' => 0,
'plid' => 0,
'menu_name' => 'main-menu',
'weight' => 0,
'options' => array(),
'module' => 'menu',
'expanded' => 0,
'hidden' => 0,
'has_children' => 0,
'customized' => 0,
'parent_depth_limit' => 8,
'description' => '',
'enabled' => 1,
),
'node_export_drupal_version' => '7',
'#_export_node_encode_object' => '1',
),
array(
'vid' => '2',
'uid' => '1',
'title' => 'b',
'log' => '',
'status' => '1',
'comment' => '1',
'promote' => '0',
'sticky' => '0',
'vuuid' => 'ad784269-d22a-f714-19cd-a691018dee49',
'nid' => '2',
'type' => 'page',
'language' => 'und',
'created' => '1320864630',
'changed' => '1320864630',
'tnid' => '0',
'translate' => '0',
'uuid' => 'b9e59753-ae5b-1bb4-31b9-56e71b95a12e',
'revision_timestamp' => '1320864630',
'revision_uid' => '1',
'body' => array(
'und' => array(
'0' => array(
'value' => 'b',
'summary' => '',
'format' => 'filtered_html',
'safe_value' => '<p>b</p>
',
'safe_summary' => '',
),
),
),
'field_reference' => array(),
'rdf_mapping' => array(
'rdftype' => array(
'0' => 'foaf:Document',
),
'title' => array(
'predicates' => array(
'0' => 'dc:title',
),
),
'created' => array(
'predicates' => array(
'0' => 'dc:date',
'1' => 'dc:created',
),
'datatype' => 'xsd:dateTime',
'callback' => 'date_iso8601',
),
'changed' => array(
'predicates' => array(
'0' => 'dc:modified',
),
'datatype' => 'xsd:dateTime',
'callback' => 'date_iso8601',
),
'body' => array(
'predicates' => array(
'0' => 'content:encoded',
),
),
'uid' => array(
'predicates' => array(
'0' => 'sioc:has_creator',
),
'type' => 'rel',
),
'name' => array(
'predicates' => array(
'0' => 'foaf:name',
),
),
'comment_count' => array(
'predicates' => array(
'0' => 'sioc:num_replies',
),
'datatype' => 'xsd:integer',
),
'last_activity' => array(
'predicates' => array(
'0' => 'sioc:last_activity_date',
),
'datatype' => 'xsd:dateTime',
'callback' => 'date_iso8601',
),
),
'cid' => '0',
'last_comment_timestamp' => '1320864630',
'last_comment_name' => NULL,
'last_comment_uid' => '1',
'comment_count' => '0',
'name' => 'admin',
'picture' => '0',
'data' => 'b:0;',
'path' => FALSE,
'menu' => array(
'link_title' => '',
'mlid' => 0,
'plid' => 0,
'menu_name' => 'main-menu',
'weight' => 0,
'options' => array(),
'module' => 'menu',
'expanded' => 0,
'hidden' => 0,
'has_children' => 0,
'customized' => 0,
'parent_depth_limit' => 8,
'description' => '',
'enabled' => 1,
),
'node_export_drupal_version' => '7',
'#_export_node_encode_object' => '1',
),
)You can see that field_references uses nid, which can be exceedingly problematic. What I suggest is to use the uuid instead. Since node reference needs nid to work however, the logic on import would likely go:
- check for node reference fields
- using the uuid in the field export, fetch nids from uuid by using entity_get_id_by_uuid()
- use the nid in the field to satisfy node reference
And on export, instead of using the nid field, use uuid.
I took a stab at it, but too much PHP makes me angry, but it's likely altering the logic in node_export_relation_node_export_alter(), which only references nid right now. It looks like node_export_relation_node_import_alter() already tries to map uuid to nid.
Comments
#1
This is probably what will fix this problem #1294530: Node references only relate properly when done in the same import.
#2
Had a look at doing this, and it's not that simple. The referenced node might not be imported yet, and so the conversion back to nid is not possible until that happens. So need to come up with something to handle this situation.
#3
Not sure if this is worth fixing as I'm looking for another solution to the Node References problem.
#1586204: Improve dependency handling