Error on Nodes using CCK Location using Custom Breadcrumbs module
RockSoup - October 3, 2009 - 04:56
| Project: | Location |
| Version: | 6.x-3.1-rc1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
I am using CCK 6.x-2.4 with Location CCK 6.x-3.1-rc1. I have a node type with location fields on it that I have used custom breadcrumbs to set a "node" path on for that type.
Just a note, I do not get this error on any other type/path configurations I can come up with, only the type with location fields, and basically think the 2.x custom breadcrumbs release is awesome :)
The error I get is:
* warning: array_filter() [function.array-filter]: The first argument should be an array in C:\xampp\htdocs\mysite\sites\all\modules\location\contrib\location_cck\location_cck.module on line 385.
* warning: array_keys() [function.array-keys]: The first argument should be an array in C:\xampp\htdocs\mysite\sites\all\modules\location\contrib\location_cck\location_cck.module on line 385.
* warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\mysite\sites\all\modules\location\location.module on line 1440.I am not a coder. Since I am using a RC version of Location this could be an issue with that module, but I think it is not. I think the issue is with custom breadcrumbs, but I am not a talented enough debugger to find it. help please
thanks

#1
I am reassigning this issue to the location module because the error needs to be fixed there.
Custom breadcrumbs is revealing the error by using the token api token_replace_multiple() function. But the problem is in location_cck.module. location_cck needs to properly check the objects that are being passed into location_cck_token_values() before acting on them.
Before doing the array filter on line 385, be sure to check isset($item['location_settings']). if this array is not defined, I expect you want to bail out of the function...
I hope this helps. Sorry I can't provide a patch to fix this problem right now, but its a straightforward fix.
#2
Thanks for the quick reply MGN.
If there is anything I can do to help with this as far as testing please let me know.
Thanks.
#3
I am changing the title to be more accurate.
I would love feedback about how I could get some eyeballs on this.
MGN pointed out -
I am not a coder and don't understand how to debug this.
thanks.
#4
#5
I am still getting error, even with applied patch. By debugging i've found that location_settings key can exist but contains only "form" key.
<?php'hide' => isset($item['location_settings']) && is_array($item['location_settings']['display']['hide']) ? array_keys(array_filter($item['location_settings']['display']['hide'])) : array(),
?>
#6
I also receive a similar in CCK + Date + Image FUpload + Location.
* warning: array_filter() [function.array-filter]: The first argument should be an array in /Applications/MAMP/htdocs/bp/sites/all/modules/location/contrib/location_cck/location_cck.module on line 385.* warning: array_keys() [function.array-keys]: The first argument should be an array in /Applications/MAMP/htdocs/bp/sites/all/modules/location/contrib/location_cck/location_cck.module on line 385.
* warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/bp/sites/all/modules/location/location.module on line 1440.
I'm creating a content type called "Event" that should allow users to upload the Date, Location, and photos of their event to an intranet.
I guess the workaround I'll have to do for now is create a Text Field where they can paste the link from Google Maps and then output that field as a Link it as a link in Views ("Location".)
#7
I don't think this has anything to do with Custom Breadcrumbs as I'm getting the same errors without it installed.
They're not serious errors, and shouldn't break anything, but should still be fixed.
Here's my fix for the last error in location.module. Not sure if it's the best way, but I cast
$variables['hide']to an array which then stops the parsing complaint about an invalid argument toforeach(). It should be set to an empty array, which will not cause the loop to execute. (I don't think it will modify the original value either, just pass the result of the cast to the loop without affecting the original value). Patch is against 6.x-3.x-dev, but easy enough to find in any version.Alternately, the foreach() loop could be wrapped in
if(isset($variables['hide']) && is_array($variables['hide'])){}I didn't spend much time, but couldn't find a better solution to the first two errors other than using a lot of
isset()checks.