Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion application/cmdbabstract.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
*/
protected $sDisplayMode;
protected $aFieldsMap;
/**
* @var array Store posted values in order to be used in GetAttributeFlag
*/
protected $aPostedValues = [];
Comment on lines +179 to +182
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

Indentation of this new property/docblock doesn’t follow the surrounding convention in this file (tabs). Also the doc refers to “GetAttributeFlag” but the actual API is GetAttributeFlags() / GetFormAttributeFlags(); please update the wording to avoid confusion.

Copilot uses AI. Check for mistakes.

/**
* If true, bypass IsActionAllowedOnAttribute when writing this object
Expand Down Expand Up @@ -3884,7 +3888,33 @@ public function GetWriteableAttList($aAttList, &$aErrors, $aAttFlags = array())
return $aWriteableAttList;
}

/**
/**
* function to test if the posted value or if not exists the existing value matches the expected value
* this is used to check the current value in GetAttributeFlag function (useful to manage dynamic readonly attributes)
* @param $sAttCode
Comment on lines +3891 to +3894
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The PHPDoc is misleading: this method doesn’t “test” anything nor compare to an “expected value”; it returns the posted value (if any) or the object’s current value. Please rewrite the doc to match behavior (and reference GetAttributeFlags() with the correct name).

Copilot uses AI. Check for mistakes.
*/
public function GetCurrentValueInScreen($sAttCode)
{
Comment on lines +3896 to +3897
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

PR description / example mentions using $this->GetCurrentValue('status'), but the new helper is named GetCurrentValueInScreen(). To make the documented usage work and keep the API intuitive, consider adding a GetCurrentValue() alias (or renaming this method) and updating references accordingly.

Copilot uses AI. Check for mistakes.
if (array_key_exists($sAttCode, $this->aPostedValues)) {
return $this->aPostedValues[$sAttCode];
}
return $this->Get($sAttCode);
}

/*
* This function checks if the value of the attribute has been modified in screen
* this is used to check if field has been modified in GetAttributeFlag function (useful to manage dynamic readonly attributes)
* @param $sAttCode
Comment on lines +3905 to +3907
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

Same as above: the doc references “GetAttributeFlag” (singular / different casing) which doesn’t match the actual GetAttributeFlags() method name. Please fix the wording so integrators know which hook this is intended for.

Copilot uses AI. Check for mistakes.
*/
public function IsModifiedValueInScreen($sAttCode)
{
if (array_key_exists($sAttCode, $this->aPostedValues)) {
return $this->aPostedValues[$sAttCode] != $this->Get($sAttCode);
}
return false;
}

/**
* Compute the attribute flags depending on the object state
*/
public function GetFormAttributeFlags($sAttCode)
Expand Down Expand Up @@ -4110,6 +4140,7 @@ public function UpdateObjectFromPostedForm($sFormPrefix = '', $aAttList = null,

$aErrors = array();
$aFinalValues = array();
$this->aPostedValues = $aValues; // Store the values for later use (e.g. in getAttributeFlag)
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

Minor doc/casing issue: comment says “getAttributeFlag” but the method is GetAttributeFlags() (and this assignment is used before calling it). Please align wording for clarity.

Suggested change
$this->aPostedValues = $aValues; // Store the values for later use (e.g. in getAttributeFlag)
$this->aPostedValues = $aValues; // Store the values for later use (e.g. in GetAttributeFlags())

Copilot uses AI. Check for mistakes.
foreach($this->GetWriteableAttList(array_keys($aValues), $aErrors, $aAttFlags) as $sAttCode => $oAttDef)
{
$aFinalValues[$sAttCode] = $aValues[$sAttCode];
Expand Down
2 changes: 1 addition & 1 deletion core/ormlinkset.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ public function UpdateFromCompleteList(iDBObjectSetIterator $oFellow)
* $oCISet->RemoveItem(123456);
* $oTicket->Set(‘functionalcis_list’, $oCISet);
*/
if (!ContextTag::Check(ContextTag::TAG_SETUP)) {
if (ContextTag::Check(ContextTag::TAG_PORTAL) || ContextTag::Check(ContextTag::TAG_CONSOLE) ) {
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('old pattern - please get previous value of the linked set, modify it and set it back to the host object');
Comment on lines +524 to 525
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The deprecation notification condition changed from “log everywhere except setup” to “log only in portal/console”. This significantly reduces visibility of this deprecated API usage in other contexts (REST/cron/custom scripts) and isn’t mentioned in the PR description; please confirm this behavior change is intended (or restore the previous !TAG_SETUP gating).

Copilot uses AI. Check for mistakes.
}
}
Expand Down