Ver Fonte

fixed loadSchema in TableAcl

Piotr Labudda há 9 anos atrás
pai
commit
e0f4575cf7
1 ficheiros alterados com 9 adições e 8 exclusões
  1. 9 8
      SE/se-lib/TableAcl.php

+ 9 - 8
SE/se-lib/TableAcl.php

@@ -968,10 +968,11 @@ class TableAcl extends Core_AclBase {
 	}
 
 	public function loadSchema() {
-		if ($this->_schemaLoaded) return;
+		if ($this->_schemaLoaded) return (bool)$this->_schemaClass;
 		$srvName = $_SERVER['SERVER_NAME'];
 		$this->_schemaClass = Schema_TableFactory::build($this->_name, $this->_db, $srvName);
 		$this->_schemaLoaded = true;
+		return (bool)$this->_schemaClass;
 	}
 
 	public function init($force = false) {
@@ -979,11 +980,11 @@ class TableAcl extends Core_AclBase {
 	}
 
 	public function fieldsInit($force = false) {
+		$this->loadSchema();
 		if (null !== $this->_executed_fieldsInit) return;
 		$this->_executed_fieldsInit = true;
 
 		DBG::log("DBG INIT - fieldsInit ({$this->_zasobID}, {$this->_rootTableName})");
-		$this->loadSchema();
 		if (empty($this->_fields)) {
 			$this->_types = array();// clear _types @see $this->isInitialized
 			$userAcl = User::getAcl();
@@ -1017,7 +1018,7 @@ class TableAcl extends Core_AclBase {
 		$this->_sortEnumFields();
 		$this->_fixProjectType();
 
-		if ($this->_schemaClass) $this->_types = $this->_schemaClass->fixTypes($this->_types);
+		if ($this->loadSchema()) $this->_types = $this->_schemaClass->fixTypes($this->_types);
 		//DBG::_(true, true, "this->_types", $this->_types, __CLASS__, __FUNCTION__, __LINE__);
 
 		// fixGeomTypesFromSimpleType
@@ -1547,7 +1548,7 @@ class TableAcl extends Core_AclBase {
 	}
 
 	public function getHistItems($primaryKey) {
-		if ($this->_schemaClass && method_exists($this->_schemaClass, 'hasGetHistItems') && $this->_schemaClass->hasGetHistItems()) {
+		if ($this->loadSchema() && method_exists($this->_schemaClass, 'hasGetHistItems') && $this->_schemaClass->hasGetHistItems()) {
 			return $this->_schemaClass->getHistItems($primaryKey);
 		}
 		$ds = $this->getDataSource();
@@ -1660,7 +1661,7 @@ class TableAcl extends Core_AclBase {
 		}
 		$itemPatchChecked[$primaryKeyField] = $primaryKey;
 
-		if ($this->_schemaClass && method_exists($this->_schemaClass, 'hasUpdateItem') && $this->_schemaClass->hasUpdateItem()) {
+		if ($this->loadSchema() && method_exists($this->_schemaClass, 'hasUpdateItem') && $this->_schemaClass->hasUpdateItem()) {
 			$affected = $this->_schemaClass->updateItem($itemPatchChecked);
 		} else {
 			$ds = $this->getDataSource();
@@ -1721,7 +1722,7 @@ class TableAcl extends Core_AclBase {
 	}
 
 	public function getPrimaryKeyField() {
-		if ($this->_schemaClass) {
+		if ($this->loadSchema()) {
 			$pkField = $this->_schemaClass->getPrimaryKeyField();
 			if ($pkField) return $pkField;
 		}
@@ -1886,7 +1887,7 @@ class TableAcl extends Core_AclBase {
 	}
 
 	public function getXsdFieldType($fieldName) {// @returns string - xsd type, TODO: throw Exception when field not found
-		if ($this->_schemaClass) {
+		if ($this->loadSchema()) {
 			$schemaType = $this->_schemaClass->getType($fieldName);
 			if ($schemaType) return $schemaType;
 		}
@@ -1911,7 +1912,7 @@ class TableAcl extends Core_AclBase {
 	}
 
 	public function getXsdFieldParam($fieldName, $paramKey) {
-		return ($this->_schemaClass)
+		return ($this->loadSchema())
 			? $this->_schemaClass->getFieldParam($fieldName, $paramKey)
 			: null
 		;