N°7636 - Too many OQL requests executed in order to display a lnk (#661)

This commit is contained in:
Anne-Catherine
2024-12-09 15:15:33 +01:00
committed by GitHub
parent eedbf3d266
commit 324cb5eb6c
6 changed files with 56 additions and 12 deletions

View File

@@ -82,6 +82,7 @@ abstract class AbstractBlockLinkSetViewTable extends UIContentBlock
protected bool $bIsAllowCreate;
protected bool $bIsAllowModify;
protected bool $bIsAllowDelete;
protected int $iCount;
/**
* Constructor.
@@ -95,7 +96,7 @@ abstract class AbstractBlockLinkSetViewTable extends UIContentBlock
*
* @throws \CoreException
*/
public function __construct(WebPage $oPage, DBObject $oDbObject, string $sObjectClass, string $sAttCode, AttributeLinkedSet $oAttDef, bool $bIsReadOnly = false)
public function __construct(WebPage $oPage, DBObject $oDbObject, string $sObjectClass, string $sAttCode, AttributeLinkedSet $oAttDef, bool $bIsReadOnly = false, ?int $iCount = null)
{
parent::__construct("links_view_table_$sAttCode", ["ibo-block-links-table"]);
@@ -106,6 +107,7 @@ abstract class AbstractBlockLinkSetViewTable extends UIContentBlock
$this->oDbObject = $oDbObject;
$this->sTableId = 'rel_'.$this->sAttCode;
$this->bIsAttEditable = !$bIsReadOnly;
$this->iCount = $iCount;
$this->SetDataAttributes(['role' => 'ibo-block-links-table', 'link-attcode' => $sAttCode, 'link-class' => $this->oAttDef->GetLinkedClass()]);
// Initialization
$this->Init();
@@ -195,9 +197,13 @@ abstract class AbstractBlockLinkSetViewTable extends UIContentBlock
$oOrmLinkSet = $this->oDbObject->Get($this->sAttCode);
$oLinkSet = $oOrmLinkSet->ToDBObjectSet(utils::ShowObsoleteData());
$aExtraParams = $this->GetExtraParam();
if (is_null($this->iCount) === false) {
$aExtraParams['object_count' ] = $this->iCount;
}
// add list block
$oBlock = new DisplayBlock($oLinkSet->GetFilter(), DisplayBlock::ENUM_STYLE_LIST_IN_OBJECT, false);
$this->AddSubBlock($oBlock->GetRenderContent($oPage, $this->GetExtraParam(), $this->sTableId));
$this->AddSubBlock($oBlock->GetRenderContent($oPage, $aExtraParams, $this->sTableId));
}