Edgewall Software

Ticket #4061 (closed defect: fixed)

Opened 2 years ago

Last modified 2 months ago

existing tickets should get the default value if value is not set in ticket

Reported by: GreenZero Owned by: rblank
Priority: normal Milestone: 0.11.2
Component: ticket system Version: 0.10
Severity: major Keywords: ticket modify severity default custom field verify patch
Cc: oliver@…, p.phaneuf@…

Description

actual situation:

  • creating a new ticket, severity will be set to the configured default severity
  • existing tickets with no severity set will get the first severity in configured order on modify after creating severities


required situation:

  • creating a new ticket, severity will be set to the configured default severity (already implemented = OK)
  • modify an existing ticket will set severity to configured default severity, too


this occurs after using trac in project where no severity was used at the begining. Later on severity was filled. Modifiing existing tickets causes them to be automatically set to highest priority if user did not pay attention to that ticket field and set it manually. It would be very nice, if you could fix this.

Attachments

4061-standard-fields-default-r7502.patch (0.5 KB) - added by rblank 3 months ago.
Patch against 0.11-stable avoiding to set unset standard fields to an empty string
4061-standard-fields-default-r7554.patch (0.5 KB) - added by rblank 2 months ago.
Updated patch for current 0.11-stable

Change History

  Changed 2 years ago by anonymous

After we tried a workaround with custom fields we found out, that the custom fields have the same behaviour. The default value of such a custom field is not respected if you try to modify an already existing ticket.

  Changed 2 years ago by anonymous

  • keywords custom added

  Changed 2 years ago by anonymous

  • keywords field added

  Changed 2 years ago by anonymous

  • cc oliver@… added

  Changed 2 years ago by eblot

  • milestone 0.10.1 deleted

  Changed 2 years ago by GreenZero

  • summary changed from existing tickets should get the default severity if severity is not set in ticket to existing tickets should get the default value in custom fields if value is not set in ticket

summary changed because it is more related to custom fields than only to severity (severity is just a custom field)

  Changed 2 years ago by anonymous

  • milestone set to 0.10.3

  Changed 15 months ago by Pierre Phaneuf <pphaneuf@…>

  • cc p.phaneuf@… added
  • summary changed from existing tickets should get the default value in custom fields if value is not set in ticket to existing tickets should get the default value if value is not set in ticket

It's not just on custom fields, actually, but on built-in fields that can be hidden (like severity or component). We just transitioned from not using the "component" field (so we had a bunch of tickets with a "null" component), and when we added components, we picked one as the default. On new tickets, this was working correctly, but when an ticket (that didn't have a component) was brought up, the component field would default to the first component in alphabetical order, rather than the default component.

So we had a bunch of tickets inadvertantly changed to a (most of the time) non-sensical component by people who just added a comment quickly.

The proper fix would be for the ticket display code to use the default component if it is not set, instead of letting the browser pick the first one (for the component field, of course, this could apply to other fields).

  Changed 7 months ago by cboos

  • keywords verify added
  • owner changed from jonas to cboos
  • milestone changed from 0.10.5 to 0.11.1

See also #7200.

The current behavior (0.11-stable) must be checked.

  Changed 3 months ago by rblank

This behavior has been fixed for custom fields in #7465. But as far as I can tell, that fix should also correct the problem for built-in fields. Let me quickly check...

Changed 3 months ago by rblank

Patch against 0.11-stable avoiding to set unset standard fields to an empty string

  Changed 3 months ago by rblank

  • keywords patch added
  • owner changed from cboos to rblank

...not quite. Unset standard fields are set to the empty string on retrieval in Ticket._fetch_ticket(). The patch above fixes the problem for me with no ill effects (meaning, queries and ticket viewing and editing work, and the test suite passes).

Changed 2 months ago by rblank

Updated patch for current 0.11-stable

  Changed 2 months ago by rblank

I'm still looking for a volunteer to review this. Any takers?

  Changed 2 months ago by cboos

I'll test it.

follow-up: ↓ 15   Changed 2 months ago by cboos

I had to verify this because I was a bit confused about how this change could work.

Looks like that when we set it to '', the

 value = ticket.get_value_or_default(field.name)

in the template will get '' (instead of the default when we don't set the field, like your patch does).

Then when filling the option list, in the first case no actual entry will match '', so the first one will be chosen, whereas in the second case, the appropriate default will be chosen.

Now while I'm at it, I see that the get_value_or_default is a bit heavy handed (try...except), maybe we could do a simple if name in self.values: ... instead.

in reply to: ↑ 14 ; follow-up: ↓ 17   Changed 2 months ago by rblank

Thanks for the review.

Replying to cboos:

Then when filling the option list, in the first case no actual entry will match '', so the first one will be chosen, whereas in the second case, the appropriate default will be chosen.

Correct. So... would you say that this is the right way to fix this issue?

Now while I'm at it, I see that the get_value_or_default is a bit heavy handed (try...except), maybe we could do a simple if name in self.values: ... instead.

There are two schools about this. Some people say "better ask for forgiveness than for permission" and they do it the try: except: way, and others do an in check before accessing the item. The argument for the former is that a try: except: block has almost no runtime overhead in the normal case (no exception), whereas an if ... in ... and accessing the item requires two lookups.

In this case, the difference is probably negligible, so if the latter is the preferred coding style in Trac, I'll change it.

  Changed 2 months ago by rblank

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from 0.11.3 to 0.11.2

Patch applied in [7570].

in reply to: ↑ 15   Changed 2 months ago by cboos

Replying to rblank:

Correct. So... would you say that this is the right way to fix this issue?

Yes, indeed. I was not clear about this, sorry.

Add/Change #4061 (existing tickets should get the default value if value is not set in ticket)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from rblank. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.