Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F847988
D44.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Apr 19, 9:42 PM
Size
2 KB
Mime Type
text/x-diff
Expires
Sun, Apr 20, 9:42 PM (1 h, 20 m)
Engine
blob
Format
Raw Data
Handle
602758
Attached To
D44: MINC-114 - Cleanup IDs of saved orders before adding/editing new orders
D44.diff
View Options
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;
}
/**
Event Timeline
Log In to Comment