diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index 5b155171b..90a490921 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -1551,12 +1551,19 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ if($attributes) { foreach($attributes as $attrdefid=>$attribute) { /* $attribute can be a string or an array */ - if($attribute) - if(!$content->setAttributeValue($this->_dms->getAttributeDefinition($attrdefid), $attribute)) { + if($attribute) { + if($attrdef = $this->_dms->getAttributeDefinition($attrdefid)) { + if(!$content->setAttributeValue($attrdef, $attribute)) { + $this->_removeContent($content); + $db->rollbackTransaction(); + return false; + } + } else { $this->_removeContent($content); $db->rollbackTransaction(); return false; } + } } } diff --git a/SeedDMS_Core/Core/inc.ClassFolder.php b/SeedDMS_Core/Core/inc.ClassFolder.php index 25b01e6f1..2ad0a365e 100644 --- a/SeedDMS_Core/Core/inc.ClassFolder.php +++ b/SeedDMS_Core/Core/inc.ClassFolder.php @@ -700,7 +700,12 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { if($attributes) { foreach($attributes as $attrdefid=>$attribute) { if($attribute) - if(!$newFolder->setAttributeValue($this->_dms->getAttributeDefinition($attrdefid), $attribute)) { + if($attrdef = $this->_dms->getAttributeDefinition($attrdefid)) { + if(!$newFolder->setAttributeValue($attrdef, $attribute)) { + $db->rollbackTransaction(); + return false; + } + } else { $db->rollbackTransaction(); return false; } @@ -1026,12 +1031,19 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { if($attributes) { foreach($attributes as $attrdefid=>$attribute) { /* $attribute can be a string or an array */ - if($attribute) - if(!$document->setAttributeValue($this->_dms->getAttributeDefinition($attrdefid), $attribute)) { + if($attribute) { + if($attrdef = $this->_dms->getAttributeDefinition($attrdefid)) { + if(!$document->setAttributeValue($attrdef, $attribute)) { + $document->remove(); + $db->rollbackTransaction(); + return false; + } + } else { $document->remove(); $db->rollbackTransaction(); return false; } + } } } diff --git a/SeedDMS_Core/package.xml b/SeedDMS_Core/package.xml index 24ec9e12a..bd8ff243e 100644 --- a/SeedDMS_Core/package.xml +++ b/SeedDMS_Core/package.xml @@ -29,6 +29,7 @@ - new paramter 'new' of methode SeedDMЅ_Core_AttributeDefinition::validate() - check if folder/document is below rootDir can be turned on (default off) - SeedDMS_Core_User::setHomeFolder() can be used to unset the home folder +- check if attribute definition exists when setting attributes of folders and documents