Fatal error: Cannot unset string offsets in .../image/contrib/image_attach/image_attach/image_attach.module on line 397

I've updated to the latest version as of today, all modules up to date.

The error happens when i create a type of content node, with an image attached.

Any ideas?

Comments

victor.stan@gmail.com’s picture

This is my temporary fix, I don't know if it's the right one or not, please check if it's correct, Thanks!

#390 of image_attach.module
/**
* Extra submit handler for node forms.
*/
function image_attach_node_form_submit(&$form, &$form_state) {
// Clear the 0 key in the iids array that arises from selecting the 'None'
// option. We do this here so image_attach_nodeapi() gets clean data.
if(isset($form_state['values']['iids'][0]))
{
// var_dump($form_state['values']['iids'][0]);
unset($form_state['values']['iids'][0]);
}
}

joachim’s picture

Status: Active » Postponed (maintainer needs more info)

All works fine for me (and for everyone else, I assume, otherwise the issue queue would be screaming with it).

Can you make sure you have the latest version of the code, as this sounds related to a recently-fixed bug. Also, can you try disabling other modules that interact with nodes, as they may be causing the problem.

Finally, can you give the precise steps to reproduce this bug?

colinmccabe’s picture

I get this message when using the Node Import module. The type of node I am importing has image attach enabled. Import works fine with content types that don't have image attach enabled.

colinmccabe’s picture

Also, when I add nodes of the offending content type manually everything works fine.

joachim’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

There's an existing bug about node import. And IIRC it's node import's problem ;)

colinmccabe’s picture

Anyway, I tried victor.stan's code and it seems to be working.

Drupal Centric’s picture

I've a similar problem: Fatal error: Cannot unset string offsets in... /httpdocs/sites/all/modules/image/contrib/image_attach/image_attach.module on line 402 when updating/saving a page.

Using 6.x-1.0beta5 and I also tried the updated 6.x-1.0 using Drupal 6.19 but not fixed.

I tried this fix http://drupal.org/node/747900 and the code above but no joy. I don't have the node import module in use.

alexbk66-’s picture

I had the same problem when I had the Form module enabled.

After disabling form - the error is gone. Not sure if it's the cause though, as always with Drupal.

Screenack’s picture

The change in #1 is working for me for now (WSOD without it)

dimitriseng’s picture

I am also using Node Import with Ubercart and I am getting this error at the final step of the import process. I can confirm that after applying #1 this error is resolved. Can somebody confirm if the solution in #1 could have any side effects and if not could this be commited? Thank you.

joachim’s picture

Status: Closed (duplicate) » Active

*sigh* All these modules should be doing node_save(), not pretending to save forms. But it looks like we may need to babysit.

Can someone actually roll this change as a patch please?

jonathan1055’s picture

Hi Joachim,
Long time since I was on this board. Just started using Node Import today and got hit with WSOD in step 7 of 8. Eventually traced the error

PHP Fatal error: Cannot unset string offsets in .../sites/all/modules/image/contrib/image_attach/image_attach.module on line 408

then found #875224: Import wizard breaks when content type has image attach and was directed to this thread.

It is obviously still a problem in Node Import. Has it been fixed in any of the other reported modules above? If it is just node import I'll try to fix it there, but if there are many other modules, then yes we may have to babysit and cater for it here.

Jonathan

aproka’s picture

I believe that this addresses this issue:

Index: image_attach.module
===================================================================
--- image_attach.module
+++ image_attach.module
@@ -239,7 +239,7 @@
if ($may_attach_existing || $has_existing_images) {
$form['image_attach']['iids'] = array(
'#type' => 'select',
- $value => empty($node->iids) ? NULL : $node->iids,
+ $value => empty($node->iids) ? array() : $node->iids,
'#multiple' => TRUE,
'#size' => 6,
// Title, options and description are set just below.