Edgewall Software
Modify

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#9275 closed defect (fixed)

Whitespace normalization of milestone/component names breaks on upgrade

Reported by: andres@… Owned by: Andres Freund <andres@…>
Priority: normal Milestone: 0.12
Component: ticket system Version: 0.12dev
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

The whitespace normalization "fixes" for #7704 in r8399 unfortunately break upgrades.

If in an earlier version a milestone was saved with a name like 'foo bar' (i.e. two whitespaces) the search now normalizes the whitespace and doesnt find the milestone.

Thus *no* ticket can be edited anymore - I guess because the full list of milestones is built there, so even if only one such unnormalized component/milestone breaks all tickets.

8399     rblank         name = simplify_whitespace(name)
  1831     cmlenz         if name:
  1831     cmlenz             if not db:
  1831     cmlenz                 db = self.env.get_db_cnx()
  1831     cmlenz             cursor = db.cursor()
  1831     cmlenz             cursor.execute("SELECT value FROM enum WHERE type=%s AND name=%s",
  1831     cmlenz                            (self.type, name))

It doesnt seem to be a good idea to do the normalization uppon searching because that will fail with earlier created milestones. Whats the point anyway? Imho that should only be done while saving.

Attachments (1)

fix_trac_edgewall_9275.patch (1.1 KB ) - added by andres <andres@…> 15 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by andres <andres@…>, 15 years ago

If wanted I can writeup a patch removing all the normalization uppon retrieval - its a trivial one though, so I am not sure its worth it.

in reply to:  1 comment:2 by Remy Blank, 15 years ago

Milestone: 0.12
Owner: set to Remy Blank

Could you please describe the symptoms you get? "No ticket can be edited anymore" is not very precise. Do you get an error? Can you provide the backtrace? Can you provide a procedure to reproduce the issue?

Replying to andres <andres@…>:

If wanted I can writeup a patch removing all the normalization uppon retrieval - its a trivial one though, so I am not sure its worth it.

Yes, please do.

Assigning to 0.12 as this is a regression.

comment:3 by Remy Blank, 15 years ago

Just to clarify: I believe you are right that normalization should be done only when saving, and not when retrieving. But I am interested to know how this issue manifests itself on your installation.

comment:4 by andres <andres@…>, 15 years ago

No Backtraces. The error is the (not unobvious)

Error: Invalid milestone name

either when opening "admin/ticket/milestones/<something with two whitespaces>" or when editing a ticket when one of the possible milestones has two whitespaces. Its the exception from

       cursor = db.cursor()
        cursor.execute("""                                                                                           
            SELECT name,due,completed,description                                                                    
            FROM milestone WHERE name=%s                                                                             
            """, (name,))
        row = cursor.fetchone()
        if not row:
            raise ResourceNotFound(_('Milestone %(name)s does not exist.',
                                   name=name), _('Invalid milestone name'))

both of the time.

For reproduction just manually insert a record with two whitespaces (or use an older version, or one without the normalization to insert it).

by andres <andres@…>, 15 years ago

comment:5 by andres <andres@…>, 15 years ago

Btw, the "not unsurprisingly" shouldnt sound aggressive or whatnot :P

comment:6 by Remy Blank, 15 years ago

Thanks for the additional info. Your patch, while fixing the retrieval, unfortunately removes whitespace normalization altogether. The correct behavior, as you mentioned, is probably to normalize when creating a new milestone / component / …

comment:7 by andres <andres@…>, 15 years ago

Huh? insert() and update() do normalize again already?

comment:8 by Remy Blank, 15 years ago

Resolution: fixed
Status: newclosed

Sorry, my bad. I read the patch out of context.

You're absolutely right, we shouldn't normalize in the constructor at all, and my adding that in [8399] was a mistake, triggered by enums and components already having that normalization in the constructor.

Your patch was applied in [9585], thanks!

comment:9 by Remy Blank, 15 years ago

Owner: changed from Remy Blank to Andres Freund <andres@…>

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Andres Freund <andres@…>.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Andres Freund <andres@…> to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.