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 <eldy@destailleur.fr>
This commit is contained in:
John BOTELLA 2024-06-24 22:53:43 +02:00 committed by GitHub
parent a8e4f221e9
commit 322bbd934b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View file

@ -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;

View file

@ -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');
}
}