Only save logs that have duplicate areas.
This commit is contained in:
parent
25ecd4faf1
commit
50494b16da
|
@ -545,15 +545,17 @@ function farm_livestock_update_7008(&$sandbox) {
|
||||||
$log_wrapper = entity_metadata_wrapper('log', $log);
|
$log_wrapper = entity_metadata_wrapper('log', $log);
|
||||||
$areas = $log_wrapper->field_farm_area->value();
|
$areas = $log_wrapper->field_farm_area->value();
|
||||||
|
|
||||||
// Only update areas if some exist.
|
// Only update areas if more than 1 exists.
|
||||||
if (!empty($areas)) {
|
if (!empty($areas) && count($areas) > 1) {
|
||||||
|
|
||||||
// Get the unique areas.
|
// Get the unique areas.
|
||||||
$new_areas = array_unique($areas, SORT_REGULAR);
|
$new_areas = array_unique($areas, SORT_REGULAR);
|
||||||
|
|
||||||
// Update the log.
|
// Update the log.
|
||||||
$log_wrapper->field_farm_area->set($new_areas);
|
if (count($areas) > count($new_areas)) {
|
||||||
$log_wrapper->save();
|
$log_wrapper->field_farm_area->set($new_areas);
|
||||||
|
$log_wrapper->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sandbox['progress']++;
|
$sandbox['progress']++;
|
||||||
|
|
Loading…
Reference in New Issue