瀏覽代碼

N°977 DataSynchro: Creation and edition was broken due to the new object set API from ormLinkSet.

Backward compatible method have been introduce to ensure plugins and modules compatibility. That being said they are already flagged as deprecated and should not be used.
New: Using those deprecated methods will raise a PHP deprecated error.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4878 a333f486-631f-4898-b8df-5754b55c2be0
glajarige 7 年之前
父節點
當前提交
42b253b22c
共有 2 個文件被更改,包括 42 次插入6 次删除
  1. 39 1
      core/ormlinkset.class.inc.php
  2. 3 5
      synchro/synchrodatasource.class.inc.php

+ 39 - 1
core/ormlinkset.class.inc.php

@@ -127,6 +127,18 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
 		$this->bHasDelta = true;
 	}
 
+    /**
+     * @param DBObject $oObject
+     * @param string $sClassAlias
+     * @deprecated
+     */
+	public function AddObject(DBObject $oObject, $sClassAlias = '')
+    {
+        trigger_error('iTop: ormLinkSet::AddObject() is deprecated use ormLinkSet::AddItem() instead.', E_USER_DEPRECATED);
+
+        $this->AddItem($oObject);
+    }
+
 	/**
 	 * @param $iObjectId
 	 */
@@ -177,7 +189,33 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
 		}
 	}
 
-	/**
+    /**
+     * Note: After calling this method, the set cursor will be at the end of the set. You might to rewind it.
+     *
+     * @param bool $bWithId
+     * @return array
+     * @deprecated
+     */
+    public function ToArray($bWithId = true)
+    {
+        trigger_error('iTop: ormLinkSet::ToArray() is deprecated use foreach instead.', E_USER_DEPRECATED);
+
+        $aRet = array();
+        foreach($this as $oItem)
+        {
+            if ($bWithId)
+            {
+                $aRet[$oItem->GetKey()] = $oItem;
+            }
+            else
+            {
+                $aRet[] = $oItem;
+            }
+        }
+        return $aRet;
+    }
+
+    /**
 	 * The class of the objects of the collection (at least a common ancestor)
 	 *
 	 * @return string

+ 3 - 5
synchro/synchrodatasource.class.inc.php

@@ -560,7 +560,7 @@ EOF
 			elseif ($oAttribute instanceof SynchroAttLinkSet)
 			{
 			}
-			$oAttributeSet->AddObject($oAttribute);
+			$oAttributeSet->AddItem($oAttribute);
 		}
 		$this->Set('attribute_list', $oAttributeSet);
 	}
@@ -648,12 +648,11 @@ EOF
 
 						if (!is_null($oAttribute))
 						{
-							$oAttribute->Set('sync_source_id', $this->GetKey());
 							$oAttribute->Set('attcode', $sAttCode);
 							$oAttribute->Set('reconcile', MetaModel::IsReconcKey($this->GetTargetClass(), $sAttCode) ? 1 : 0);
 							$oAttribute->Set('update', 1);
 							$oAttribute->Set('update_policy', 'master_locked');
-							$oAttributeSet->AddObject($oAttribute);
+							$oAttributeSet->AddItem($oAttribute);
 						}
 					}
 				}
@@ -677,9 +676,8 @@ EOF
 		if ($this->Get('reconciliation_policy') == 'use_attributes')
 		{
 			$oSet = $this->Get('attribute_list');
-			$oSynchroAttributeList = $oSet->ToArray();
 			$bReconciliationKey = false;
-			foreach($oSynchroAttributeList as $oSynchroAttribute)
+			foreach($oSet as $oSynchroAttribute)
 			{
 				if ($oSynchroAttribute->Get('reconcile') == 1)
 				{