Fixed saving PreorderHistory only once

This commit is contained in:
Frank Schubert
2024-07-17 16:26:46 +02:00
parent 1042a48620
commit 3e47c9a8d6

View File

@@ -38,14 +38,26 @@ class Preorder extends mfBaseModel {
$this->ordered_services = null;
$this->creator = null;
$this->editor = null;
$nesting_level = mfValuecache::singleton()->get("preorder-save-nesting-level-".$this->id);
if(!$nesting_level) {
$nesting_level = 1;
} else {
$nesting_level++;
}
mfValuecache::singleton()->set("preorder-save-nesting-level-".$this->id, $nesting_level);
if($nesting_level > 1) {
return true;
}
// prevent potential infinite loop
if($this->in_after_save) return true;
$this->in_after_save++;
//if($this->in_after_save) return true;
//$this->in_after_save++;
// update preorder OAID if it's different from the unit OAID
// but only if the unit OAID is of the same origin as the campaign
$old_oaid = $this->oaid;
$this->setOrCreateOaid();
if($this->oaid != $old_oaid) {
$this->save();
@@ -54,6 +66,7 @@ class Preorder extends mfBaseModel {
//TODO: history start
if($this->status_id != $this->_old_data->status_id) {
$this->createHistoryEntry();
$this->_old_data->status_id = $this->status_id;
}
// run triggers based on new status
@@ -62,8 +75,7 @@ class Preorder extends mfBaseModel {
$this->cascadeStatus();
// Cascade status changes down all active preorders with the same hausnummer
$this->cascadeStatusToPreorders();
$this->in_after_save--;
}
public function createHistoryEntry() {