Patch #15277
closedAccept custom field format added at runtime
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.
Files