New redirects always save with highest ID site #100
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, love the plugin! However, I recently upgraded to Craft 3.2.7 and have found that redirects are no longer saving on the correct sites.
I did some sleuthing and found that though the
$propagate
parameter is set to false when saving the redirect, this only stops it from being saved to all sites if the record exists (see Arguments here).To get around this, in the
afterSave
callback, all element records created for sites that aren't the relevant one are deleted. Unfortunately, this is run every time a record is saved (and it always gets saved for all sites when a new record is created), meaning that the only lingering redirect record is one on the highest site ID.This PR shifts the record deletion to occur in the Controller's action for saving instead of in a post-save callback, so it's only executed for the record on the relevant site.