Skip to content

Commit

Permalink
Fixes multisite propagating to sites outside group
Browse files Browse the repository at this point in the history
  • Loading branch information
daftspunk committed May 10, 2024
1 parent ccb93de commit 098a219
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Database/Traits/Multisite.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,20 @@ public function multisiteSaveComplete()

Site::withGlobalContext(function() {
$otherModels = $this->newOtherSiteQuery()->get();
$otherSites = $otherModels->pluck('site_id')->all();
$otherSites = $this->getMultisiteSyncSites();

// Propagate attributes to known records
if ($this->propagatable) {
foreach ($otherModels as $model) {
$this->propagateToSite($model->site_id, $model);
foreach ($otherSites as $siteId) {
if ($model = $otherModels->where('site_id', $siteId)->first()) {
$this->propagateToSite($siteId, $model);
}
}
}

// Sync non-existent records
if ($this->isMultisiteSyncEnabled()) {
$missingSites = array_diff($this->getMultisiteSyncSites(), $otherSites);
$missingSites = array_diff($otherSites, $otherModels->pluck('site_id')->all());
foreach ($missingSites as $missingSite) {
$this->propagateToSite($missingSite);
}
Expand Down

0 comments on commit 098a219

Please sign in to comment.