|
|
@@ -293,7 +293,23 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
");
|
|
|
}
|
|
|
|
|
|
+ public function clearGetItemCache($pk = null) {
|
|
|
+ if (!$pk) $this->_cache = [];
|
|
|
+ else if (array_key_exists($pk, $this->_cache)) unset($this->_cache[$pk]);
|
|
|
+ }
|
|
|
public function getItem($pk, $params = []) {
|
|
|
+ // TODO: ceche query for: $pk = 'default_db/CRM_PROCES/PROCES', $params = [ 'propertyName' => "*,field" ]
|
|
|
+ if (!$this->_cache) $this->_cache = [];
|
|
|
+ if (!empty($this->_cache) && 1 === count($params) && "*,field" === V::get('propertyName', '', $params)) {
|
|
|
+ if (array_key_exists($pk, $this->_cache)) return $this->_cache[$pk];
|
|
|
+ $this->_cache[$pk] = $this->_getItem($pk, $params);
|
|
|
+ } else {
|
|
|
+ return $this->_getItem($pk, $params);
|
|
|
+ }
|
|
|
+ return $this->_cache[$pk];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function _getItem($pk, $params = []) {
|
|
|
if (!$pk) throw new Exception("Missing primary key '{$this->_namespace}'");
|
|
|
$pkField = $this->getSqlPrimaryKeyField();
|
|
|
if (!$pkField) throw new Exception("Missing primary key field defined in '{$this->_namespace}'");
|
|
|
@@ -366,10 +382,11 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
return $item;
|
|
|
}
|
|
|
|
|
|
- public function updateItem($itemPatch) {
|
|
|
+ public function updateItem($itemPatch) { // @required [ 'namespace' => ... ] (primaryKey)
|
|
|
$pkField = $this->getPrimaryKeyField();
|
|
|
$pk = V::get($pkField, null, $itemPatch);
|
|
|
if (null === $pk) throw new Exception("BUG missing primary key field for '{$this->_namespace}' updateItem");
|
|
|
+ $this->clearGetItemCache($pk);
|
|
|
DBG::log(['updateItem $itemPatch', $itemPatch]);
|
|
|
unset($itemPatch[$pkField]);
|
|
|
if (empty($itemPatch)) return 0;
|