N°9525 - TagSet Errors

This commit is contained in:
Eric Espie
2026-04-20 17:42:35 +02:00
parent 848d869954
commit 900bd6956a
4 changed files with 17 additions and 14 deletions

View File

@@ -43,24 +43,24 @@ final class ormTagSet extends ormSet
/** /**
* *
* @param array $aTagCodes * @param array|null $aItems
* *
* @throws \CoreException * @throws \CoreException
* @throws \CoreUnexpectedValue when a code is invalid * @throws \CoreUnexpectedValue when a code is invalid
*/ */
public function SetValues($aTagCodes) public function SetValues($aItems)
{ {
if (is_null($aTagCodes)) { if (is_null($aItems)) {
$aTagCodes = []; $aItems = [];
} }
if (!is_array($aTagCodes)) { if (!is_array($aItems)) {
throw new CoreUnexpectedValue("Wrong value {$aTagCodes} for {$this->sClass}:{$this->sAttCode}"); throw new CoreUnexpectedValue("Wrong value {$aItems} for {$this->sClass}:{$this->sAttCode}");
} }
$oTags = []; $oTags = [];
$iCount = 0; $iCount = 0;
$bError = false; $bError = false;
foreach ($aTagCodes as $sTagCode) { foreach ($aItems as $sTagCode) {
$iCount++; $iCount++;
if (($this->iLimit != 0) && ($iCount > $this->iLimit)) { if (($this->iLimit != 0) && ($iCount > $this->iLimit)) {
$bError = true; $bError = true;

View File

@@ -21,6 +21,7 @@ SetupWebPage::AddModule(
// Components // Components
// //
'datamodel' => [ 'datamodel' => [
'model.itop-faq-light.php',
], ],
'data.struct' => [ 'data.struct' => [
//'data.struct.itop-knownerror-mgmt.xml', //'data.struct.itop-knownerror-mgmt.xml',

View File

@@ -213,7 +213,7 @@ abstract class AttributeSet extends AttributeDBFieldVoid
* force an allowed value (type conversion and possibly forces a value as mySQL would do upon writing! * force an allowed value (type conversion and possibly forces a value as mySQL would do upon writing!
* *
* @param $proposedValue * @param $proposedValue
* @param DBObject $oHostObj * @param DBObject|null $oHostObj
* *
* @param bool $bIgnoreErrors * @param bool $bIgnoreErrors
* *

View File

@@ -7,6 +7,8 @@
namespace Combodo\iTop\Core\AttributeDefinition; namespace Combodo\iTop\Core\AttributeDefinition;
use ApplicationContext;
use cmdbAbstractObject;
use CoreException; use CoreException;
use CoreUnexpectedValue; use CoreUnexpectedValue;
use CoreWarning; use CoreWarning;
@@ -534,21 +536,21 @@ HTML;
} }
/** /**
* @param $value * @param $sValue
* @param DBObject $oHostObject * @param DBObject $oHostObject
* @param bool $bLocalize * @param bool $bLocalize
* *
* @return string * @return string
* *
*/ */
public function GetAsXML($value, $oHostObject = null, $bLocalize = true) public function GetAsXML($sValue, $oHostObject = null, $bLocalize = true)
{ {
if (is_object($value) && ($value instanceof ormTagSet)) { if (is_object($sValue) && ($sValue instanceof ormTagSet)) {
$sRes = "<Set>\n"; $sRes = "<Set>\n";
if ($bLocalize) { if ($bLocalize) {
$aValues = $value->GetLabels(); $aValues = $sValue->GetLabels();
} else { } else {
$aValues = $value->GetValues(); $aValues = $sValue->GetValues();
} }
if (!empty($aValues)) { if (!empty($aValues)) {
$sRes .= '<Tag>'.implode('</Tag><Tag>', $aValues).'</Tag>'; $sRes .= '<Tag>'.implode('</Tag><Tag>', $aValues).'</Tag>';
@@ -636,7 +638,7 @@ HTML;
public function FromJSONToValue($json) public function FromJSONToValue($json)
{ {
$oSet = new ormTagSet($this->GetHostClass(), $this->GetCode(), $this->GetMaxItems()); $oSet = new ormTagSet($this->GetHostClass(), $this->GetCode(), $this->GetMaxItems());
$oSet->SetValues($json); $oSet->SetValues(json_decode($json, true));
return $oSet; return $oSet;
} }