When using Node export/import the not nodeblock machine name is ignored.

a reduced snippet of a node for import...

array(
  (object) array(
      'vid' => '11',
      'uid' => '2',
      'title' => 'ttttttttsssssssss',
      'log' => '',
      'status' => '1',
      'comment' => '1',
      'promote' => '0',
      'sticky' => '0',
      'vuuid' => '                                    ',
      'nid' => '11',
      'type' => 'uwlib_static',
      'language' => 'und',
      'field_static_body' => array(
        'und' => array(
          array(
            'value' => 'sssssssssssssssssssssssssssss',
            'format' => 'plain_text',
            'safe_value' => "<p>sssssssssssssssssssssssssssss</p>\n",
          ),
        ),
      ),
      'cid' => '0',
      'nodeblock' => array(
        'nid' => '11',
        'enabled' => '1',
        'machine_name' => 'a_readable_name',
        'block_title' => 'ttttttttsssssssss',
        'view_mode' => 'full',
        'node_link' => '0',
        'comment_link' => '0',
        'translation_fallback' => '0',
      ),
    ),
)

Perhaps problem has something to do with including a copy of the nid in nodeblock array because that value wont be valid because node import will assign the object a new one after import.

I think this is high priority because node import is used often. Node import was the reason I created a patch some months ago for a named machine_name :)

After this issue is resolved I think the dev branch is in good shape.

Thanks

Comments

ronino’s picture

Status: Active » Needs review
StatusFileSize
new594 bytes

I had the same problem. The attached patch fixes this by adding the custom_machine_name field to the nodeblock section in the $node object in nodeblock_node_load(). This way nodeblock_node_update() correctly keeps the machine name.

ronino’s picture

StatusFileSize
new736 bytes

Here is a patch that addresses one thing you mentioned:

Perhaps problem has something to do with including a copy of the nid in nodeblock array because that value wont be valid because node import will assign the object a new one after import.

The patch makes sure that the nodeblock record is saved for the correct nid on the target system when a node is updated from another server. Without, you can't update an existing nodeblock node with a different nid on another system.

steverweber’s picture

Status: Needs review » Reviewed & tested by the community

Thanks
Both patches looks good.

Can someone else confirm, I love to see these two patches pulled into the dev branch.

idebr’s picture

Patch in #1 also fixes a fatal PDO error when an editor without 'administer nodeblock' permission saves a nodeblock with a custom machine name.

Johnny vd Laar’s picture

I've fixed the bug here:
Node export/import not compatible with Provide a machine name.

didn't use the patches.

Administer nodeblock permission does not exist anymore in the newest nodeblock so I'm not looking at any PDO errors.

Johnny vd Laar’s picture

Status: Reviewed & tested by the community » Fixed

Please reopen when you have any problems with node imports.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ronino’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs review

Johnny vd Laar wrote:

I've fixed the bug here:
Node export/import not compatible with Provide a machine name.

didn't use the patches.

Hmm, this is not fixed in the latest stable 7.x-1.4. How did you fix this without using the patches? After applying them, 1.4 works as expected considering the bugs described above.

Administer nodeblock permission does not exist anymore in the newest nodeblock so I'm not looking at any PDO errors.

This was just fixed as a side effect (mentioned in #4). The two bugs targeted with the patches #1 and #2 are described by the bug reporter. #3 confirms that the patches work so please really commit this to the current dev ;-).

Johnny vd Laar’s picture

Oh sorry i should have posted a link to the commit there:
http://drupalcode.org/project/nodeblock.git/commit/87639bf

this was the commit.

Johnny vd Laar’s picture

Status: Needs review » Closed (fixed)
ronino’s picture

Version: 7.x-1.x-dev » 7.x-1.6
Status: Closed (fixed) » Needs review
StatusFileSize
new1.28 KB

The issue with the machine name has been resolved, thank you Johnny vd Laar!

However, when importing a nodeblock node exported via node_export, the correct nid is still not set (see #2). This only works if I export and import a node on the same system as the nid stays the same. If I export a node on one machine and import it on another machine, the nodeblock data gets lost as $node in nodeblock_node_insert() and nodeblock_node_update() already contains the new nid from the target system, but $node->nodeblock['nid'] contains the old one from the source system.

I reworked the patch for 1.6 and enhanced it to fix both nodeblock_node_insert() and nodeblock_node_update().

  • Commit 87960fc on 7.x-1.x authored by Ronino:
    Issue #2006220 by Ronino | steverweber: Node export/import not...
Johnny vd Laar’s picture

Status: Needs review » Fixed

Seems to work. I've committed your fix here:
http://drupalcode.org/project/nodeblock.git/commitdiff/87960fc?hp=06f2d0...

Thank you!

ronino’s picture

Great! Thank you, Johnny!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.