clean up form data in submit handler, not hook_nodeapi -- produces PHP Fatal Error with Node_Import

sphopkins - September 27, 2009 - 18:52
Project:Image
Version:6.x-1.0-beta3
Component:image_attach
Category:bug report
Priority:critical
Assigned:Unassigned
Status:postponed (maintainer needs more info)
Description

Please see my description here #589422: PHP fatal error

I think that a change in Image.Module has impacted another module

#1

sphopkins - September 27, 2009 - 18:53
Component:image.module» image_attach

#2

joachim - September 27, 2009 - 22:37

It helps if you repeat the problem here:

Drupal 6.13, Image 6.x-1.0-beta3

When attempting an import (that had worked flawlessly before) I get the following error on my server:

PHP Fatal error: Cannot unset string offsets in /var/www/html/sites/all/modules/image/contrib/image_attach/image_attach.module on line 343, referer: http://x.x.x.x/?q=admin/content/node_import/41

Can you confirm your line 343 is this:

      // Unsetting the "- None -" entry from the form select entries
      unset($node->iids[0]);

If so, I'm sure there are better places for this than hook_nodeapi -- it's dealing with a quirk of the form, whereas hook_nodeapi is meant to be general. We should move it to a submit handler perhaps?

On the other hand, apparently
"PHP 5 seems to have an error where it tries to treat strings as arrays instead of highlighting the error"
did you run update.php after upgrading to the latest image module?

#3

sphopkins - September 28, 2009 - 01:00

I will confirm tomorrow when I have full access to my server. However as I have not touched anything I am sure it is whatever you guys released ;-)

I did run update.php but I will verify that it has been completely done...

#4

sphopkins - September 28, 2009 - 19:23

Confirmed:

// Unsetting the "- None -" entry from the form select entries
      unset($node->iids[0]);

As well I have confirmed that update.php was run, and I reran it to verify.

Hope this helps.

#5

joachim - September 28, 2009 - 22:46

Does commenting out that line fix the problem?

#6

sphopkins - September 29, 2009 - 00:09

I will test that. I am not normally comfortable changing some of the code without someone who knows what is happening giving me the go-ahead !

#7

sphopkins - September 29, 2009 - 19:35

Commenting the line out worked to allow the Node_import to work properly.

Thanks for reviewing.

#8

joachim - September 29, 2009 - 20:00
Title:PHP Fatal Error - interaction with Node_Import ?» clean up form data in submit handler, not hook_nodeapi -- produces PHP Fatal Error with Node_Import

Thanks for confirming.
Better title.

#9

joachim - October 3, 2009 - 11:53
Status:active» needs review

Please could you test this patch?

You'll need either a clean copy of beta3 or the dev release to apply it to.

This patch also needs to be tested for regular use of image attach: creating and editing nodes normally, without node_import.

AttachmentSize
589428.image_attach.clean-iids-submit.patch 1.73 KB

#10

sphopkins - October 5, 2009 - 23:41

I will look at this patch. I only have a production server so I am leery of messing it up ;-)

#11

joachim - October 6, 2009 - 08:33

The drupal docs have a section on running a test server locally. This is a good idea to have in general, and is a lot easier to set up than it used to be: basically, xampp on Windows and mamp on a mac.

#12

sphopkins - October 6, 2009 - 12:00

Yeah I have MAMP Pro and I did use it for testing to get the website up and running but it has gone stale since I implemented the site. I will try and update things to the same level before testing.

#13

joachim - October 6, 2009 - 14:50

I recommend this for cloning your live site to your dev server: http://drupal.org/project/backup_migrate -- does it in about three clicks; an absolute breeze.

#14

magpie5212 - October 13, 2009 - 16:45

Subscribing

#15

bails - October 20, 2009 - 15:25

Hi I've tested the above patch on a production server and it seems not to fix the issue.

before

Tue Oct 20 14:09:37 2009] [error] [client 192.168.1.1] PHP Fatal error: Cannot unset string offsets in foobar/drupal-6.14/sites/all/modules/image/contrib/image_attach/image_attach.module on line 343

after

[Tue Oct 20 14:55:09 2009] [error] [client 192.168.1.1] PHP Fatal error: Cannot unset string offsets in foobar/drupal-6.14/sites/all/modules/image/contrib/image_attach/image_attach.module on line 332

So I'm left with a commented out version which does work.

#16

joachim - October 20, 2009 - 16:18
Status:needs review» postponed (maintainer needs more info)

Gah, what is node_import doing???
If it's triggering the form submit handler, then surely it's using the form in some way and so the values should be there.

What version of node_import are you using?
And could you post a sample node that causes this problem so I can try the import myself?

 
 

Drupal is a registered trademark of Dries Buytaert.