Index: branches/5.2.x/units/orders/orders_event_handler.php =================================================================== --- branches/5.2.x/units/orders/orders_event_handler.php +++ branches/5.2.x/units/orders/orders_event_handler.php @@ -3799,9 +3799,7 @@ return ; } - $copied_ids = unserialize($this->Application->RecallVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize(Array ()))); - - foreach ($copied_ids as $id) { + foreach ( $this->trackCopiedOrderIDs($event) as $id ) { $an_event = new kEvent($this->Prefix . ':Dummy'); $this->Application->SetVar($this->Prefix . '_id', $id); $this->Application->SetVar($this->Prefix . '_mode', ''); // this is to fool ReserveItems to use live table @@ -3810,22 +3808,39 @@ } /** - * Occurs before an item is copied to live table (after all foreign keys have been updated) - * Id of item being copied is passed as event' 'id' param + * Occurs after an item has been copied to live table + * Id of copied item is passed as event' 'id' param * * @param kEvent $event * @return void * @access protected */ - protected function OnBeforeCopyToLive(kEvent $event) + protected function OnAfterCopyToLive(kEvent $event) { - parent::OnBeforeCopyToLive($event); + parent::OnAfterCopyToLive($event); - $id = $event->getEventParam('id'); - $copied_ids = unserialize($this->Application->RecallVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize(array ()))); - array_push($copied_ids, $id); + $this->trackCopiedOrderIDs($event, $event->getEventParam('id')); + } + + /** + * Tracks copied order IDs. + * + * @param kEvent $event Event. + * @param integer $id Order ID. + * + * @return array + */ + protected function trackCopiedOrderIDs(kEvent $event, $id = null) + { + $setting_name = $event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'); + $ids = $this->Application->GetVar($setting_name, array()); + + if ( isset($id) ) { + array_push($ids, $id); + $this->Application->SetVar($setting_name, $ids); + } - $this->Application->StoreVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize($copied_ids)); + return $ids; } /**