Patch #15277

Accept custom field format added at runtime

Added by Boris Bera about 4 years ago. Updated about 4 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Custom fields
Target version:2.4.0

Description

The CustomField model has a validation for the field_format attribute. This validation makes sure that the given field_format is part of the list of registered field formats.

There's a bug in the validation. The list the field format is checked against doesn't get updated when a new field format is added. This is probably because rails caches the list instead of accessing the reference and getting the updated version every time.

This becomes a problem for plugin developers. When a plugin registers a field format, all the custom fields using their formats will be invalid. Strangely enough, this doesn't seem to always happen. The same plugin running on the same version of redmine (2.3.3) on two different machines doesn't always have this bug. One version running on a mac in the development environment doesn't have this problem while another running on debian 7 in the production environment does have this problem.

This patch fixes the problem by wrapping the array of valid formats in a proc so that the updated version is used every time.

custom_field_format_validation_fix.patch Magnifier (2.08 KB) Boris Bera, 2013-11-06 17:27

Associated revisions

Revision 12248
Added by Jean-Philippe Lang about 4 years ago

Accept custom field format added at runtime (#15277).

Patch by Boris Bera.

History

#1 Updated by Jean-Philippe Lang about 4 years ago

  • Subject changed from Fixing validation problem with CustomField's field_format to Accept custom field format added at runtime
  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Target version set to 2.4.0

Patch committed in r12248 with slight change, thanks.

Also available in: Atom PDF