Edgewall Software

Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#12725 closed enhancement

Validate ticket comment changes — at Version 8

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.3.2
Component: ticket system Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
  • Ticket comment edits are validated. ITicketManipulators are called and [ticket] max_comment_size is enforced.
  • Added ticket warnings above the preview.
API Changes:
Internal Changes:

Description

Discussed in #12722.

_validate_ticket should probably be called because currently max_comment_size is not enforced for a comment edit: tags/trac-1.2/trac/ticket/web_ui.py#L1336. _validate_ticket calls ITicketManipulator, which would allow additional rules to be enforced for ticket comment changes.

ICommentManipulator (comment:2:ticket:12722) might provide a nicer interface, but I'm unsure if it's necessary.

As suggested in #12642 for ticket workflow warnings, and similar to what is discussed in #11269, the warnings should be rendered near the comment edit box.

Change History (12)

comment:2 by Peter Suter, 7 years ago

Some plugins (th:TracHoursPlugin, th:PullRequestsPlugin) implement ITicketManipulator mainly to manipulate / cause side-effects, not to validate. Will there still be a way for these plugins to avoid these side-effects on comment editing? (It looks like req.args.get('comment') might return None for comment editing, correct? That might conveniently keep them working as-is.)

comment:3 by Ryan J Ollos, 7 years ago

Yes, req.args.get('comment') returns None for comment editing. I haven't checked, but it probably return an empty string for a ticket property change with no comment.

A plugin could also detect a comment edit by checking for 'edited_comment' in req.args.

Last edited 7 years ago by Ryan J Ollos (previous) (diff)

comment:4 by Ryan J Ollos, 7 years ago

Milestone: 1.2.11.3.2

I'll target next-major-release since there is impact on plugins.

by Ryan J Ollos, 7 years ago

by Ryan J Ollos, 7 years ago

by Ryan J Ollos, 7 years ago

by Ryan J Ollos, 7 years ago

comment:5 by Ryan J Ollos, 7 years ago

Part of #11269 will also be addressed in this ticket. I chose to place the warnings directly above the preview so that it doesn't interfere with the ticket property changes box. Here is an example of the interference:

With warnings placed above the preview:

For consistency I added a warning above the New Ticket preview:

For consistency I moved the edit conflict warnings and added a warning box for the Ticket Change preview:

Last edited 7 years ago by Ryan J Ollos (previous) (diff)

comment:6 by Ryan J Ollos, 7 years ago

Proposed changes in log:rjollos.git:t12725_validate_comment.1. I will add test coverage before committing.

in reply to:  2 comment:7 by Ryan J Ollos, 7 years ago

Replying to Peter Suter:

Some plugins (th:TracHoursPlugin, th:PullRequestsPlugin) implement ITicketManipulator mainly to manipulate / cause side-effects, not to validate. Will there still be a way for these plugins to avoid these side-effects on comment editing? (It looks like req.args.get('comment') might return None for comment editing, correct? That might conveniently keep them working as-is.)

Documented in TracDev/PluginDevelopment/ExtensionPoints/trac.ticket.api.ITicketManipulator@7.

comment:8 by Ryan J Ollos, 7 years ago

Release Notes: modified (diff)
Status: assignedclosed

Committed to trunk in r15719.

Note: See TracTickets for help on using tickets.