浏览代码

Fix for Trac #608: install broken on PHP < 5.2.17

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2481 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 12 年之前
父节点
当前提交
99aed65db1
共有 2 个文件被更改,包括 8 次插入4 次删除
  1. 2 2
      setup/compiler.class.inc.php
  2. 6 2
      setup/modelfactory.class.inc.php

+ 2 - 2
setup/compiler.class.inc.php

@@ -82,7 +82,7 @@ class MFCompiler
 		if ($oUserRightsNode)
 		{
 			$sUserRightsModule = $oUserRightsNode->getAttribute('_created_in');
-			$this->Log("User Rights module foud: $sUserRightsModule");
+			$this->Log("User Rights module found: $sUserRightsModule");
 		}
 
 		// List root classes
@@ -90,7 +90,7 @@ class MFCompiler
 		$this->aRootClasses = array();
 		foreach ($this->oFactory->ListRootClasses() as $oClass)
 		{
-			$this->Log("Root class: ".$oClass->getAttribute('id'));
+			$this->Log("Root class (with child classes): ".$oClass->getAttribute('id'));
 			$this->aRootClasses[$oClass->getAttribute('id')] = $oClass;
 		}
 

+ 6 - 2
setup/modelfactory.class.inc.php

@@ -1686,7 +1686,9 @@ class MFElement extends DOMElement
 				{
 					throw new Exception("XML datamodel loader: found mandatory node $this->tagName/$sSearchId marked as deleted in $oContainer->tagName");
 				}
-				$oTargetNode = $oContainer->ownerDocument->ImportNode($this, false);
+				// Beware: ImportNode(xxx, false) DOES NOT copy the node's attribute on *some* PHP versions (<5.2.17)
+				// So use this workaround to import a node and its attributes on *any* PHP version
+				$oTargetNode = $oContainer->ownerDocument->ImportNode($this->cloneNode(false), true);
 				$oContainer->AddChildNode($oTargetNode);
 			}
 		}
@@ -1698,7 +1700,9 @@ class MFElement extends DOMElement
 				$oContainer->Dump();
 				throw new Exception("XML datamodel loader: could not find $this->tagName/$sSearchId in $oContainer->tagName");
 			}
-			$oTargetNode = $oContainer->ownerDocument->ImportNode($this, false);
+			// Beware: ImportNode(xxx, false) DOES NOT copy the node's attribute on *some* PHP versions (<5.2.17)
+			// So use this workaround to import a node and its attributes on *any* PHP version
+			$oTargetNode = $oContainer->ownerDocument->ImportNode($this->cloneNode(false), true);
 			$oContainer->AddChildNode($oTargetNode);
 		}
 		return $oTargetNode;