From: Iain Patterson Date: Thu, 10 Apr 2014 15:27:14 +0000 (-0400) Subject: Try harder to avoid duplicate order state IDs. X-Git-Tag: 2014-04-10~1 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=7cbf38d98e84961ccab6cd8213e322fa775a2b9e;hp=-c;p=readifood.git Try harder to avoid duplicate order state IDs. An order whose state was changed from delivered to something else then back to delivered might still appear in the order state array despite the presence of the hacked query to filter them out. We now run a secondary hack to remove them from the array. A better solution is needed here... --- 7cbf38d98e84961ccab6cd8213e322fa775a2b9e diff --git a/lib/report.php b/lib/report.php index b2bc16d..c58864d 100644 --- a/lib/report.php +++ b/lib/report.php @@ -231,9 +231,12 @@ $sth = $dbh->prepare("select * from OrderState o where updated=(select min(updated) from OrderState where order_id=o.order_id and state & " . $GLOBALS['STATE_DELIVERED'] . ") and updated between '$from' and '$to'"); $sth->execute(); $order_states = OrderStatePeer::populateObjects($sth); + $dups = array(); foreach ($order_states as $order_state) { - $order_ids[] = $order_state->getOrderId(); - $order_state_ids[] = $order_state->getId(); + $order_id = $order_state->getOrderId(); + $order_ids[] = $order_id; + if (! $dups[$order_id]) $order_state_ids[] = $order_state->getId(); + $dups[$order_id] = true; } $q = new OrderQuery; $q->filterById($order_ids);