Fixes #7496: Perform an explict cast of ticket_id to a string to avoid a programming error on PostgreSQL, where strict type checking is done. Prevent possibility of SQL injection since ticket_id comes from the request.

Moving from class methods to functions and changing method/function signatures
has been done for trimming main class and finally removing class attributes,
that have been abused as variables before (there was even self.tickets!).

This is the bare minimum of changes, that don't break code, but turn Babel
into an undeclared, strict requirement so far. I'll fix that later.
Starting to remove class attribute variables for becoming thread-safe again.

Refs #10194: Implemented a fix for the IntegrityError when importing tickets with the TicketImportPlugin and not defining a changetime in the dataset (or in some cases of using the same changetime for multiple tickets).

The ticket id, time and field columns must be unique in the ticket_change table. Importing a set of tickets that are all assigned a changetime of "now" will result in an IntegrityError whenever two or more ticket share a relation with a single other ticket.

This feels like more of a workaround than a solution, but it will hopefully do for now.

Fixed "Slash in Milestone name prevents displaying dependency graph". The regex in match_request was improved, allowing the realm and id to be extracted from the request path, and the process_request function to be refactored to better utilize these request arguments.