I'm getting an error when I preview my nodes.

warning: Invalid argument supplied for foreach() in MYURL/sites/all/modules/location/location.module on line 1677.

...it may be unrelated, but I noticed this warning after I just installed a newly patched version of WYSIWYG, here: http://drupal.org/node/253600#comment-1050339
(in case it's relevant at all - though could be unrelated ?)

Thanks for any insight into this issue :)
Scott

CommentFileSizeAuthor
#17 location_no_locative_info.patch817 bytesclaudiu.cristea

Comments

scottrigby’s picture

BTW, Just checked with sun and apparently the function on line 1677 isn't related to the WYSIWYG module in any way.

Also, for the node-type in question, there Locations aren't enabled at all, so I assume this should not be an issue - but for some reason it is.

Any ideas? How can I help track this down?

Cheers :)
Scott

DerTobi75’s picture

Same here, but I am using the Drupal 5.x version. Every node that does not have locationfields create that warning!

TallDavid’s picture

I have also started seeing this error in the log after updating a Drupal 5.11 site to location 5.x-3.0-rc1.

Invalid argument supplied for foreach() in /.../sites/all/modules/location/location.module on line 1701.

bdragon’s picture

I can confirm this on my test site. I believe it's related to invalid data, but I haven't had time to debug.

bdragon’s picture

Assigned: Unassigned » bdragon

Looking into this now.

bdragon’s picture

Version: 6.x-3.0-rc1 » 6.x-3.x-dev
Status: Active » Fixed

oh, I get it. Yeah, location's trying to run on all nodes and not double checking a couple things.

Should be fixed in HEAD and DRUPAL-5--3 now.

http://drupal.org/cvs?commit=148367
http://drupal.org/cvs?commit=148369

MedicSean37’s picture

I have this issue on D6.5. It doesn't occur all the time, and it did happen with a content type that doesn't even use the location module. I did upgrade from D5 which I used the location module then too.

I'll upgrade to head soon and report back.

dynamite’s picture

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

Hi,

What does this line mean?

"Should be fixed in HEAD and DRUPAL-5--3 now."

Is there a way to find a patch for the fix so that we can apply it to 5.x-3.0-rc1? I'm having issues with rc2, so I resorted to rc1. Please kindly let me know.

Thanks!

femrich’s picture

Version: 5.x-3.0-rc1 » 5.x-3.0-rc2
Status: Fixed » Active

I get this for 5.x-3.0.rc2 when creating new content:

warning: Invalid argument supplied for foreach() in /home/user/public_html/sites/all/modules/location/location.module on line 1774.

According to what I read above, this should already have been fixed in this version, no? Or do I need to upgrade to Head?

dynamite’s picture

Version: 5.x-3.0-rc2 » 5.x-3.0-rc1
Status: Active » Fixed

Hi femrich,

You can try the latest dev version. It solved the problem for me, but the search proximity filter is broken in the latest dev version. sigh...

femrich’s picture

Version: 5.x-3.0-rc1 » 5.x-3.0-rc2
Status: Fixed » Active

Thanks, dynamite, though I can't see that substituting a version with one bug with a dev version with another bug qualifies an issue as "fixed." It's gone on long enough for me that I will simply uninstall the module until the next RC or official release, and then test that one.

skizzo’s picture

On 5.x-3.0-rc2 I am seeing this error when entering data in a CCK location field and then hitting the Return key. However, if I click the Submit button (instead of Enter key), then I see no error and location gets geocoded correctly.

femrich’s picture

For me it happens also when I click "submit."

amcc’s picture

warning: Invalid argument supplied for foreach() in blah/all/modules/location/location.module on line 1750.

Get this when creating a new forum topic, when logged in as an authenticated user, but not admin.
Somehow the location variable is getting into the form topic

line 1750 below in location.module - this is causing the trouble for me

foreach ($locs as $location) {
    $variables['locations'][] = theme('location', $location, $variables['hide']);
  }

I've not added locations to forum topics - i've tried installing then reinstalling the forum module - additionally nothing is being themed in forum topics.

Authenticated users have permissions to do the following under location module:
set own user location
submit latitude/longitude
view all user locations
view own user location

amcc’s picture

Modifying location.module like this fixes the adding forum posts problem described above, not sure if it breaks anything else important, don't think it will.

/**
 * Theme preprocess function for theming a group of locations.
 */
function template_preprocess_locations(&$variables) {
	if (arg(2) != 'forum'){
	  $locs = $variables['locations'];
	  $variables['locations'] = array();
	  $variables['rawlocs'] = $locs;

	  foreach ($locs as $location) {
	    $variables['locations'][] = theme('location', $location, $variables['hide']);
	  }
	}
}

Rather than modifying the location.module file itself you should be able to do this in the theme i believe, eg zen_preprocess_locations, but this isn't working for me, and there's a long issue about that here: http://drupal.org/node/258089

Either way this shouldn't be happening in the first place. This also fixes the problem (added an if statement to check for the $locs variable - perhaps this is more appropriate:

function template_preprocess_locations(&$variables) {
	$locs = $variables['locations'];
	$variables['locations'] = array();
	$variables['rawlocs'] = $locs;
	if ($locs){
		foreach ($locs as $location) {
			$variables['locations'][] = theme('location', $location, $variables['hide']);
		}
	}
}
jannalexx’s picture

v6.6
warning: Invalid argument supplied for foreach() in \location.module on line 1677 (rc2) / on line 1750 (rc3)

#15 works (1st solution) at least the error disappeared
there should be a 6.7 fix (for 2nd solution) as stated in http://drupal.org/node/258089
but it should be in the module code for now

claudiu.cristea’s picture

StatusFileSize
new817 bytes

Here's a patch for 5.x-3.0-rc2. The error is fired up from location_nodeapi().

claudiu.cristea’s picture

Status: Active » Needs review

Changed also the status....

sComm’s picture

Is this resolved in 5.15?

TallDavid’s picture

Version: 5.x-3.0-rc2 » 5.x-3.1-rc1
Status: Needs review » Fixed

This problem no longer occurs with the latest version 5.x-3.1-rc1 2009-Mar-03 on my site. I believe that the problem has been resolved and am therefore marking this ticket as fixed.

Status: Fixed » Closed (fixed)

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

yesct’s picture