I upgraded today and get the following error when trying to create a node which references a location:

warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/bnewsome/public_html/modules/location/location.module on line 1385.

Interestingly this does not occur on another node type which also has a location.

Thoughts?

Comments

jdm843’s picture

I'm having the same problem (above mentioned warning) with 5.x-3.0 running Drupal 5.14. It exists in all nodes in which I'm using location. When I try to change a location the address updates but the lat/long coordinates do not recalculate and are blank. I used the "delete" box to clear the previous location before inputting the new one. Clearing cache...reinstalling module have no effect.

nnn’s picture

I got the same problem. Then I opened the edit page for the content type that uses location, and re-submit the content type setting. After that, when I opened the edit page of the nodes of that content type, I saw no more of this error message.

yhzsailor’s picture

I found a solution at http://drupal.org/node/36408

PHP5 is the problem. I wouldn't have thought of that because I've never used PHP5, but a quick look into the PHP manual reveals that "The behavior of array_merge() was modified in PHP 5". Read Example 3 at http://us3.php.net/manual/en/function.array-merge.php

As a result of this hint, I modified location.module line 1387 (at least that's the line in my modified location.module) to read something like this (extra lines for the complete function listed for context.)

/**
 * Returns an empty location object based on the given settings.
 */
function location_empty_location($settings) {
  $defaults = location_invoke_locationapi($location, 'defaults');
  if (isset($settings['form']['fields'])) {
    foreach ($settings['form']['fields'] as $k => $v) {
      $defaults[$k] = array_merge((array)$defaults[$k], (array)$v);
    }
  }

The only change is the addition of (array) before each parameter in the call to array_merge on line 1387. That got rid of the error message and I'm presuming that this has fixed the issue and it is not silently failing.

mherchel’s picture

Same issue with 5.x-3.0 & Drupal 5.14.

Making yhzsailor's changes fixed the issue for me.

Thanks Yhzsailor!

pmark23’s picture

Status: Active » Needs review

I suddenly started having these same problems, but the above patch worked.

bdragon’s picture

Status: Needs review » Fixed

Fixed this yesterday. It was attempting to blindly merge in form elements that had been tacked on.

Thanks for the report!

http://drupal.org/cvs?commit=163493
http://drupal.org/cvs?commit=163494

Status: Fixed » Closed (fixed)

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

bdragon’s picture

Title: Error after Upgrade from 5.x-RC1 » [master] Argument #1 is not an array
Status: Closed (fixed) » Fixed

Marking as master and changing to fixed again for visibility.

Status: Fixed » Closed (fixed)

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