avoid fetch_objectlinked for each page of the document

This commit is contained in:
atm-greg 2022-04-04 14:31:48 +02:00
parent d0ed15ce5c
commit 2455d8fe52
2 changed files with 11 additions and 1 deletions

View File

@ -123,6 +123,11 @@ abstract class CommonObject
*/
public $linkedObjects;
/**
* @var boolean is linkedObjects full loaded. Loaded by ->fetchObjectLinked
*/
public $linkedObjectsFullLoaded = false;
/**
* @var Object To store a cloned copy of object before to edit it and keep track of old properties
*/
@ -3834,6 +3839,9 @@ abstract class CommonObject
} else {
$sql .= "(fk_source = ".((int) $sourceid)." AND sourcetype = '".$this->db->escape($sourcetype)."')";
$sql .= " ".$clause." (fk_target = ".((int) $targetid)." AND targettype = '".$this->db->escape($targettype)."')";
if ($sourceid == $this->id && $sourcetype == $this->element && $targetid == $this->id && $targettype == $this->element && $clause == 'OR') {
$this->linkedObjectsFullLoaded = true;
}
}
$sql .= " ORDER BY ".$orderby;

View File

@ -2282,7 +2282,9 @@ function pdf_getLinkedObjects(&$object, $outputlangs)
$linkedobjects = array();
$object->fetchObjectLinked();
if (empty($object->linkedObjectsFullLoaded)) {
$object->fetchObjectLinked();
}
foreach ($object->linkedObjects as $objecttype => $objects) {
if ($objecttype == 'facture') {