Modify

Opened 8 years ago

Closed 8 years ago

#13148 closed defect (fixed)

Handle custom fields without valid default value

Reported by: Miklos Molnar Owned by: Jon Ashley
Priority: normal Component: KeepInterfaceSimplePlugin
Severity: normal Keywords:
Cc: Trac Release:

Description

If you have a custom field without valid default value (in ex. start_date = time and start_date.value = ), the warden will return with error message ("No field named '%s' is defined"). I suggest that, for these fields we should return an empty string so it still can be used at comparisons in conditions. I have attached a patch for fixing the problem.

Attachments (1)

handle_custom_fields.diff (944 bytes) - added by Miklos Molnar 8 years ago.
Patch for improved custom field handling

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by Miklos Molnar

Attachment: handle_custom_fields.diff added

Patch for improved custom field handling

comment:1 Changed 8 years ago by Jon Ashley

Thank you for reporting this fault.

I tried to reproduce the issue and initially failed. I defined a custom field in trac.ini as follows:

[ticket-custom]
bug_test = text
bug_test.format = plain
bug_test.label = Bug Test
bug_test.options = 
bug_test.order = 7
bug_test.value = 

and a Warden rule to reject the field:

[kis_warden]
test for bug = bug_test == ''

but that simply triggers the Warden rejection as expected. The call to self.ticket.get_value_or_default('bug_test') returned an empty string.

However, when I changed

bug_test = text

to

bug_test = time

that triggered the fault you reported. The call to self.ticket.get_value_or_default('bug_test') returned None.

I wasn't even aware that there was a custom field type named 'time'! It doesn't show up as an option on my 'Manage Custom Fields' admin panel.

Further testing revealed that radio button fields suffer from the same problem - they start off undefined.

I will apply your patch, with a minor re-ordering so that the existing field list is only obtained when no value can be read from the field.

comment:2 Changed 8 years ago by Jon Ashley

In 16558:

In the Warden, return an empty string for fields that exist but have no value, such as a radio button with nothing selected.
re #13148

comment:3 Changed 8 years ago by Jon Ashley

Status: newaccepted

Believed fixed on trunk; will be fixed in the next release.

comment:4 Changed 8 years ago by Jon Ashley

Resolution: fixed
Status: acceptedclosed

Fixed in [16643].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jon Ashley.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.