Index: /trunk/workflow/setup/tables_current.inc.php
===================================================================
--- /trunk/workflow/setup/tables_current.inc.php	(revision 1229)
+++ /trunk/workflow/setup/tables_current.inc.php	(revision 2908)
@@ -190,9 +190,8 @@
 				'fd' => array(
 					'wf_parent_instance_id'	=> array('type' => 'int', 'precision' => '4', 'nullable' => False),
-					'wf_parent_activity_id'	=> array('type' => 'int', 'precision' => '4', 'nullable' => False),
 					'wf_child_instance_id' 	=> array('type' => 'int', 'precision' => '4', 'nullable' => False),
 					'wf_parent_lock' 		=> array('type' => 'int', 'precision' => '2', 'nullable' => True)
 				),
-				'pk' => array('wf_parent_instance_id', 'wf_parent_activity_id', 'wf_child_instance_id'),
+				'pk' => array('wf_parent_instance_id', 'wf_child_instance_id'),
 				'fk' => array(),
 				'ix' => array(),
Index: /trunk/workflow/setup/tables_update.inc.php
===================================================================
--- /trunk/workflow/setup/tables_update.inc.php	(revision 2757)
+++ /trunk/workflow/setup/tables_update.inc.php	(revision 2908)
@@ -1278,4 +1278,13 @@
 			/* reconnect to the previous database */
 			$GLOBALS['phpgw']->ADOdb->connect($workflowHostInfo['host'], $workflowHostInfo['user'], $workflowHostInfo['password'], $workflowHostInfo['dbname']);
+
+			/* removing primary key of egw_wf_interinstance_relations */
+			$GLOBALS['phpgw']->ADOdb->query('ALTER TABLE egw_wf_interinstance_relations DROP CONSTRAINT egw_wf_interinstance_relations_pkey');
+
+			/* removing wf_parent_activity_id column from egw_wf_interinstance_relations table */
+			$GLOBALS['phpgw']->ADOdb->query('ALTER TABLE egw_wf_interinstance_relations DROP COLUMN wf_parent_activity_id');
+
+			/* adding primary key without the column removed */
+			$GLOBALS['phpgw']->ADOdb->query('ALTER TABLE egw_wf_interinstance_relations ADD CONSTRAINT egw_wf_interinstance_relations_pkey PRIMARY KEY (wf_parent_instance_id, wf_child_instance_id)');
 		}
 
Index: /trunk/workflow/inc/class.so_move_instances.inc.php
===================================================================
--- /trunk/workflow/inc/class.so_move_instances.inc.php	(revision 2591)
+++ /trunk/workflow/inc/class.so_move_instances.inc.php	(revision 2908)
@@ -318,23 +318,4 @@
 		}
 
-		/* format the array elements for use in a SELECT SQL statement, e.g. [iid => 12, aid = 27] would produce (12, 27) */
-		$instanceActivityList = array_map(create_function('$e', 'return \'(\' . $e[\'iid\'] . \', \' . $e[\'aid\'] . \')\';'), $instanceActivityList);
-
-		/* update the interinstance relations of the modified rows of the instance_activities table */
-		$resultSet = $this->db->query("SELECT wf_parent_instance_id, wf_parent_activity_id FROM egw_wf_interinstance_relations WHERE ((wf_parent_instance_id, wf_parent_activity_id) IN (" . implode(', ', $instanceActivityList) . "))");
-		$rows = $resultSet->GetArray(-1);
-		if (is_array($rows))
-		{
-			foreach ($rows as $row)
-			{
-				/* update the activity ID */
-				if (!$this->db->query("UPDATE egw_wf_interinstance_relations SET wf_parent_activity_id = ? WHERE (wf_parent_instance_id = ?) AND (wf_parent_activity_id = ?)", array($activitiesConvert[$row['wf_parent_activity_id']], $row['wf_parent_instance_id'], $row['wf_parent_activity_id'])))
-				{
-					$this->db->FailTrans();
-					return array('error' => 'Erro atualizando a tabela de relacionamento inter-instância. Nenhuma modificação foi salva');
-				}
-			}
-		}
-
 		/* in case of success, commit the modifications */
 		$this->db->CompleteTrans();
Index: /trunk/workflow/inc/engine/src/common/WfRuntime.php
===================================================================
--- /trunk/workflow/inc/engine/src/common/WfRuntime.php	(revision 2776)
+++ /trunk/workflow/inc/engine/src/common/WfRuntime.php	(revision 2908)
@@ -1089,5 +1089,4 @@
     $run_activity = Factory::newInstance('run_activity');
     $run_activity->runtime->instance->parentInstanceId = $this->instance_id;
-    $run_activity->runtime->instance->parentActivityId = $this->activity_id;
     $output = $run_activity->goChildInstance($activityID, $properties, $user, $parentLock);
     $_REQUEST['iid'] = $iid;
@@ -1128,7 +1127,7 @@
   function getParent()
   {
-    $resultSet = $this->query("SELECT wf_parent_instance_id, wf_parent_activity_id, wf_parent_lock FROM egw_wf_interinstance_relations WHERE (wf_child_instance_id = ?)", array($this->getInstanceId()));
+    $resultSet = $this->query("SELECT wf_parent_instance_id, wf_parent_lock FROM egw_wf_interinstance_relations WHERE (wf_child_instance_id = ?)", array($this->getInstanceId()));
     if (($row = $resultSet->fetchRow()))
-      return array('instance_id' => $row['wf_parent_instance_id'], 'activity_id' => $row['wf_parent_activity_id'], 'lock' => ($row['wf_parent_lock'] == 1));
+      return array('instance_id' => $row['wf_parent_instance_id'], 'lock' => ($row['wf_parent_lock'] == 1));
     else
       return false;
Index: /trunk/workflow/inc/engine/src/API/Instance.php
===================================================================
--- /trunk/workflow/inc/engine/src/API/Instance.php	(revision 2887)
+++ /trunk/workflow/inc/engine/src/API/Instance.php	(revision 2908)
@@ -84,9 +84,4 @@
    */
   var $parentLock = false;
-  /**
-   * @var int $parentActivityId The activity ID of the parent instance
-   * @access public
-   */
-  var $parentActivityId;
   /**
    * @var int $parentInstanceId The instance ID of the parent instance
@@ -490,5 +485,5 @@
     return '';
   }
- 
+
   /**
    * Creates a new instance.
@@ -503,5 +498,5 @@
   function _createNewInstance($activityId,$user) {
     // Creates a new instance setting up started, ended, user, status and owner
-    $pid = $this->getOne('select wf_p_id from '.GALAXIA_TABLE_PREFIX.'activities where wf_activity_id=?',array((int)$activityId));
+    $pid = $this->getOne('SELECT wf_p_id FROM '.GALAXIA_TABLE_PREFIX.'activities WHERE wf_activity_id=?',array((int)$activityId));
     $this->pId = $pid;
     $this->setStatus('active');
@@ -515,26 +510,32 @@
     $iid=$this->instanceId;
 
-    $query = 'insert into '.GALAXIA_TABLE_PREFIX.'instances
-      (wf_instance_id, wf_started,wf_ended,wf_status,wf_p_id,wf_owner,wf_properties) 
-      values(?,?,?,?,?,?,?)';
-
-   $this->query($query,array((int)$iid, $now,0,'active',$pid,$user,$this->security_cleanup(Array(),false)));
- 
+    $query = 'INSERT INTO '.GALAXIA_TABLE_PREFIX.'instances
+                (wf_instance_id, wf_started,wf_ended,wf_status,wf_p_id,wf_owner,wf_properties)
+              VALUES
+                (?,?,?,?,?,?,?)';
+
+    $this->query($query,array((int)$iid, $now,0,'active',$pid,$user,$this->security_cleanup(Array(),false)));
+
     // Then add in ".GALAXIA_TABLE_PREFIX."instance_activities an entry for the
     // activity the user and status running and started now
-    $query = 'insert into '.GALAXIA_TABLE_PREFIX.'instance_activities (wf_instance_id,wf_activity_id,wf_user,
-            wf_started,wf_status) values(?,?,?,?,?)';
+    $query = 'INSERT INTO '.GALAXIA_TABLE_PREFIX.'instance_activities
+                (wf_instance_id,wf_activity_id,wf_user,wf_started,wf_status)
+              VALUES
+                (?,?,?,?,?)';
     $this->query($query,array((int)$iid,(int)$activityId,$user,(int)$now,'running'));
 
     if (($this->isChildInstance) && (!is_null($this->parentInstanceId)))
     {
-      $query = 'INSERT INTO '.GALAXIA_TABLE_PREFIX.'interinstance_relations(wf_parent_instance_id, wf_parent_activity_id, wf_child_instance_id, wf_parent_lock) VALUES(?,?,?,?)';
-      $this->query($query,array((int) $this->parentInstanceId, (int) $this->parentActivityId, (int) $iid, (int) (($this->parentLock) ? 1 : 0)));
-    }
-    
+      $query = 'INSERT INTO '.GALAXIA_TABLE_PREFIX.'interinstance_relations
+                  (wf_parent_instance_id, wf_child_instance_id, wf_parent_lock)
+                VALUES
+                  (?,?,?)';
+      $this->query($query,array((int) $this->parentInstanceId, (int) $iid, (int) (($this->parentLock) ? 1 : 0)));
+    }
+
     //update database with other datas stored in the object
     return $this->sync();
   }
-  
+
   /**
    * Sets the name of this instance
@@ -1142,9 +1143,9 @@
     return $this->__activity_completed;
   }
- 
+
   /**
    * This function can be called by the instance object himself (for automatic activities)
-   * or by the WfRuntime object. In interactive activities code users use complete() --without args-- 
-   * which refer to the WfRuntime->complete() function which call this one. 
+   * or by the WfRuntime object. In interactive activities code users use complete() --without args--
+   * which refer to the WfRuntime->complete() function which call this one.
    * In non-interactive activities a call to a complete() will generate errors because the engine
    * does it his own way as I said first.
@@ -1162,5 +1163,5 @@
   {
     //$this->db->
-    $result = $this->query("SELECT 1 FROM " . GALAXIA_TABLE_PREFIX . "instances i, " . GALAXIA_TABLE_PREFIX . "interinstance_relations ir WHERE (ir.wf_child_instance_id = i.wf_instance_id) AND (i.wf_status IN ('active', 'exception')) AND (ir.wf_parent_lock = 1) AND (ir.wf_parent_instance_id = ?) AND (ir.wf_parent_activity_id = ?)", array($this->instanceId, $activityId));
+    $result = $this->query("SELECT 1 FROM " . GALAXIA_TABLE_PREFIX . "instances i, " . GALAXIA_TABLE_PREFIX . "interinstance_relations ir WHERE (ir.wf_child_instance_id = i.wf_instance_id) AND (i.wf_status IN ('active', 'exception')) AND (ir.wf_parent_lock = 1) AND (ir.wf_parent_instance_id = ?)", array($this->instanceId));
     if ($result->numRows() > 0)
       die("Esta instância está aguardando que outras instâncias, das quais depende, sejam finalizadas.");
@@ -1170,5 +1171,5 @@
     //The complete() is in a transaction, it will be completly done or not at all
     $this->db->StartTrans();
-    
+
     //lock rows and ensure access is granted
     if (!(isset($this->security))) $this->security = &Factory::getInstance('WfSecurity');
