From 8468a05b87931d716bcc8c8cd381742de9fe2770 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com> Date: Sun, 16 May 2021 23:28:54 -0400 Subject: [PATCH] Unset tags relation after setting (#131) This ensures that the proper tag values are returned to the API by clearing any cached tags before returning a response. It also makes sure that the listeners to the `DiscussionWasTagged` event won't have old data under `$event->discussion->tags`. Fixes https://github.com/flarum/core/issues/2514 --- extensions/tags/src/Listener/SaveTagsToDatabase.php | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/tags/src/Listener/SaveTagsToDatabase.php b/extensions/tags/src/Listener/SaveTagsToDatabase.php index f63b690a8..c6d04c4c5 100755 --- a/extensions/tags/src/Listener/SaveTagsToDatabase.php +++ b/extensions/tags/src/Listener/SaveTagsToDatabase.php @@ -118,6 +118,7 @@ class SaveTagsToDatabase $discussion->afterSave(function ($discussion) use ($newTagIds) { $discussion->tags()->sync($newTagIds); + $discussion->unsetRelation('tags'); }); } }