I was importing a bunch of nodes 6.x nodes (using 6.x-3.1) into 7.x (using 7.x-3.x-dev) and kept hitting this error:
Fatal error: Cannot unset string offsets in sites/all/modules/contrib/node_export/node_export.module on line 718
This is line 718 (with some context):
if (variable_get('node_export_reset_path_' . $node->type, TRUE)) {
$node->path = NULL;
}
else {
unset($node->path['pid']); // Line 718
I made two discoveries:
- The nodes I was importing did not have $node->path['pid'], only $node->path.
- PHP throws an error when you try to treat a string like an array, as with unset().
Assuming, then, that if it exists, $node->path['pid'] should be a string (which makes sense) the attached patch resolves the error.
Comments
Comment #1
venutip commentedComment #2
dwaine commentedAfter updating from 6.x-2.24 to 6.x-3.1 my site is seeing this same issue while testing the node import process. The exact message is:
Comment #3
danielb commentedCan you see if this works as a replacement for line 718 in node_export.module ? If it does I would prefer to do it like this.
Comment #4
venutip commentedHi danielb,
Tried your fix and still hit the same error. The problem is that (for all my nodes, anyway) $node->path is a string, not an array, so PHP thinks we're trying to access the string using array notation, and so always returns the first letter of $node->path.
How about this patch?
Comment #5
danielb commentedI don't believe you.
Comment #6
danielb commentedBut seems you're right
http://www.magentocommerce.com/boards/viewthread/261346/
blooody php
Comment #7
danielb commentedCommitted something similar to your patch :)
Thanks!
Comment #8
venutip commentedHa ha, glad you decided I was not lying to you :)
Thanks!
Comment #9
chromix commentedWe need to have this same fix back-ported to 6.
Comment #10
chromix commented...and here it is. Test in good health.
Comment #11
chromix commentedsorry... this one fixes the extra spaces at the end of one of the lines (git will complain about it)
Comment #12
danielb commentedcheers, committed
Comment #14
opdaviesI'm getting a similar error:
Fatal error: Cannot unset string offsets in /home/odavies/unionlearn/drupal/modules/menu/menu.module on line 543
This only happens when I uncheck the option to reset menu links for this content type.
I'm using the 7.x-3.x-dev branch with Drupal 7.12.
Comment #15
opdaviesThis seems to be specific to the XML output. I've exported the content using the Node Code format, and it's importing OK, including the menu items.
If I'm able, then I'll post both versions of the exported code here.
Comment #16
danielb commentedPlease don't hijack issues. The same error message is not grounds for reopening, and in this case it isn't even the same.