Commit 5510ced5ac8520dd63d7dcf00c00b3719d9270da

Authored by megan_w
1 parent 57db32c3

KTS-3924 - incremented the metadata version on updating the metadata.

"CLONE -Changing metadata via Edit Metadata (i.e. webbased) does not increase the metadata version (SUP-1008)"

Committed by: Megan Watson
Reviewed by: Donald Jackson



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/branches/RB_3.5.4a@9639 c91229c3-7414-0410-bfa2-8a42b809f60b
ktapi/KTAPIDocument.inc.php
@@ -1105,29 +1105,48 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1105,29 +1105,48 @@ class KTAPI_Document extends KTAPI_FolderItem
1105 */ 1105 */
1106 function update_metadata($metadata) 1106 function update_metadata($metadata)
1107 { 1107 {
1108 - global $default;  
1109 - if (empty($metadata))  
1110 - {  
1111 - return;  
1112 - }  
1113 -  
1114 - $packed = $this->get_packed_metadata($metadata);  
1115 -  
1116 - DBUtil::startTransaction();  
1117 - $result = KTDocumentUtil::saveMetadata($this->document, $packed, array('novalidate'=>true));  
1118 -  
1119 - if (is_null($result))  
1120 - {  
1121 - DBUtil::rollback();  
1122 - return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR . ': Null result returned but not expected.');  
1123 - }  
1124 - if (PEAR::isError($result))  
1125 - {  
1126 - DBUtil::rollback();  
1127 - return new KTAPI_Error('Unexpected validation failure', $result);  
1128 - }  
1129 - DBUtil::commit();  
1130 - 1108 + global $default;
  1109 + if (empty($metadata))
  1110 + {
  1111 + return;
  1112 + }
  1113 +
  1114 + $packed = $this->get_packed_metadata($metadata);
  1115 +
  1116 + DBUtil::startTransaction();
  1117 +
  1118 + $user = $this->ktapi->get_user();
  1119 + $this->document->setLastModifiedDate(getCurrentDateTime());
  1120 + $this->document->setModifiedUserId($user->getId());
  1121 +
  1122 + // Update the content version / document version
  1123 + if($default->updateContentVersion){
  1124 + $this->document->startNewContentVersion($user);
  1125 + $this->document->setMinorVersionNumber($this->document->getMinorVersionNumber()+1);
  1126 + }else {
  1127 + $this->document->startNewMetadataVersion($user);
  1128 + }
  1129 +
  1130 + $res = $this->document->update();
  1131 + if (PEAR::isError($res))
  1132 + {
  1133 + DBUtil::rollback();
  1134 + return new KTAPI_Error('Unexpected failure updating document', $res);
  1135 + }
  1136 +
  1137 + $result = KTDocumentUtil::saveMetadata($this->document, $packed, array('novalidate'=>true));
  1138 +
  1139 + if (is_null($result))
  1140 + {
  1141 + DBUtil::rollback();
  1142 + return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR . ': Null result returned but not expected.');
  1143 + }
  1144 + if (PEAR::isError($result))
  1145 + {
  1146 + DBUtil::rollback();
  1147 + return new KTAPI_Error('Unexpected validation failure', $result);
  1148 + }
  1149 + DBUtil::commit();
1131 1150
1132 $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); 1151 $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
1133 $aTriggers = $oKTTriggerRegistry->getTriggers('edit', 'postValidate'); 1152 $aTriggers = $oKTTriggerRegistry->getTriggers('edit', 'postValidate');
plugins/ktcore/document/edit.php
@@ -208,6 +208,8 @@ class KTDocumentEditAction extends KTDocumentAction { @@ -208,6 +208,8 @@ class KTDocumentEditAction extends KTDocumentAction {
208 if($default->updateContentVersion){ 208 if($default->updateContentVersion){
209 $this->oDocument->startNewContentVersion($this->oUser); 209 $this->oDocument->startNewContentVersion($this->oUser);
210 $this->oDocument->setMinorVersionNumber($this->oDocument->getMinorVersionNumber()+1); 210 $this->oDocument->setMinorVersionNumber($this->oDocument->getMinorVersionNumber()+1);
  211 + }else {
  212 + $this->oDocument->startNewMetadataVersion($this->oUser);
211 } 213 }
212 214
213 $res = $this->oDocument->update(); 215 $res = $this->oDocument->update();