Sfoglia il codice sorgente

added cache for SystemObject getItem

Piotr Labudda 8 anni fa
parent
commit
58b1c8ae46
1 ha cambiato i file con 5 aggiunte e 5 eliminazioni
  1. 5 5
      SE/se-lib/Schema/SystemObjectStorageAcl.php

+ 5 - 5
SE/se-lib/Schema/SystemObjectStorageAcl.php

@@ -378,16 +378,16 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
 	public function getItem($pk, $params = []) {
 	public function getItem($pk, $params = []) {
 		// TODO: ceche query for: $pk = 'default_db/CRM_PROCES/PROCES', $params = [ 'propertyName' => "*,field" ]
 		// TODO: ceche query for: $pk = 'default_db/CRM_PROCES/PROCES', $params = [ 'propertyName' => "*,field" ]
 		if (!$this->_cache) $this->_cache = [];
 		if (!$this->_cache) $this->_cache = [];
-		if (!empty($this->_cache) && 1 === count($params) && "*,field" === V::get('propertyName', '', $params)) {
+		if (1 === count($params) && "*,field" === V::get('propertyName', '', $params)) {
 			if (array_key_exists($pk, $this->_cache)) return $this->_cache[$pk];
 			if (array_key_exists($pk, $this->_cache)) return $this->_cache[$pk];
-			$this->_cache[$pk] = $this->_getItem($pk, $params);
+			$this->_cache[$pk] = $this->_fetchItem($pk, $params);
 		} else {
 		} else {
-			return $this->_getItem($pk, $params);
+			return $this->_fetchItem($pk, $params);
 		}
 		}
 		return $this->_cache[$pk];
 		return $this->_cache[$pk];
 	}
 	}
 
 
-	public function _getItem($pk, $params = []) {
+	public function _fetchItem($pk, $params = []) {
 		if (!$pk) throw new Exception("Missing primary key '{$this->_namespace}'");
 		if (!$pk) throw new Exception("Missing primary key '{$this->_namespace}'");
 		$pkField = $this->getSqlPrimaryKeyField();
 		$pkField = $this->getSqlPrimaryKeyField();
 		if (!$pkField) throw new Exception("Missing primary key field defined in '{$this->_namespace}'");
 		if (!$pkField) throw new Exception("Missing primary key field defined in '{$this->_namespace}'");
@@ -436,7 +436,7 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
 	}
 	}
 
 
 	public function buildFeatureFromSqlRow($item, $params = []) {
 	public function buildFeatureFromSqlRow($item, $params = []) {
-		DBG::log($params, 'array', "buildFeatureFromSqlRow...");
+		DBG::log($params, 'array', "buildFeatureFromSqlRow... '{$item['namespace']}'");
 		$exNs = explode('/', $item['namespace']);
 		$exNs = explode('/', $item['namespace']);
 		$item['name'] = array_pop($exNs);
 		$item['name'] = array_pop($exNs);
 		$item['nsPrefix'] = implode('__x3A__', $exNs);
 		$item['nsPrefix'] = implode('__x3A__', $exNs);