Posted by wjaspers on May 21, 2010 at 4:32pm
15 followers
| Project: | Addresses |
| Version: | 6.x-1.12 |
| Component: | Code, CCK related |
| Category: | bug report |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | needs review |
| Issue tags: | Content type, existing field, Illegal offset type, preg_match |
Issue Summary
Found a hook issue quite similar to what had been previously reported.
Order of operations:
- Install the Addresses module under (sites/all/modules/addresses)
- Go to your Modules page and enable Addresses. Then push save.
- Create a content type.
- Add an address field to your new content type and press save.
- Go back to your content type list.
- Create another content type.
- Add an EXISTING FIELD of type Address to this content type and press save.
- Note the following errors:
* warning: Illegal offset type in C:\webroot\vhostdocs\2008\includes\form.inc on line 1373.
* warning: preg_match() expects parameter 2 to be string, array given in C:\webroot\vhostdocs\2008\includes\bootstrap.inc on line 777.Environment:
- Windows Server 2003
- Apache 2.0.63 w/o SSL support
- PHP 5.2.13 (my live site may be newer)
- Drupal 6.x
This only seems to have occurred after installing the addresses module. Oddly enough, the content type still functions correctly, and I don't seem to be losing any data when I try to create content.
Comments
#1
wjaspers - thank you for the thorough report. If someone could please reproduce this in a different environment I would appreciate it as I am very limited on time currently.
#2
I'm getting the same errors thrown up (repeated 5 times, see below) when someone tries to create a new account (see http://www.byusforus.net). It doesn't stop the user creating the account, but does put them off a little!
Environment
Ubuntu 8.10
Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4.6 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
Drupal 6.16
warning: Illegal offset type in /home/default/byusforus.net/user/htdocs/includes/form.inc on line 1373.
warning: Illegal offset type in /home/default/byusforus.net/user/htdocs/includes/form.inc on line 1373.
warning: Illegal offset type in /home/default/byusforus.net/user/htdocs/includes/form.inc on line 1373.
warning: Illegal offset type in /home/default/byusforus.net/user/htdocs/includes/form.inc on line 1373.
warning: Illegal offset type in /home/default/byusforus.net/user/htdocs/includes/form.inc on line 1373.
warning: preg_match() expects parameter 2 to be string, array given in
#3
I have a short-term solution:
For me, this was happening when I set any of the CCK field settings to "Hidden". I removed the CCK field, added a new one and used "None" on those fields instead.
I did spend some time looking through Backtrace, et al. What is happening is that form_builder() is getting a $form where $form['#type'] is an array('hidden', 'hidden'). This is not supposed to happen, $form['#type'] is always supposed to be a string.
There are four places in the module code where '#type' is set to 'hidden'. One of these must be getting merged or flattened when a form is built.
It looks like the problem might be happening with in the 'Default value' area. When I tried to submit the settings for my address field, one of the fields that I set to 'Hidden' was failing validation in the 'Default value' area, despite the fact that it was not required.
I strongly suspect this code here:
<?phpfunction addresses_cck_field_settings($op, $field) {
switch ($op) {
case 'form':
// Get the form fields from the API addressesfieldapi
module_load_include('settings.inc', 'addresses');
$form = _addresses_settings_fields($field);
$form['required'] = array(
'#type' => 'hidden',
'#value' => $field['required'],
);
$form['#validate'][] = '_addresses_cck_field_validate';
return $form;
?>
That is all the time I can spend on this. I hope it is enough to get this fixed.
#4
Just wanted to confirm that this problem does seem to arise as a result of flagging fields as 'Hidden' rather than 'None'.
#5
Yep I can confirm this as well. The errors repeat for each address field marked as hidden.
#6
confirm problem.
subscribe
#7
Yes, this happens. Subscribing.
#8
did this ever come to a resolution? subscribing
#9
This still happens.
#10
Assuming #3 was on the right track, we are probably missing a
'#tree' =>true somewhere.Let me know whether the attached patch does anything good for you.
Thank you.
Alexis
#11
I suppose you're using version 6.x-1.12?
#12
Hmm, I think I may had downgraded to 1.10 due to another bug: http://drupal.org/node/899732
So if this is fixed in 1.12 it might not anymore.
#13
I experienced this issue with version 1.12 and the patch #10 fixed it for me!
Thanks...
#14
Okay, I applied the patch to the development version. I will publish as 1.13 if one other person says it fixes the problem. The development version is the same as 1.12 + patch in #10 at this point.
Thank you.
Alexis Wilke
#15
The patch doesn't fix it for me.
What I get is:
warning: Illegal offset type in /home/content/88/4800788/html/includes/form.inc on line 1378.
warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/content/88/4800788/html/includes/bootstrap.inc on line 856.
And on top of that the address option doesn't even show up on the node form.
#16
Same problem here. I get the following:
warning: Illegal offset type in /includes/form.inc on line 1378.
warning: htmlspecialchars() expects parameter 1 to be string, array given in /includes/bootstrap.inc on line 856.
I do see the address option on the form unlike @merzikain. And the form does still seem to work for the most part. However, I have received reports from some people that they are not able to successfully submit the form so this may be a bigger problem. I'm setting this to a higher priority for this reason, but if I'm wrong on this feel free to set the priority back down.
Thanks
#17
I can confirm this issue is not fixed with the patch.
I am using 6x-1.12 and the patch applied at #10 applied. I have three fields marked as hidden and get the following error:
warning: Illegal offset type in [site]/includes/form.inc on line 1378.
warning: Illegal offset type in [site]/includes/form.inc on line 1378.
warning: Illegal offset type in [site]/includes/form.inc on line 1378.
warning: htmlspecialchars() expects parameter 1 to be string, array given in [site]/includes/bootstrap.inc on line 860.
warning: htmlspecialchars() expects parameter 1 to be string, array given in [site]/includes/bootstrap.inc on line 860.
warning: htmlspecialchars() expects parameter 1 to be string, array given in [site]/includes/bootstrap.inc on line 860.
I changed the hidden to none and the errors went away, but the address was still not formatting correctly. So I removed the field and added it back. Now it's not showing at all!
#18
Attached patch fixes described problem.
Also some other parts of the module's code have been rewritten to fix other related issues.
Please review.
#19
Please discard this post. Tried to patch the wrong version :-(
#20