Commit 225ca57d276d92b2d419d4cf2b84173f8212f455

Authored by Brad Shuttleworth
1 parent cc0a58fb

make ::changeWorkflowOnDocument match ::startWorkflowOnDocument in tolerance

by handling null input properly.



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5556 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/workflow/workflowutil.inc.php
@@ -120,9 +120,10 @@ class KTWorkflowUtil { @@ -120,9 +120,10 @@ class KTWorkflowUtil {
120 120
121 // fix for 1049: workflows reset on document move. 121 // fix for 1049: workflows reset on document move.
122 // this was the original purpose of "changeWorkflowOnDocument". 122 // this was the original purpose of "changeWorkflowOnDocument".
123 -  
124 - if ($oDocument->getWorkflowId() == $oWorkflow->getId()) {  
125 - return true; // bail out, essentially. 123 + if (!is_null($oWorkflow)) {
  124 + if ($oDocument->getWorkflowId() == $oWorkflow->getId()) {
  125 + return true; // bail out, essentially.
  126 + }
126 } 127 }
127 128
128 return KTWorkflowUtil::startWorkflowOnDocument($oWorkflow, $oDocument); 129 return KTWorkflowUtil::startWorkflowOnDocument($oWorkflow, $oDocument);
@@ -156,12 +157,12 @@ class KTWorkflowUtil { @@ -156,12 +157,12 @@ class KTWorkflowUtil {
156 157
157 $oDocument->setWorkflowId($iWorkflowId); 158 $oDocument->setWorkflowId($iWorkflowId);
158 $oDocument->setWorkflowStateId($iStartStateId); 159 $oDocument->setWorkflowStateId($iStartStateId);
159 -  
160 - $sTransactionComments = "Workflow \"" . $oWorkflow->getHumanName() . "\" started."; 160 + $sTransactionComments = "Workflow \"" . $oWorkflow->getHumanName() . "\" started.";
  161 +
161 } else { 162 } else {
162 $oDocument->setWorkflowId(null); 163 $oDocument->setWorkflowId(null);
163 $oDocument->setWorkflowStateId(null); 164 $oDocument->setWorkflowStateId(null);
164 - $sTransactionComments = "Workflow removed from document."; 165 + $sTransactionComments = "Workflow removed from document.";
165 } 166 }
166 167
167 $res = $oDocument->update(); 168 $res = $oDocument->update();