[Rt-commit] rt branch, 4.2/transactions-cf-optimization, created. rt-4.2.0-32-g61a2dea

Alex Vandiver alexmv at bestpractical.com
Thu Oct 31 17:48:32 EDT 2013


The branch, 4.2/transactions-cf-optimization has been created
        at  61a2dea4940c90c8e39232046958dc0209cc42eb (commit)

- Log -----------------------------------------------------------------
commit 61a2dea4940c90c8e39232046958dc0209cc42eb
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Oct 31 16:58:18 2013 -0400

    Short-circuit looking for transaction CFs where they can never exist
    
    775f4bd replaced the ticket-specific ShowTransaction with a generalized
    one; however, it missed one notable difference between the two.  The
    general one checked every transaction for OCFVs, whereas the ticket
    transaction display, in 69a36d9, had replaced that with a limit to only
    "message" elements, and let ShowCustomFields further check for OCFs.
    This had the unintentional side effect of hiding the transaction CFs if
    the transaction had no CF values, but also added a notable performance
    regression.
    
    Remove the unindexed OCFV check per transaction, and short-circuit
    transaction CF display by checking once in ShowHistory if there are any
    OCFs applied at all.  Note that if there are OCFs, ShowCustomFields does
    its own check for OCFs once per transaction; this second check could
    theoretically be removed by passing $CustomFields from ShowHistory all
    of the way down into ShowCustomFields, but this would cause the existing
    MassageCustomFields callback to be called repeatedly on the same object,
    once per transaction.
    
    This does not add back the logic to limit CF display to transaction of
    type "message"; if transaction CFs were applied to non-tickets, such a
    change would hide them, as they had been displayed under the old
    /Elements/ShowTransaction.

diff --git a/share/html/Elements/ShowHistory b/share/html/Elements/ShowHistory
index 765a260..10c0e75 100644
--- a/share/html/Elements/ShowHistory
+++ b/share/html/Elements/ShowHistory
@@ -125,6 +125,7 @@ while ( my $Transaction = $Transactions->Next ) {
         RowNum            => $i,
         Attachments       => $trans_attachments->{$Transaction->id} || {},
         AttachmentContent => $trans_content,
+        HasTxnCFs         => $HasTxnCFs,
     );
 
     # manually flush the content buffer after each txn,
@@ -171,6 +172,8 @@ for my $attachment (@{$Attachments->ItemsArrayRef()}) {
 
 my $record_type = $Object->RecordType;
 my $histid      = "\L$record_type\E-" . $Object->id . "-history";
+
+my $HasTxnCFs = ($Object->can("TransactionCustomFields") and $Object->TransactionCustomFields->Count);
 </%INIT>
 <%ARGS>
 $Object
diff --git a/share/html/Elements/ShowTransaction b/share/html/Elements/ShowTransaction
index 98e1771..f7d8dfa 100644
--- a/share/html/Elements/ShowTransaction
+++ b/share/html/Elements/ShowTransaction
@@ -68,9 +68,7 @@
 
   <div class="content">
 <%PERL>
-if ( $Transaction->CustomFieldValues->Count ) {
-    $m->comp('/Elements/ShowCustomFields', Object => $Transaction );
-}
+$m->comp('/Elements/ShowCustomFields', Object => $Transaction ) if $HasTxnCFs;
 $m->comp(
     'ShowTransactionAttachments',
     %ARGS,
@@ -87,6 +85,7 @@ $Object => $Transaction->Object
 
 $Attachments => undef
 $AttachmentContent => undef
+$HasTxnCFs => 1
 
 $ShowBody => 1
 $ShowActions => 1

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


More information about the Rt-commit mailing list