Author: david
Date: Mon Nov 16 17:12:24 2009
New Revision: 3899

Log:
Delete QubitObjectTermRelation rows related to deleted QubitEvent 'subject' 
events. Fixes issue #1129. --force

Modified:
   trunk/lib/task/migrate/QubitMigrate107to108.class.php

Modified: trunk/lib/task/migrate/QubitMigrate107to108.class.php
==============================================================================
--- trunk/lib/task/migrate/QubitMigrate107to108.class.php       Mon Nov 16 
15:00:38 2009        (r3898)
+++ trunk/lib/task/migrate/QubitMigrate107to108.class.php       Mon Nov 16 
17:12:24 2009        (r3899)
@@ -953,26 +953,29 @@
       {
         $event = $this->data['QubitEvent'][$key];
 
-        // Just delete if there is no actor for this event
-        if (!isset($event['actor_id']))
+        if (isset($event['actor_id']))
         {
-          unset($this->data['QubitEvent'][$key]);
-          continue;
+          // Get a random, unique key
+          do
+          {
+            $newKey = rand();
+          }
+          while (isset($this->data['QubitRelation'][$newKey]));
+
+          $this->data['QubitRelation']['QubitRelation_'.$newKey] = array(
+            'subject_id' => $event['information_object_id'],
+            'object_id' => $event['actor_id'],
+            'type_id' => '<?php echo QubitTerm::NAME_ACCESS_POINT_ID."\n" ?>'
+          );
         }
 
-        // Get a random, unique key
-        do
+        // Delete QubitObjectTermRelations linked to QubitEvent
+        while ($otrKey = $this->getRowKey('QubitObjectTermRelation', 
'object_id', $key))
         {
-          $newKey = rand();
+          unset($this->data['QubitObjectTermRelation'][$otrKey]);
         }
-        while (isset($this->data['QubitRelation'][$newKey]));
-
-        $this->data['QubitRelation']['QubitRelation_'.$newKey] = array(
-          'subject_id' => $event['information_object_id'],
-          'object_id' => $event['actor_id'],
-          'type_id' => '<?php echo QubitTerm::NAME_ACCESS_POINT_ID."\n" ?>'
-        );
 
+        // Delete QubitEvent object
         unset($this->data['QubitEvent'][$key]);
       }
     }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to