From 1b1eb77fffd62d613267b4e58b6bb787bc573c36 Mon Sep 17 00:00:00 2001 From: October CMS Date: Tue, 8 Aug 2023 14:03:41 +1000 Subject: [PATCH] Perform propagation after deferred binding --- src/Database/Model.php | 3 +++ src/Database/Traits/Multisite.php | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Database/Model.php b/src/Database/Model.php index 4ac79ef1d..9ad899b18 100644 --- a/src/Database/Model.php +++ b/src/Database/Model.php @@ -421,6 +421,9 @@ protected function saveInternal($options = []) $this->commitDeferredAfter($this->sessionKey); } + // After save deferred binding + $this->fireEvent('model.saveComplete'); + return $result; } diff --git a/src/Database/Traits/Multisite.php b/src/Database/Traits/Multisite.php index 6104387d4..7efda2c89 100644 --- a/src/Database/Traits/Multisite.php +++ b/src/Database/Traits/Multisite.php @@ -50,13 +50,13 @@ public function initializeMultisite() $this->bindEvent('model.afterCreate', [$this, 'multisiteAfterCreate']); // Process propagation last so relations are all set up correctly - $this->bindEvent('model.afterSave', [$this, 'multisiteAfterSave'], -1); + $this->bindEvent('model.saveComplete', [$this, 'multisiteSaveComplete'], -1); $this->defineMultisiteRelations(); } /** - * multisiteBeforeSave constructor event + * multisiteBeforeSave constructor event used internally */ public function multisiteBeforeSave() { @@ -68,9 +68,9 @@ public function multisiteBeforeSave() } /** - * multisiteAfterSave constructor event + * multisiteSaveComplete constructor event used internally */ - public function multisiteAfterSave() + public function multisiteSaveComplete() { if ($this->getSaveOption('propagate') !== true) { return; @@ -102,7 +102,7 @@ public function multisiteAfterSave() } /** - * multisiteAfterCreate constructor event + * multisiteAfterCreate constructor event used internally */ public function multisiteAfterCreate() {