Skip to content

N°8528 - ignore silo not applied on 1:n linkedset displayed in form in portal#761

Open
accognet wants to merge 1 commit intodevelopfrom
feature/8528-ignore_silo_1_n_linkedset_in_portal
Open

N°8528 - ignore silo not applied on 1:n linkedset displayed in form in portal#761
accognet wants to merge 1 commit intodevelopfrom
feature/8528-ignore_silo_1_n_linkedset_in_portal

Conversation

@accognet
Copy link
Copy Markdown
Contributor

internal

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes portal linkedset scoping so that the “ignore silos” behavior is correctly applied for 1:n linkedsets displayed in portal forms.

Changes:

  • Apply portal scope (via ScopeValidatorHelper) to AttributeLinkedSet::GetDefaultValue() queries when running in portal context.
  • Optimize ormLinkSet index-building by reducing loaded columns and adjust iteration object loading behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
sources/Core/AttributeDefinition/AttributeLinkedSet.php Intersects linkedset query with portal scope so silos / ignore-silos rules are applied in portal.
core/ormlinkset.class.inc.php Optimizes column loading during index generation and changes how preserved items are reloaded during iteration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

{
$sId = key($this->aPreserved);
$oRet = MetaModel::GetObject($this->sClass, $sId);
$oRet = MetaModel::GetObject($this->sClass, $sId, true, true);
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MetaModel::GetObject($this->sClass, $sId, true, true) sets $bAllowAllData=true, which bypasses user-rights filtering for every ormLinkSet iteration. As ormLinkSet is a core structure used outside the portal, this can expose objects/fields a user is not allowed to read. Instead, pass the AllowAllData flag from the original set/search (eg based on $this->oOriginalSet->GetFilter()->IsAllDataAllowed()), so ignoring silos only happens when the underlying query explicitly allows it.

Suggested change
$oRet = MetaModel::GetObject($this->sClass, $sId, true, true);
$bAllowAllData = false;
if ($this->oOriginalSet !== null)
{
$bAllowAllData = $this->oOriginalSet->GetFilter()->IsAllDataAllowed();
}
$oRet = MetaModel::GetObject($this->sClass, $sId, true, $bAllowAllData);

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 👌

{
$aRet = array();
$this->oOriginalSet->Rewind();
$this->oOriginalSet->OptimizeColumnLoad([$this->sClass => []]);
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OptimizeColumnLoad() expects an array keyed by class alias (see DBObjectSet::OptimizeColumnLoad()), but this uses $this->sClass (class name). If the underlying filter alias was renamed (eg to Link in indirect linkedsets), this optimization won’t apply and the set may still load all columns. Use the original filter’s class alias (eg $this->oOriginalSet->GetFilter()->GetClassAlias()) as the key.

Suggested change
$this->oOriginalSet->OptimizeColumnLoad([$this->sClass => []]);
$oFilter = $this->oOriginalSet->GetFilter();
$sClassAlias = $oFilter->GetClassAlias();
$this->oOriginalSet->OptimizeColumnLoad([$sClassAlias => []]);

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 👌

Copy link
Copy Markdown
Contributor

@bdalsass bdalsass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well but needs another opinion.

Also needs to be rebased on support/3.2 branch.
Be carefull with AttributeDefinition file splitting.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there is a way to move this handling inside the portal sources for better isolation 🤔

@bdalsass bdalsass requested a review from rquetiez April 1, 2026 07:38
Copy link
Copy Markdown
Contributor

@rquetiez rquetiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This proposal needs a rework so that the itop core remains uncoupled from external consumers such as the Portal.

$this->oOriginalSet->Rewind();
$this->oOriginalSet->OptimizeColumnLoad([$this->sClass => []]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the intention here with regard to the goal of this PR?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core implementation MUST NOT be coupled to the portal (here ScopeValidatorHelper, PORTAL_ID)
Could be acceptable solely for maintenance purposes (branch 2.3)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what reason this call would be removed ? Fetch can be called in the first place when browsing a set of links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Work made by Combodo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants