From 72258266aa4556557262bb517918ba2194bd7edb Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Thu, 6 Sep 2018 22:41:19 +0100 Subject: MM-11649: Fix caching issue in channel API endpoints. (#9345) This fixes an issue where the cached Channel objects would contain data from a failed update when the update to the database failed. --- api4/channel.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'api4') diff --git a/api4/channel.go b/api4/channel.go index 1599b6e70..d497c9793 100644 --- a/api4/channel.go +++ b/api4/channel.go @@ -97,10 +97,11 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) { } var oldChannel *model.Channel - var err *model.AppError - if oldChannel, err = c.App.GetChannel(channel.Id); err != nil { + if originalOldChannel, err := c.App.GetChannel(channel.Id); err != nil { c.Err = err return + } else { + oldChannel = originalOldChannel.DeepCopy() } switch oldChannel.Type { @@ -229,10 +230,12 @@ func patchChannel(c *Context, w http.ResponseWriter, r *http.Request) { return } - oldChannel, err := c.App.GetChannel(c.Params.ChannelId) - if err != nil { + var oldChannel *model.Channel + if originalOldChannel, err := c.App.GetChannel(c.Params.ChannelId); err != nil { c.Err = err return + } else { + oldChannel = originalOldChannel.DeepCopy() } switch oldChannel.Type { -- cgit v1.2.3-1-g7c22