diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py index 5ad20d49d..3108fe49b 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py @@ -874,18 +874,24 @@ class ProcessInstanceProcessor: else: process_instance_data_dict[bpmn_key] = bpmn_dict[bpmn_key] - if self.process_instance_model.serialized_bpmn_definition_id is None: - new_hash_digest = sha256( - json.dumps(bpmn_spec_dict, sort_keys=True).encode("utf8") - ).hexdigest() - serialized_bpmn_definition = SerializedBpmnDefinitionModel.query.filter_by( - hash=new_hash_digest - ).first() - if serialized_bpmn_definition is None: - serialized_bpmn_definition = SerializedBpmnDefinitionModel( - hash=new_hash_digest, static_json=json.dumps(bpmn_spec_dict) - ) - db.session.add(serialized_bpmn_definition) + # FIXME: always save new hash until we get updated Spiff without loopresettask + # if self.process_instance_model.serialized_bpmn_definition_id is None: + new_hash_digest = sha256( + json.dumps(bpmn_spec_dict, sort_keys=True).encode("utf8") + ).hexdigest() + serialized_bpmn_definition = SerializedBpmnDefinitionModel.query.filter_by( + hash=new_hash_digest + ).first() + if serialized_bpmn_definition is None: + serialized_bpmn_definition = SerializedBpmnDefinitionModel( + hash=new_hash_digest, static_json=json.dumps(bpmn_spec_dict) + ) + db.session.add(serialized_bpmn_definition) + if ( + self.process_instance_model.serialized_bpmn_definition_id is None + or self.process_instance_model.serialized_bpmn_definition.hash + != new_hash_digest + ): self.process_instance_model.serialized_bpmn_definition = ( serialized_bpmn_definition ) @@ -1299,6 +1305,8 @@ class ProcessInstanceProcessor: return ProcessInstanceStatus.complete user_tasks = bpmn_process_instance.get_ready_user_tasks() + # workflow.waiting_events (includes timers, and timers have a when firing property) + # if the process instance has status "waiting" it will get picked up # by background processing. when that happens it can potentially overwrite # human tasks which is bad because we cache them with the previous id's.