HI there,
I used the module with youtube.
Upload the file with filefield & show it with em field.

After I deleted a node, I got this error:
unserialize() expects parameter 1 to be string, array given in /is/htdocs/xx/www/drupal/sites/all/modules/emfield/emfield.cck.inc in Zeile 87.

What could be the cause? The file was not deleted on you tube server.

Cheers

CommentFileSizeAuthor
#2 emfield.cck_.diff252 byteskobnim

Comments

arthurf’s picture

Project: Media Mover » Embedded Media Field
Version: 6.x-1.0-beta9 » 6.x-3.x-dev

Sounds like this is an issue with emfield not media mover.

kobnim’s picture

Version: 6.x-3.x-dev » 6.x-2.5
Component: Miscellaneous » Code
StatusFileSize
new252 bytes

I am having the same problem. Here are steps to duplicate the problem:

I. Set-up
- create a node-type containing a filefield an an emfield.
- create this mediamover config:
-- harvest: harvests files from the filefield,
-- process: upload harvested files to youtube
-- complete: populate emfield with the youtube url

II. Run-time
- user creates a node and uploads a file
- system runs the mediamover config, which populates the emfield with the youtube url.
- admin goes to admin/content/node and deletes the node

Result:
- warning: unserialize() expects parameter 1 to be string, array given in emfield.cck.inc on line 87

The problem happens inside function _emfield_emfield_field(), $op='load'.
The function expects $items[$delta]['data'] to be a string, but it is instead is an array:
$items[$delta]['data'] = array(0 => FALSE)

I was able to resolve the problem by replacing:

$data = (array)unserialize($items[$delta]['data']);

with:

if (is_string($items[$delta]['data'])){
  $data = (array)unserialize($items[$delta]['data']);
} else {
  $data = NULL;
}

I am attaching a patch, though I am not sure this is the right solution, because I do not understand what is causing $items[$delta]['data'] to be an array rather than a string.

kobnim’s picture

After further investigation, I found that the source of the problem was in the media_mover module. One of the media_mover contrib modules, mm_emfield.module, calls node_save() while node_delete() is executing, and this causes a bunch of problems including the "unserialize" warning. See here for more details:
http://drupal.org/node/1540278

Nonetheless, it may still be a good idea to modify _emfield_emfield_field() (as in the patch submitted above) to allow for the possibility that $items[$delta]['data'] is not a string.