From 50494b16da140ce5b84e7a6aadd7f1ca73635335 Mon Sep 17 00:00:00 2001 From: paul121 Date: Wed, 28 Oct 2020 09:28:20 -0700 Subject: [PATCH] Only save logs that have duplicate areas. --- modules/farm/farm_livestock/farm_livestock.install | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/farm/farm_livestock/farm_livestock.install b/modules/farm/farm_livestock/farm_livestock.install index 8d1723c6c..47f3940b2 100644 --- a/modules/farm/farm_livestock/farm_livestock.install +++ b/modules/farm/farm_livestock/farm_livestock.install @@ -545,15 +545,17 @@ function farm_livestock_update_7008(&$sandbox) { $log_wrapper = entity_metadata_wrapper('log', $log); $areas = $log_wrapper->field_farm_area->value(); - // Only update areas if some exist. - if (!empty($areas)) { + // Only update areas if more than 1 exists. + if (!empty($areas) && count($areas) > 1) { // Get the unique areas. $new_areas = array_unique($areas, SORT_REGULAR); // Update the log. - $log_wrapper->field_farm_area->set($new_areas); - $log_wrapper->save(); + if (count($areas) > count($new_areas)) { + $log_wrapper->field_farm_area->set($new_areas); + $log_wrapper->save(); + } } $sandbox['progress']++;