DEV: Improve add_to_serializer include_* options (#21220)

- Move the old '`define_include_method`' arg to a `respect_plugin_enabled` kwarg

- Introduce an `include_condition` kwarg which can be passed a lambda with inclusion logic. Lambda will be run via `instance_exec` in the context of the serializer instance

This is backwards compatible - old-style invocations will trigger a deprecation message
This commit is contained in:
David Taylor
2023-04-24 12:17:51 +01:00
committed by GitHub
parent aa5038a352
commit 26b7f8a63b
5 changed files with 115 additions and 54 deletions

View File

@ -975,7 +975,8 @@ module Discourse
digest = Digest::MD5.hexdigest(warning)
redis_key = "deprecate-notice-#{digest}"
if Rails.logger && !Discourse.redis.without_namespace.get(redis_key)
if Rails.logger && !GlobalSetting.skip_redis? &&
!Discourse.redis.without_namespace.get(redis_key)
Rails.logger.warn(warning)
begin
Discourse.redis.without_namespace.setex(redis_key, 3600, "x")