Download & Extend

[master] Argument #1 is not an array

Project:Location
Version:5.x-3.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

#1

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.

#2

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.

#3

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.

#4

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

Making yhzsailor's changes fixed the issue for me.

Thanks Yhzsailor!

#5

Status:active» needs review

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

#6

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

#7

Status:fixed» closed (fixed)

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

#8

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.

#10

Status:fixed» closed (fixed)

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