Fatal error: Cannot unset string offsets in home/public_html/modules/filefield/filefield_widget.inc on line 323

Members fund testing for the Drupal project. Drupal Association Learn more


tdurocher’s picture

Same error here. I just upgraded to the same version. I seem to have lost the existing filefield I had. Part of the config is there but no type or widget type.

quicksketch’s picture

Could you describe when the error is displayed? Did you run update.php?

quicksketch’s picture

Title: I have Error » Fatal error: Cannot unset string offsets
Priority: Critical » Normal

I'm not getting the same problem on my machine, but from the line number of the error I'm guessing this happens when you're editing a node. Does the error go away if you save the node and then edit it again? Does it happen on every node?

Konstantin_by’s picture

Yes I updated base. Error appear when I try to edit node. It happen almost the every node but not on all nodes. When I try to edit node that have two imagefields its ok, when one its error.

nodes with 2 imagefields - http://www.daadaa.net/blog/kniga-skazki-tysyacha-i-odna-noch

nodes with 1 imagefield - http://daadaa.net/blog/sostavlenie-grammotnogo-opisaniya-saita-dlya-kata...

update17/03: This happen only with old nodes that I want to edit. When I create new node and then edit It's ok

igorik’s picture

I have the same problem after updating to new filefield and imagefield

chaloalvarezj’s picture

I am having the same problem.. subscribe. This is the error I get:

Fatal error: Cannot unset string offsets in .../modules/filefield/filefield_widget.inc on line 323

Note: After getting the error I upgraded to the DEV version of March 17th and run update.php... but the error persists.

chaloalvarezj’s picture

OK.. I checked the database, because new instances where working fine and only the old ones where giving the error.
The error is caused because for unique cck image fields BEFORE the serialized information was saved as a string, and NOW it is saved as an array:




I only had a few images so, I changed the manually... but for large sites a SQL procedure is necessary... (update.php ??!)

IMPORTANT: Don't forget to clear your cache before editing again!!

quicksketch’s picture

Yikes, messy data storage! Thanks for finding this chaloalvarezj, it would have been hard for me to discover from a fresh installation. I agree, an update function is in order.

quicksketch’s picture

Thanks I can now reproduce this by manually inserting the sample data provided by chaloalvarezj.

quicksketch’s picture

Title: Fatal error: Cannot unset string offsets » Fatal error: Cannot unset string offsets (Corrupted "data" column)
Assigned: Konstantin_by » quicksketch
Status: Active » Needs review
2.93 KB

Here's a patch which fixes all the data that was double-serialized. Please try it out and see if it corrects the problem (make a database backup first).

Konstantin_by’s picture

If there no change in database - can you share files that were patched. Thanks

quicksketch’s picture

Status: Needs review » Fixed

I've committed the patch in #10 and I'm releasing a beta2 version shortly that should correct this problem.

Konstantin_by, changes to the code are not necessary. This problem is caused by bad data in the database, there aren't any problems with the code itself that is causing this problem. So rather than changing the code, we just needed an update function to fix the data.

igorik’s picture

Priority: Normal » Critical
Status: Fixed » Active


I tried the beta 2 dev version but it doesn't work for me
I got still blank page with the message "Fatal error: Cannot unset string offsets in /home/users/somvprahe.sk/web/www/sites/all/modules/filefield/filefield_widget.inc on line 323" after I want editing existing profile with imagefileds.

I did update and clear all my caches before trying.

Please let me know if there is same way how can I help you to debug this problem.


quicksketch’s picture

igorik, can you look in your database and see if any of the data appears like the (incorrect) data shown in #7? Any data that is incorrect will start with "s", data that is correct with start with "a".

Good data: a:3:{s:11:"description";s:7:"Tachino";s:3:"alt";s:0:"";s:5:"title";s:0:"";}
Bad data:  s:39:"a:1:{s:11:"description";s:7:"Tachino";}";
igorik’s picture

Hi, this is full example of one of user affected by this bug:


I hope it helps.
p.s. I broke it to 3 lines for better visibility in this comment

k74’s picture

Hi, I upgrade from beta 1 to beta 2, I have uploaded a lot PDF manuals with FileField, from updating a post with some description of the PDF file with an "a" or "s" (http://www.fullcustom.es/guias/quitar-aviso-service) but others do well (http://www.fullcustom.es/guias/rebaje-suspesion-trasera) the case is that those who do well can the edit, but is that go wrong if I get the editing error: Fatal error: Cannot unset string offsets in /sites/all/modules/filefield/filefield_widget.inc on line 323

With the beta 1 was so good

szy’s picture

It happens, when:

1. you first set your field to multiple,
2. then filled it with file(s),
3. changed field capacity to 1 file,
4. ... at the end: editing the node.


k74’s picture

Version: 6.x-3.0-beta1 » 6.x-3.0-beta2

Do not understand or do not work for me:

1. In field settings Set Number of values: Unlimited
2. ¿?
3. In field settings Set Number of values: 1
4. editing de node generates the Fatal error: Cannot unset string offsets in filefield_widget.inc on line 323


quicksketch’s picture

Thanks szy! You nailed it! This must be a core CCK bug. What's more, every time you switch to unlimited, then back to single, the data gets serialized again.

Single value FileField first upload: a:1:{s:11:"description";s:0:"";}
Toggle to unlimited then back to single: s:32:"a:1:{s:11:"description";s:0:"";}";
Toggle to unlimited again then back to single: s:40:"s:32:"a:1:{s:11:"description";s:0:"";}";";

Obviously a very bad thing the upgrade path I wrote would only fix one level of double-serialization, it'll need to be updated to fix any level. Plus, we'll need to find what's causing this in CCK/FileField.

szy’s picture

@k74: it's not a solution, unfortunately, but quick steps to reproduce the error.

@quicksketch, you're welcome, but that's one and only way I can help :/ :]


quicksketch’s picture

igorik’s picture


I tried the latest cck dev build with your patch but it doesn't help.
I got still the message "Fatal error: Cannot unset string offsets in /home/users/somvprahe.sk/web/www/sites/all/modules/filefield/filefield_widget.inc on line 323"

I am not sure, but maybe some other update into (cck/fielfield) module which repair bad strings to right strings(or what is it) is needed?


quicksketch’s picture

Status: Active » Needs review
822 bytes

Here's a temporary fix that will solve this problem until the CCK update (#407446: Per-Field to Per-Type Storage Corrupts Serialized Columns) is finished.

igorik’s picture

The quick fix works fine. Thanks a lot for it.

quicksketch’s picture

Status: Needs review » Fixed

Thanks for confirming igorik! I'm releasing a beta3 version tonight to solve the problems temporarily.

k74’s picture

Version: 6.x-3.0-beta3 » 6.x-3.0-beta2
Status: Needs review » Fixed

the patch ck_fix_serialization-407446-3.patch http://drupal.org/node/407446 working properly.

glowkeeper’s picture

Version: 6.x-3.0-beta2 » 6.x-3.0-beta3
Status: Fixed » Needs review

I've just upgraded to beta3, but I'm getting the same problems as above - namely "Cannot unset string offsets in filefield_widget.inc on line 323" when trying to edit something containing an imagefield.


quicksketch’s picture

glowkeeper, per the release page, make sure you clear your caches, since CCK keeps a cache of even the corrupted data. Visit admin/settings/performance and click the "Clear caches" button at the bottom of the page.

glowkeeper’s picture

I had cleared the cache's - I have the devel module installed so I can do it nice and easily with a single click.

glowkeeper’s picture

I should also mention that none of my images are displaying either.

I was a little reluctant to mention that because all this happened whilst I was in the midst of also trying to change sites/blah to sites/blah.com, as well as upgrading modules, and I don't know whether that has caused the images to stop displaying, or whether it's due to the imagefield problem.

Luckily this is on a development server. Unluckily, it was all due to go live this weekend and now I aint confident that will happen. Stupidly, I didn't take a backup of the database or drupal heirarchy before making these change, so I can't get out of the fix I'm in easily either. I'm pretty new to Drupal, but even so, I really really should know better :( I suppose the good thing is that, next time, I wont take it all working for granted, and will definitely take those archives before making such changes.....

glowkeeper’s picture

I'm still having problems this morning - I've tried creating new pages containing the imagefield, and they exhibit the problem - the image is not displayed and when I try and edit the page I get the error.

Is anyone else having the same problem after upgrading cck and filefield to 2.2 and beta3 respectively?

TCRobbert’s picture

quicksketch: The things I mentioned here http://drupal.org/node/366183#comment-1379970 about the alt and title not outputting correctly were already done with beta 3 of both filefield and imagefield.

If you would like to test me anything else just drop me a line.

glowkeeper’s picture

To discount any site renaming as part of the problem, I've restored to a backup I took on the evening of 18th March. Everything works correctly. I then got the filefield beta3 update and cck 2.2 update - once again I get the fatal error issue.

So I'm pretty certain the issue is not fixed with the beta3 update, and I'm well up for testing any proposed patches......

glowkeeper’s picture

I've reverted back to cck 2.1, filefield alpha7 and imagefield alpha4 and all is working again.

TenaMurphy’s picture

I got this error with beta1. I had a CCK field allowing 3 images, and I populated all 3 images on one node and saved. I changed my mind and removed 2 of the images from the node, then saved the node. I changed the content type definition to allow only 1 image, then saved. When I tried to re-edit the node, got the error. Didn't get the error on any other nodes because I hadn't added any images to them before changing the content type definition. I tried applying the patch, but still got the error. Cleared cache many times. Still got the error. Upgraded to beta3 (including another cache clear and update.php) and now all is well. THANK YOU!

drfuzetto’s picture

Is there a suggestion for manually fixing this problem?
I can't edit any of my nodes and I really don't want to loose all of my images.

drfuzetto’s picture

This was almost a disaster for me but I was able to fix it by fixing some values in these tables:
content_node_field (field:type)
content_node_field_instance (fields:widget_type,widget_module)

alphakom’s picture

I am also having this issue after upgrading Drupal from 5.x to 6.x, using Ubercart. I cannot edit the 'product' nodes that have images in them. Other nodes, such as page or story, work fine (using beta3).

glowkeeper’s picture

Gunthor - see my post #34 - no need to panic, you will not have lost any data - get the alpha releases of imagefield and filefield (I've since found that you can use the latest cck), and all will be fine.

Then I suppose keep an eye out for fixes......

quicksketch’s picture

Version: 6.x-3.0-beta2 » 6.x-3.0-beta3
Status: Fixed » Needs review

glowkeeper: I know you've got sites to keep running, but from the perspective of fixing this long-term it'd be more helpful to move forward than backward. The alpha versions have their own problems too, like not deleting files, leaving empty database entries, and not managing revisions properly. If you upgrade, then downgrade, then upgrade later, you'll be left permanently with mismanaged data in your database, since the update functions only fire one time and the second time you update they will not be run again.

This problem is fixed between the latest CCK dev, the patch in #407446: Per-Field to Per-Type Storage Corrupts Serialized Columns and the quickfix above in #23 (or you can update to the dev version of FileField).

wonder95’s picture

I'm confused. If I update to the latest CCK dev, doesn't that make the patch in 407446 not necessary?

quicksketch’s picture

If I update to the latest CCK dev, doesn't that make the patch in 407446 not necessary?

The patch fixing the problem of causing corrupted data has already been committed in #407446: Per-Field to Per-Type Storage Corrupts Serialized Columns. However the patch to actually fix existing corrupted data has not yet been committed. So you'd need CCK dev and the current patch in #407446.

Either way, FileField is currently working around the problem until it's fixed in CCK. So simply applying the patch in comment #23 above will fix the problem in FileField until it's fixed in CCK.

attheshow’s picture

I'm using FileField 6.x-3.0-beta3 and CCK 6.x-2.x-dev March 26th. I'm still seeing this error whenever editing nodes.

TyraelTLK’s picture


attheshow’s picture

Update: I just updated to 6.x-3.0-dev from today (March 30th) and the issue now appears to be resolved on my system.

quicksketch’s picture

Thanks attheshow, I'm working on getting out a new version as soon as possible.

fuerst’s picture

For me it did not resolve yet. I'm running CCK 6.x-2.x-dev (2009-Mar-31), Filefield 6.x-3.x-dev (2009-Mar-31) and applied cck_fix_serialization-407446-3.patch to CCK. After that I did run update.php.

Still the Fatal error. Do you have any ideas?

fhojman’s picture

Same problem for me: running CCK 6.x-2.x-dev and Filefield 6.x-3.0-beta3, applied the cck_fix_serialization-407446-3.patch. Still impossible to edit a node and to visualize images.

szy’s picture

If I understand the issue correctly:

if you have edited your files during module's failure and you have corrupted data
in your database table, you need to repair it either manually or using backup,
which you do have, right? :]

But, as I said before, I'm not sure of it.

quicksketch? :]


dvc9’s picture


fuerst’s picture

The problem also was related to some errors in the Ubercart code.

It works for me now using this versions:

* CCK 6.x-2.x-dev (2009-Mar-31)
* FileField 6.x-3.x-dev (2009-Apr-01)
* ImageField 6.x-3.0-beta3
* Ubercart 6.x-2.x-dev (2009-Mar-18)

See the problem description at the Ubercart issue tracker: http://drupal.org/node/404352

fhojman’s picture

I installed the four modules-versions and I'm still getting the same error, both in existing and newly-created nodes:

"Cannot unset string offsets in /homepages/43/d96125994/htdocs/DrupalSites/sites/all/modules/filefield/filefield_widget.inc on line 380"

just the line number has changed from 323 to 380...

quicksketch’s picture

Status: Needs review » Fixed

I've put out new RC versions of both FileField and ImageField that includes the fix from #23. This should fix the problems described in this thread, though the information in the database may still be incorrect until #407446: Per-Field to Per-Type Storage Corrupts Serialized Columns is committed and CCK 2.3 is released.

fuerst’s picture

That means you probably get existing and corrupted data fixed by applying the patch described in http://drupal.org/node/407446#comment-1378500 to CCK's content.install and run an /update.php. Remember to backup your database first.

glowkeeper’s picture

quicksketch - I'd like to upgrade now, but you seem to suggest that since I downgraded in order to keep my sites running, I can't update? Could you suggest how I could proceed and get upto date?

stokestoke’s picture


stokestoke’s picture

I have : Fatal error: Cannot unset string offsets in filefield_widget.inc on line 380
I a running :
- cck-6.x-2.2,
- filefield-6.x-3.0-rc1,
- imagefield-6.x-3.0-rc1,
- ubercart-6.x-2.0-beta5
I have tried :
- http://drupal.org/files/issues/content_double_serialize.patch
- http://drupal.org/files/issues/cck_fix_serialization-407446-3.patch (update 6009)

I have cleared the cache - drupal 6 (Using admin ... performance)
I have removed all products and pictures from the dev site and when I re-add a product and then edit it to add the picture ... wham .. same error.
I am switching my dev env back to
- cck-6.x-2.1,
- filefield-6.x-3.0-alpha7,
- imagefield-6.x-3.0-alpha4,
- ubercart-6.x-2.0-beta4
where the pictures worked 100%.
(I'm adding this post in an affort to provide more information)

stokestoke’s picture

Okay, I rolled back to:
- drupal 6.9,
- cck-6.x-2.1,
- filefield-6.x-3.0-alpha7,
- imagefield-6.x-3.0-alpha4,
- imageapi-6.x-1.3,
- ubercart-6.x-2.0-beta4
where the pictures worked 100%.
I then:
- went to http://yoursitename/admin/settings/performance and cleared the cache (right at the bottom)
- went to http://yoursitename/admin/build/imagecache and flushed all the image cache's in the list.
- copy'd drupal 6.10 (Was on 6.9) to web root.
- copy'd all my other addons to sites/all/modules (Including the modules above).
- copy'd all my pictures to the directory where my pictures are stored.
- ran http://yoursitename/update.php
- replaced imagefield-6.x-3.0-alpha4 with imagefield-6.x-3.0-rc1.
- replaced filefield-6.x-3.0-alpha7 with filefield-6.x-3.0-rc1.
- replaced filefield-6.x-3.0-alpha7 with filefield-6.x-3.0-rc1.
- replaced imageapi-6.x-1.3 with imageapi-6.x-1.5.
- ran http://yoursitename/update.php

100% success.
I am still testing though, but so far so good.

(( !! p.s. I am still running ubercart-6.x-2.0-beta4 !! ))

quicksketch’s picture

Thanks stokestoke for the great walkthrough. I'm glad that it worked in the end!

stokestoke’s picture

I have replaced ubercart-6.x-2.0-beta4 with ubercart-6.x-2.0-beta5.
Still working 100%.

Thanks quicksketch, and thanks for all your hard work.

ngaur’s picture

This is also being discussed at #410118: unable to edit story, less helpfully than here.

It looks like quicksketch provided a fix in cck-dev which has not yet made it to a release version

I've just put in the dev version of cck, but that's not sufficient to fix my un-editable nodes. The .install code might help someone upgrading after this patch is applied, but as far as my system's update.php is concerned, there's no updates to apply. Despite comment #58, I'm not all that clear to fix the data. Am I right in thinking that the schema upgrade system is not able to reverse its changes correctly?

I don't have much data loaded, and could just start over, but newly uploaded data continues to get corrupted.

* If I upload an image when adding a new node, I can't edit it.
* If I add a new node with no image then I can edit it, but oddly it presents me two image upload fields. The node can be viewed, but the image is not visible.
* If I then upload one or two images, the node becomes uneditable, and the image is still not visible on the node view page.
* If I edit the node but do not add images, the node remains editable, and still showing the image upload panel twice.
* Setting the Content Field to single image rather than unlimited doesn't seem to change anything, including that I still get two image upload panes appearing on the edit form.

I'm using:
Using today's 6.x-2.x-dev right now. Was using cck-6.x-2.2.tar.gz. doesn't seem to make any difference.
ubercart-6.x-2.0-beta5 :-)

I'm not sure that what's been described about the DB contents fits what I see. In content_field_image_cache.field_image_cache_data I've got entries like a:2:{s:3:"alt";s:1:"x";s:5:"title";s:1:"x";}

Same error though:
Fatal error: Cannot unset string offsets in /...foobar.../drupal-6.10/sites/all/modules/filefield/filefield_widget.inc on line 380

Status: Fixed » Closed (fixed)

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

agapiou’s picture

Hi i am trying to use node import to import products in ubercart through csv.
At step 6 when i click next to go to step 7 i get the following error:

Fatal error: Cannot unset string offsets in blahblah/sites/all/modules/filefield/filefield_widget.inc on line 442

I have been searching the forum and i have no idea what and why it is caused. The thing is that I was able to perform imports so far with no problem and suddenly all of a suden i get this error.

Could anyone please point me out?

bojanz’s picture

Same error here (line 442). Running the latest Acqua Drupal with filefield 3.2 Smells like a CCK bug.

Changing the cck field setting from "1 value" to "2 values" created the problem.
var_dump($item['data']) gives me serialized data, instead of an array with the description that the code expects to see.

Changed back from "2 values" to "1 value" and the problem disappeared.

bojanz’s picture

And changing again from "1 value" to "2 values", and now it's working.

Quirky. Maybe my CCK is having a bad day and needs some patience from me :)

alarcombe’s picture

I had this problem whilst exporting a content type from my dev box to a staging server. Upon inspection of the content_node_field table the type field for that that field's record was set to 'image' whilst all of the other Image fields had their type set to filefield. Just running

update content_node_field set type = 'filefield' where type = 'image';

seemed to do the trick. For me it cured the symptom but not the underlying problem. ymmv and backup your db first of course!

mvc’s picture

Title: Fatal error: Cannot unset string offsets (Corrupted "data" column) » Fatal error: CCK data field not always unserialized
Version: 6.x-3.0-beta3 » 6.x-3.6
Status: Closed (fixed) » Needs review
785 bytes

I ran into a related error after upgrading from filefield 3.3: the variable $item in the same function was also not unserialized, leading to the following error:

warning: array_merge() [function.array-merge]: Argument #1 is not an array in DOCROOT/sites/all/modules/contrib/filefield/filefield_field.inc on line 294.

Module versions:

drupal 6.16
cck 6.x-2.7
filefield 6.x-3.6
imagefield 6.x-3.3
imageapi 6.x-1.6

I wrote a small patch based on the above code and this now works for me; please review. I don't believe this will break any existing code.

asb’s picture

quicksketch’s picture

Status: Needs review » Closed (fixed)

The patch in #67 should not be necessary because $item['data'] is not referenced in the remainder of that function. Please open a new issue for any further discussion on this topic.

mvc’s picture

Status: Closed (fixed) » Needs review

@quicksketch: i know you asked not to have further discussion on this issue, but i'm going to respectfully disagree with your comment.
$item is passed by reference to that function, so the fact that it isn't referenced later in that function isn't relevant.

quicksketch’s picture

Status: Needs review » Postponed (maintainer needs more info)

$item is not passed by reference, only $items is:

function filefield_field_sanitize($node, $field, &$items, $teaser, $page)

When we do our foreach() it is not by reference either:

foreach ($items as $delta => $item) {

In order for item to be by reference it would have to look like this:

foreach ($items as $delta => &$item) {
quicksketch’s picture

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