diff --git a/location.module b/location.module old mode 100644 new mode 100755 index 1bc8ef6..1757088 --- a/location.module +++ b/location.module @@ -888,7 +888,16 @@ function location_load_locations($id, $key = 'vid') { * Example: array('genid' => 'my_custom_1111') */ function location_save_locations(&$locations, $criteria) { - if (isset($locations) && is_array($locations) && !empty($criteria) && is_array($criteria)) { + // Unset any bogus locations... + if (isset($locations) && is_array($locations)) { + foreach ($locations as $key => $location) { + if (!array_filter($location)) { + unset($locations[$key]); + } + } + } + + if (isset($locations) && is_array($locations) && !empty($locations) && !empty($criteria) && is_array($criteria)) { foreach (array_keys($locations) as $key) { location_save($locations[$key], TRUE, $criteria); } @@ -1130,7 +1139,13 @@ function _location_patch_locpick(&$location) { * is provided, there will be no attempt to reuse lids. * @return The lid of the saved location, or FALSE if the location is considered "empty." */ -function location_save(&$location, $cow = TRUE, $criteria = array()) { +function location_save(&$location, $cow = TRUE, $criteria = array()) { + // If this is an empty location, then return FALSE. + $check_location = array_filter($location); + if (empty($check_location)) { + return FALSE; + } + // Quick settings fixup. if (!isset($location['location_settings'])) { $location['location_settings'] = array();