Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I got the error
Fatal error: Cannot unset string offsets in /var/www/drupal/sites/all/modules/cck/content.module on line 124
This fatal error prevents to create or edit nodes of the affected content type, so this is a major issue. I got this error with fields generated by node reference
More context information: http://drupal.org/node/989254
I did a small patch to prevent this error.
Enjoy IT
Comment | File | Size | Author |
---|---|---|---|
#4 | cck_unset_error.patch | 704 bytes | Gemma Morton |
#3 | cck_unset_error.patch | 662 bytes | Gemma Morton |
cck_unset_error.patch | 654 bytes | -enzo- |
Comments
Comment #1
-enzo- CreditAttribution: -enzo- commentedTypo the line is 1248
Comment #2
dagmarhttp://drupal.org/coding-standards#indenting Use two spaces instead of tabs.
http://drupal.org/coding-standards#controlstruct use {} in control structures. Control statements should have one space between the control keyword and opening parenthesis, to distinguish them from function calls.
http://drupal.org/coding-standards#concat Always use a space between the dot and the concatenated parts to improve readability.
And from http://drupal.org/node/34341 use !empty() instead of isset()
So, the code should be:
Comment #3
Gemma Morton CreditAttribution: Gemma Morton commentedIv rolled the patch to use whats shown in #2.
Is this going to be accepted?
Comment #4
Gemma Morton CreditAttribution: Gemma Morton commentedMe again,
It seems the Addresses module sends the following array to _content_field_invoke for $items:
Whilst the code expects an Array, this is throwing numerous errors on my site (and thus I am sure others)
So, Iv just changed the patch to first check if it is an Array, before unsetting $items[_add more]
I realise that at the end of this day, this is something that Addresses should check, but its probably a good idea for CCK to make sure its checking an array, before it trys to do anything to it. I hope this is ok.
Comment #5
Gemma Morton CreditAttribution: Gemma Morton commentedIgnore my comments.
In your code, you should run
node_object_prepare($node);
before
node_save($node);
and then you shouldnt receive this error.
Comment #6
jessia CreditAttribution: jessia commentedWhen I try to apply this patch, I get the error:
patching file content.module
patch: **** malformed patch at line 15:
-Jessi
Comment #7
Ludo.RI have the same issue on line 1248.
It may be linked to this issue : http://drupal.org/node/1077798
Comment #8
kenorb CreditAttribution: kenorb commentedClosed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.