Download & Extend

Argument #1 is not an array... location.module on line 1409.

Project:Location
Version:6.x-3.x-dev
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:closed (fixed)
Issue tags:location bdragon check

Issue Summary

* warning: array_merge() [function.array-merge]: Argument #1 is not an array in /media/wd500/www/devroots/d6-matadortravel-com/sites/all/modules/location/location.module on line 1409.

Error appears twice when viewing a user's page, with content profile, APK installed on drupal 6.9

This is the referenced code...

<?php
**
*
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($defaults[$k], $v); //line 1409
   
}
  }

...
?>

So it looks like location_invoke_locationapi is screwing up, giving a non array (or nothing at all)...

Comments

#1

Same problem

warning: array_merge() [function.array-merge]: Argument #1 is not an array in xxx/sites/all/modules/location/location.module on line 1409.
warning: array_merge() [function.array-merge]: Argument #1 is not an array in xxx/sites/all/modules/location/location.module on line 1409.

#2

Status:active» closed (duplicate)

Duplicate of #346988: [master] Argument #1 is not an array.

#3

Status:closed (duplicate)» active

Re-opening this request.

This is for 5.x-3.0:
#346988: [master] Argument #1 is not an array

I am using:

version = "6.x-3.0"
core = "6.x"
project = "location"
datestamp = "1229117725"

I have the same issue as described above. Two array errors on Edit:

* warning: array_merge() [function.array-merge]: Argument #1 is not an array in /drupal-6.10/sites/all/modules/location/location.module on line 1409.
* warning: array_merge() [function.array-merge]: Argument #1 is not an array in /drupal-6.10/sites/all/modules/location/location.module on line 1409.

-pinxi

#4

marked #411982: warning: array_merge() a duplicate of this issue

#5

Priority:normal» critical

See:

<?php
**
*
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($defaults[$k], $v); //line 1409
   
}
  }

...
?>

Note that $location (which is never defined) is used in location_invoke_location(). I don't know if that was supposed to be

<?php
location_invoke_locationapi
($settings, 'defaults');
?>
or something else.

#6

Status:active» needs review

$location is defined further down, I'm guessing it just needs to be moved up before location_invoke_locationapi(). Patch attached.

AttachmentSize
location_381498.patch 952 bytes

#7

bump.

same thing for 5.x-3.x-dev...

AttachmentSize
location_381498_d5.patch 922 bytes

#8

I had the same problem due to a malformed settings. I corrected the problem like this :

function location_empty_location($settings) {
  $location = array();
  $defaults = location_invoke_locationapi($location, 'defaults');
  if (isset($settings['form']['fields'])) {
    foreach ($settings['form']['fields'] as $k => $v) {
    if (! is_null ($defaults[$k])){
    $defaults[$k] = array_merge($defaults[$k], $v);
    }
    }
  }
...

#9

#10

I still get the error, unless I change the same bit of code to:

function location_empty_location($settings) {
  $location = array();
  $defaults = location_invoke_locationapi($location, 'defaults');
  if (!is_array($defaults['locpick'])) $defaults['locpick'] = array();
  if (isset($settings['form']['fields'])) {
    foreach ($settings['form']['fields'] as $k => $v) {
      $defaults[$k] = array_merge($defaults[$k], $v);
    }
  }
...

"locpick" seems to be missing it's defaults settings.

#11

subscribe - this seems to be causing errors with submission too.

#12

Just needs to be a bit more robust I think... try

diff --git a/html/sites/all/modules/location/location.module b/html/sites/all/modules/location/location.module
index 705f206..ac911b9 100644
--- a/html/sites/all/modules/location/location.module
+++ b/html/sites/all/modules/location/location.module
@@ -1405,9 +1405,11 @@ function location_is_empty($location, &$filled) {
function location_empty_location($settings) {
   $location = array();
   $defaults = location_invoke_locationapi($location, 'defaults');
-  if (!is_array($defaults['locpick'])) $defaults['locpick'] = array();
   if (isset($settings['form']['fields'])) {
     foreach ($settings['form']['fields'] as $k => $v) {
+      if (!isset($defaults[$k])) {
+        $defaults[$k] = array();
+      }
       $defaults[$k] = array_merge($defaults[$k], $v);
     }
   }

*EDIT*
I'll also note that this error was completely making so that my node, with a location_cck field, would not be created at all. So in my case it was not just 'lockpick' that was not set, but cck-something-or_other as well. Using this fixed that and would fix any key that happens to be within $settings['form']['fields'] and not within $defaults.

#13

Priority:critical» minor
Status:needs review» postponed (maintainer needs more info)

I think this is just a problem for some people, not all. Any idea what combination of situations causes the problem? Can you make a new test site using the new dev release, with just location, and document the steps you go through to reproduce the error?

#14

same issue. subscribe. going to try Dev version.

#15

Status:postponed (maintainer needs more info)» needs review

I haven't taken my own advice and done a simple blank test site to recreate the error (yet). But I did start getting the error when I upgraded to the new dev, for example on my add user form (where I have cck locations in the content profiles). Attached the patch suggested in #12 by sirkitree (it got rid of the errors for me)

--- location.module.orig        2010-04-09 01:11:14.211671813 -0400
+++ location.module     2010-04-09 01:11:45.161606063 -0400
@@ -1406,6 +1406,9 @@ function location_empty_location($settin
   $defaults = location_invoke_locationapi($location, 'defaults');
   if (isset($settings['form']['fields'])) {
     foreach ($settings['form']['fields'] as $k => $v) {
+      if (!isset($defaults[$k])) {
+        $defaults[$k] = array();
+      }
       $defaults[$k] = array_merge($defaults[$k], $v);
     }
   }
AttachmentSize
patch4444.patch 495 bytes

#16

steps to reproduce:
clean site 6.16 with modules:
Administration menu 6.x-1.5
Content Construction Kit (CCK) 6.x-2.6
Includes: Content, Fieldgroup, Option Widgets, Text
Location 6.x-3.0
Includes: Location, Location CCK
Poormanscron 6.x-2.2
Includes: Poormanscron
Views 6.x-2.10
Includes: Views, Views UI

Add a new content type, add a cck location field, create a node of that content type and should get the error.

#17

tagging

#18

marked #662250: warning: array_merge() as a duplicate of this issue

#19

FIX: Try upgrading to version 6.x-3.1-rc1 or better

I ran into this issue migrating from one server to another. The original server was running version 6.x-3.1-rc1, while the destination server was running the older 6.x-3.0.

Not only were we getting the line 1409 error, but no one was able to update or add any nodes in certain content types that used Location CCK fields.

An upgrade to 6.x-3.1-rc1 resolved these issues.

#20

Version:6.x-3.0» 6.x-3.x-dev

This is already fixed in 6.x-3.x-dev. I'm not sure when but the current code for that part (#15) is now:

<?php
 
if (isset($settings['form']['fields'])) {
    foreach (
$settings['form']['fields'] as $k => $v) {
      if (isset(
$defaults[$k])) {
       
$defaults[$k] = array_merge($defaults[$k], $v);
      }
    }
  }
?>

Can you confirm the problem is fixed in the latest dev?

#21

Status:needs review» closed (fixed)

This looks fixed to me.