Skip to content

Commit

Permalink
Merge pull request #100 from lmaucoin/master
Browse files Browse the repository at this point in the history
New redirects always save with highest ID site
  • Loading branch information
johanzandstra committed Oct 7, 2019
2 parents 2b73c09 + 8ffafa9 commit 0693184
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 9 additions & 0 deletions src/controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,15 @@ public function actionSaveRedirect()

return null;
} else {
// remove form other sites
Craft::$app->getDb()->createCommand()
->delete('{{%elements_sites}}', [
'AND',
['elementId' => $redirect->id],
['!=', 'siteId', $siteId]
])
->execute();

if ($request->getAcceptsJson()) {
return $this->asJson([
'success' => true,
Expand Down
8 changes: 0 additions & 8 deletions src/elements/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,6 @@ public function afterSave(bool $isNew)

$record->save(false);

// remove form other sites
Craft::$app->getDb()->createCommand()
->delete('{{%elements_sites}}', [
'AND',
['elementId' => $record->id],
['!=', 'siteId', $this->siteId]
])
->execute();
parent::afterSave($isNew);
}

Expand Down

0 comments on commit 0693184

Please sign in to comment.