Accept custom field format added at runtime
|Assignee:||Jean-Philippe Lang||% Done:|
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.
#1 Updated by Jean-Philippe Lang almost 7 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.