FIX: Ruby 2 backward compatible plugin logout redirect (#19845)

This is a very subtle one. Setting the redirect URL is done by passing
a hash through a Discourse event. This is broken on Ruby 2 since the
support for keyword arguments in events was added.

In Ruby 2 the last argument is cast to keyword arguments if it is a
hash. The key point here is that creates a new copy of the hash, so
what the plugin is modifying is not the hash that was passed.
This commit is contained in:
Ted Johansson
2023-01-12 19:12:20 +08:00
committed by GitHub
parent 4093fc6074
commit 5dcb245eac
2 changed files with 4 additions and 1 deletions

View File

@ -12,6 +12,9 @@ module Discourse
class Utils
URI_REGEXP ||= URI.regexp(%w[http https])
# TODO: Remove this once we drop support for Ruby 2.
EMPTY_KEYWORDS ||= {}
# Usage:
# Discourse::Utils.execute_command("pwd", chdir: 'mydirectory')
# or with a block