Found a hook issue quite similar to what had been previously reported.

Order of operations:

  1. Install the Addresses module under (sites/all/modules/addresses)
  2. Go to your Modules page and enable Addresses. Then push save.
  3. Create a content type.
  4. Add an address field to your new content type and press save.
  5. Go back to your content type list.
  6. Create another content type.
  7. Add an EXISTING FIELD of type Address to this content type and press save.
  8. 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

codycraven’s picture

Status: Needs review » Active

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.

cliveR952’s picture

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

rolodmonkey’s picture

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:

function 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.

ISPTraderChris’s picture

Just wanted to confirm that this problem does seem to arise as a result of flagging fields as 'Hidden' rather than 'None'.

fayola’s picture

Yep I can confirm this as well. The errors repeat for each address field marked as hidden.

loominade’s picture

confirm problem.

subscribe

gewillson’s picture

Yes, this happens. Subscribing.

hongpong’s picture

did this ever come to a resolution? subscribing

Anonymous’s picture

This still happens.

AlexisWilke’s picture

StatusFileSize
new497 bytes

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

AlexisWilke’s picture

Version: 6.x-1.08 » 6.x-1.12
Component: Code » Code, CCK related
Priority: Minor » Normal

I suppose you're using version 6.x-1.12?

Anonymous’s picture

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.

ratinakage’s picture

I experienced this issue with version 1.12 and the patch #10 fixed it for me!

Thanks...

AlexisWilke’s picture

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

merzikain’s picture

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.

deggertsen’s picture

Priority: Normal » Major

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

otherroutes’s picture

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!

taran2l’s picture

StatusFileSize
new21.41 KB

Attached patch fixes described problem.

Also some other parts of the module's code have been rewritten to fix other related issues.

Please review.

eric66’s picture

Please discard this post. Tried to patch the wrong version :-(

rolodmonkey’s picture

Status: Active » Needs review
rolodmonkey’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

Since Drupal 6 is no longer supported, I am closing this issue.