Skip to content
Open
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
24 changes: 24 additions & 0 deletions core/dbobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,30 @@ public function SetIfNull($sAttCode, $value)
}
}

/**
* Helper to copy a value only if the target is currently undefined
*
* Call Copy() only of the internal representation of the target attribute is null.
*
* @api
* @see Copy()
* @see SetIfNull())
*
* @param string $sDestAttCode
* @param string $sSourceAttCode
*
* @return bool true if copy was successfull or was not performed because target attribute isn't null
*
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \Exception
*/
public function CopyIfNull($sDestAttCode, $sSourceAttCode)
{
$this->SetIfNull($sDestAttCode, $this->Get($sSourceAttCode));
return true;
Copy link
Contributor Author

@favincen favincen Dec 8, 2025

Choose a reason for hiding this comment

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

Note to Combodo: Set() and Copy() do return true unconditionaly upon completion, but SetIfNul() do not return any value. Seems unconsistant to me.
So how do this new CopyIfNull() method should behave concerning returning value ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And should SetIfNull() be updated to return a boolean upon completion ?

}

/**
* Helper to set a value that fits the attribute max size
*
Expand Down