Active
Project:
Content Construction Kit (CCK)
Version:
6.x-2.9
Component:
fieldgroup.module
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
2 Apr 2009 at 00:09 UTC
Updated:
24 Oct 2011 at 13:37 UTC
When CCK field or field group descriptions are empty, the following error is showing up:
warning: preg_match() expects parameter 2 to be string, array given in includes\bootstrap.inc on line 775.
It appears that when the string is empty the t() function returns an Array? Here are some of the places that are causing the issue that I've found by dumping the back trace from the bootstrap method:
fieldgroup.module#537
'#description' => $label ? content_filter_xss(t($group['settings']['display']['description'])) : '',
content.node_form.inc#101
$description = content_filter_xss(t($field['widget']['description']));
Comments
Comment #1
yched commentedCannot reproduce. That would be a major bug which would have raised 100's of reports :-)
t('') return ''.
I'm not sure what is happening on your setup. Looks like $field['widget']['description'] and $group['settings']['display']['description'] are returning arrays instead of strings.
A couple suggestions in the dark :
- re-save your fields and groups
- empty your site's cache (admin/settings/performance, 'Cleard cached data' at the bottom of the form)
Also, are those fields coming from an upgraded D5 setup, or were they created in D6 ?
Comment #2
ahansen1 commentedI just double checked and t() does return an Array on null on my setup? I just put the following in a page:
And the output is:
This is from a migrated setup. However, I deleted all of the directories except for sites and files before plunking in the 6.10 install. I have seen this error come up on various module forums. I'm not sure why my setup is returning that? I guess you're saying it shouldn't be and isn't on yours.
Comment #3
ahansen1 commentedSo, I dug a little deeper and found something interesting. As I mentioned t(null) was returning an array. This seems to be because of the following snippet in common.inc:
It seems that in my environment $custom_strings[$langcode][$string] was equal to:
So, naturally when $string was null it returned the empty Array. I worked around the issue by putting the following snippet in my settings.php file:
Now everything seems to be fine and dandy. Should the value of $custom_strings[$langcode][$string] not have been what it was in my environment? Is this a core bug? Or do you think something is just funky in my environment?
Comment #4
jonathanhuot commentedI had the same issue, but the following was printed as an error instead of yours :
drupal warning: strlen() expects parameter 1 to be string, array given in (..)/bootstrap.inc on line 892.In my case, strlen was called by content_filter_xss no matter t returned an array.
Only one fieldgroup had this issue, and I edit-it/submit blank description to fix it.
Why none description was inserted in database ? well... module code just call these fews lines of CCK API code :
Maybe CCK should set a blank description if none was given in function call ?
Comment #5
jonathanhuot commentedUpdated issue fields.
Comment #6
Syg commentedThe fact is that you should avoid to use variables in t() function or at least verify that your variable is not NULL.
From API :
For information, I added those lines till the bug is fixed :
Edit :
My problem was that features exported a NULL value for some fieldgroup descriptions. So re-entering an empty string ('') in the description fixed the issue.