Fixed bug which prevented Preorder::afterSave() from running

This commit is contained in:
Frank Schubert
2023-09-28 11:44:50 +02:00
parent 0aa6ad8186
commit d0bcb9a369
+4 -1
View File
@@ -20,7 +20,8 @@ class Preorder extends mfBaseModel {
} }
public function afterSave() { public function afterSave() {
if(!$this->in_after_save) return true; // prevent potential infinite loop
if($this->in_after_save) return true;
$this->in_after_save = true; $this->in_after_save = true;
// update preorder OAID if it's different from the unit OAID // 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 // but only if the unit OAID is of the same origin as the campaign
@@ -34,6 +35,7 @@ class Preorder extends mfBaseModel {
public function setOrCreateOaid($oaid_attributes = false) { public function setOrCreateOaid($oaid_attributes = false) {
$campaign = new Preordercampaign($this->preordercampaign_id); $campaign = new Preordercampaign($this->preordercampaign_id);
//var_dump($campaign);exit;
if(!$campaign->id) { if(!$campaign->id) {
return false; return false;
} }
@@ -53,6 +55,7 @@ class Preorder extends mfBaseModel {
} }
} elseif($campaign->oaid_origin == "ofaa") { } elseif($campaign->oaid_origin == "ofaa") {
$current_oaid = OpenAccessIdModel::getFirstOaid($this->oaid); $current_oaid = OpenAccessIdModel::getFirstOaid($this->oaid);
//var_dump($current_oaid);exit;
if(!$current_oaid) { if(!$current_oaid) {
$this->log->error("OAID of Preorder ".$this->id." not found in OpenAccessIds"); $this->log->error("OAID of Preorder ".$this->id." not found in OpenAccessIds");
// assume it's from a different origin // assume it's from a different origin