I have a migration pulling in data from an XML document into a fresh Drupal 6 setup.

However, if I attempt to set a filter format for the body field I get these errors for each attempted import:

strpos() expects parameter 1 to be string, array given
File node/node.module, line 314

The configuration for the filter format looks like so:

$this->addFieldMapping('body', 'description')
      ->arguments(array('format' => 'full_html'))
      ->xpath('description');

I've traced part of the bug down to the function node_teaser being passed incorrect parameters, whereby the first paramter $body is actually an array. I can step around this issue by changing line 200 in migrate/plugins/destination/node.inc to

$node->teaser = node_teaser($node->body[0]);

but this then causes a different error which I haven't attempted to debug further:

mysqli_real_escape_string() expects parameter 2 to be string, array given File includes/database.mysqli.inc, line 329

I'm happy to help debug further, please just let me know what information I can provide.

Comments

torrance123’s picture

Also, I note at least one other person has reported the same issue: http://drupal.org/node/1174442#comment-5092820

torrance123’s picture

Also, if it's of any help, I have no 'body' field listed in the UI in the list of destination fields — this applies to both the default 'Story' and 'Page' content types as well as a custom type. Things are mostly pretty vanilla.

I can import into the body field just fine, however, so long as I don't set a text format filter on it, though migrate does complain that ""body" was used as destination field in "description" mapping but is not in list of destination fields".

mikeryan’s picture

Priority: Major » Normal
Status: Active » Fixed

The body and teaser got lost from the list of available fields when the subfield support was added, I've put them back.

As for the format - in Drupal 6 there was no machine name for text formats (i.e., "full_html" has no meaning), you need to use the numeric ID from the filter_formats table.

Alex Andrascu’s picture

Can you please provide an example:

        $this->addFieldMapping( 'body', 'user_comment' )
        ->arguments( array( 'format' => 2 ) );

where 2 is full_html, does the same thing.
Thanks

Alex Andrascu’s picture

Status: Fixed » Active
mikeryan’s picture

Status: Active » Fixed

Like body and teaser, format got lost from the list of node fields - on D6, format is a node field, not a subfield of the body.

Map as follows on D6:

$this->addFieldMapping('format')
     ->defaultValue(2);
Alex Andrascu’s picture

right *slaps self* thanks a lot :)

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Formatting correction

Chris Charlton’s picture

Issue summary: View changes

I got stung by this in a D7-to-D7 migration. No resolution yet.