Commit 789d7e189ab2dd5033c47dc0182608a92aec6aae

Authored by Megan Watson
1 parent 48998b69

Initialised packed metadata as an array. Checked that values are set to n/a befo…

…re setting them to an empty string.

Committed by: Megan Watson
ktapi/KTAPIDocument.inc.php
... ... @@ -1405,7 +1405,7 @@ class KTAPI_Document extends KTAPI_FolderItem
1405 1405 // if the 'blankvalue' argument was set to 1 (true) then do not use the current value;
1406 1406 // this prevents the 'n/a' values set for blank fields on get_metadata from being saved as such
1407 1407 // while allowing user entered values of 'n/a' to be saved
1408   - $value = $fieldinfo['blankvalue'] ? '' : $fieldinfo['value'];
  1408 + $value = ($fieldinfo['value'] == 'n/a' && $fieldinfo['blankvalue']) ? '' : $fieldinfo['value'];
1409 1409 }
1410 1410 elseif ($fieldinfo instanceof stdClass) // is_a($fieldinfo, 'stdClass'))
1411 1411 {
... ... @@ -2156,7 +2156,7 @@ class KTAPI_Document extends KTAPI_FolderItem
2156 2156 {
2157 2157 return $this->document->getContentVersionId();
2158 2158 }
2159   -
  2159 +
2160 2160 /**
2161 2161 * Gets the url which can be used to download the document.
2162 2162 *
... ... @@ -2622,7 +2622,7 @@ class KTAPI_Document extends KTAPI_FolderItem
2622 2622 if (KTPluginUtil::pluginIsActive('brad.UserHistory.plugin')) {
2623 2623 $path = KTPluginUtil::getPluginPath('brad.UserHistory.plugin');
2624 2624 require_once($path . 'UserHistoryActions.php');
2625   -
  2625 +
2626 2626 $docAction = new UserHistoryDocumentAction($this->document, $this->ktapi->get_user());
2627 2627 $docAction->_show();
2628 2628 }
... ...
lib/documentmanagement/documentutil.inc.php
... ... @@ -641,6 +641,7 @@ $sourceDocument->getName(),
641 641 $aSimpleMetadata[$oField->getId()] = $sValue;
642 642 }
643 643  
  644 + $MDPack = array();
644 645 foreach ($aFieldsets as $oFieldset) {
645 646 $aFields =& $oFieldset->getFields();
646 647 $aFieldValues = array();
... ... @@ -694,6 +695,7 @@ $sourceDocument->getName(),
694 695 return $res;
695 696 }
696 697 // XXX: Metadata refactor
  698 + $aMetadata = (is_array($aMetadata)) ? $aMetadata : array();
697 699 foreach ($aMetadata as $aInfo) {
698 700 list($oMetadata, $sValue) = $aInfo;
699 701 if (is_null($oMetadata)) {
... ...