only call updateMultiple if something changed
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 27 Apr 2016 09:33:41 +0000 (11:33 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 29 Apr 2016 08:29:13 +0000 (10:29 +0200)
 ... in updateProductLifespan

Change-Id: Idaab6f1d75fc42f1f082e9dfdf9c2d4fa73a6742
Reviewed-on: http://gerrit.tine20.com/customers/3098
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Sales/Controller/Product.php

index 042e40d..90c450e 100644 (file)
@@ -144,9 +144,13 @@ class Sales_Controller_Product extends Sales_Controller_NumberableAbstract
         
         $productIdsToChangeToInactive = $this->_getProductIdsForLifespanUpdate(/* $setToActive = */ false);
         $productIdsToChangeToActive   = $this->_getProductIdsForLifespanUpdate(/* $setToActive = */ true);
-        
-        $this->_backend->updateMultiple($productIdsToChangeToInactive, array('is_active' => false));
-        $this->_backend->updateMultiple($productIdsToChangeToActive,   array('is_active' => true));
+
+        if (count($productIdsToChangeToInactive) > 0) {
+            $this->_backend->updateMultiple($productIdsToChangeToInactive, array('is_active' => false));
+        }
+        if (count($productIdsToChangeToActive) > 0) {
+            $this->_backend->updateMultiple($productIdsToChangeToActive, array('is_active' => true));
+        }
     }
     
     /**