[Rt-commit] rt branch, 4.4/rest-reduce-txn-loop, created. rt-4.4.4-86-g6cf274f5b

? sunnavy sunnavy at bestpractical.com
Tue Feb 18 10:14:48 EST 2020


The branch, 4.4/rest-reduce-txn-loop has been created
        at  6cf274f5bc5b38db59f9c55c2482efd1c32effe5 (commit)

- Log -----------------------------------------------------------------
commit 6cf274f5bc5b38db59f9c55c2482efd1c32effe5
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Feb 18 22:17:48 2020 +0800

    Check txn's fields for its relationship with ticket
    
    Previously we did the check by iterating ticket's txns, which was slow
    and could result in performance issues.

diff --git a/share/html/REST/1.0/Forms/ticket/history b/share/html/REST/1.0/Forms/ticket/history
index 536d8b0d3..63d4a5f8c 100644
--- a/share/html/REST/1.0/Forms/ticket/history
+++ b/share/html/REST/1.0/Forms/ticket/history
@@ -101,17 +101,8 @@ if ($type) {
 if ($tid) {
     my @data;
     my $t = RT::Transaction->new($session{CurrentUser});
-
-    # this paragraph limits the transaction ID query to transactions on this ticket. 
-    # Otherwise you can query any transaction from any ticket, which makes no sense.
-    my $Transactions = $ticket->Transactions;
-    my $tok=0;
-    while (my $T = $Transactions->Next()) {
-        $tok=1 if ($T->Id == $tid)
-    }
-    if ($tok) {
-        $t->Load($tid);
-    } else {
+    $t->Load($tid);
+    if ( $t->ObjectType ne 'RT::Ticket' || $t->Object->Id != $ticket->id ) {
         return [ "# Transaction $tid is not related to Ticket $id", [], {}, 1 ];
     }
 

-----------------------------------------------------------------------


More information about the rt-commit mailing list