From d1fa93a2b6692782a3711e3bc0dcabb601444409 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 23 Aug 2017 10:47:12 +0200 Subject: [PATCH] DB_model bugfix: - update method now is using _manageUDFs instead of directly UDFLib->manageUDFs - _manageUDFs method now accept the id as third parameter - if the third parameter of _manageUDFs is null the getUDFs is not called - If id parameter of method load is null now a correct parameter is given to get_where --- application/core/DB_Model.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php index e756f3100..1c2190f6d 100644 --- a/application/core/DB_Model.php +++ b/application/core/DB_Model.php @@ -111,7 +111,7 @@ class DB_Model extends FHC_Model if (isError($ent = $this->_isEntitled(PermissionLib::UPDATE_RIGHT))) return $ent; // If this table has UDF and the validation of them is ok - if (isError($validate = $this->udflib->manageUDFs($data, $this->dbTable, $this->getUDFs($id)))) return $validate; + if (isError($validate = $this->_manageUDFs($data, $this->dbTable, $id))) return $validate; $tmpId = $id; @@ -207,7 +207,7 @@ class DB_Model extends FHC_Model $tmpId = $this->_arrayCombine($this->pk, $id); } } - else + elseif ($id != null) { $tmpId = array($this->pk => $id); } @@ -782,13 +782,20 @@ class DB_Model extends FHC_Model /** * Wrapper method for UDFLib->manageUDFs */ - private function _manageUDFs(&$data, $schemaAndTable, $udfValues = null) + private function _manageUDFs(&$data, $schemaAndTable, $id = null) { $manageUDFs = success(true); if ($this->hasUDF()) { - $manageUDFs = $this->udflib->manageUDFs($data, $this->dbTable, $this->getUDFs($id)); + if ($id != null) + { + $manageUDFs = $this->udflib->manageUDFs($data, $this->dbTable, $this->getUDFs($id)); + } + else + { + $manageUDFs = $this->udflib->manageUDFs($data, $this->dbTable); + } } return $manageUDFs;