From 322bbd934b9fb9c1cfe4aa3336c4d45f12bed2da Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Mon, 24 Jun 2024 22:53:43 +0200 Subject: [PATCH 1/2] fix : 19.0 fix inconsistent link validation (#30141) * Dirty fix for inconcistant link psedo langage * add todo * Update commonobject.class.php * Update commonobject.class.php --------- Co-authored-by: Laurent Destailleur --- htdocs/core/class/commonobject.class.php | 9 ++++++++- htdocs/core/class/validate.class.php | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index afb86b05a66..c4bf7145661 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8495,7 +8495,14 @@ abstract class CommonObject $classname = $InfoFieldList[0]; $classpath = $InfoFieldList[1]; if (!$validate->isFetchable($fieldValue, $classname, $classpath)) { - $this->setFieldError($fieldKey, $validate->error); + $lastIsFetchableError = $validate->error; + + // from V19 of Dolibarr, In some cases link use element instead of class, example project_task + if ($validate->isFetchableElement($fieldValue, $classname)) { + return true; + } + + $this->setFieldError($fieldKey, $lastIsFetchableError); return false; } else { return true; diff --git a/htdocs/core/class/validate.class.php b/htdocs/core/class/validate.class.php index 50d290f7517..1c14d3e60bd 100644 --- a/htdocs/core/class/validate.class.php +++ b/htdocs/core/class/validate.class.php @@ -335,4 +335,20 @@ class Validate } return false; } + + /** + * Check for all values in db for an element + * @see self::isFetchable() + * + * @param integer $id of element + * @param string $element_type the element type + * @return boolean Validity is ok or not + * @throws Exception + */ + public function isFetchableElement($id, $element_type) + { + // TODO use newObjectByElement() introduce in V20 by PR #30036 for better errors management + $elementProperty = getElementProperties($element_type); + return $this->isFetchable($id, $elementProperty['classname'], $elementProperty['classpath'].'/'.$elementProperty['classfile'].'.class.php'); + } } From e57e99fe19e9fe6bd2af89b87211a30d8283fd33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 25 Jun 2024 15:12:03 +0200 Subject: [PATCH 2/2] fix warning with pgsql DoliDB.class.php (#30153) --- htdocs/core/db/DoliDB.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index a6469cf6939..666a755ed24 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -181,8 +181,10 @@ abstract class DoliDB implements Database $this->transaction_opened++; dol_syslog("BEGIN Transaction".($textinlog ? ' '.$textinlog : ''), LOG_DEBUG); dol_syslog('', 0, 1); + return 1; + } else { + return 0; } - return $ret; } else { $this->transaction_opened++; dol_syslog('', 0, 1);