[Rt-commit] rt branch, 4.2/external-cf-category-performance, created. rt-4.2.3-23-g45ea908

Alex Vandiver alexmv at bestpractical.com
Wed Mar 5 20:57:06 EST 2014


The branch, 4.2/external-cf-category-performance has been created
        at  45ea9086a569d93f8693dde72dbbdcfc76f46763 (commit)

- Log -----------------------------------------------------------------
commit 45ea9086a569d93f8693dde72dbbdcfc76f46763
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Mar 5 20:51:57 2014 -0500

    Provide a default value for Category on External CFs
    
    If the hash passed to ->LoadFromHash does not contain a key for
    category, any code which later calls ->Category on the object will turn
    around and attempt to ask the database.  This is precisely what
    EditCustomFieldSelect does, of course.  For External CFs, this is both
    slow _and_ wrong -- it will always ask for CustomFieldValue id #1, and
    will do so repeatedly, for every external CF value provided.  This
    incurs a significant performance penalty on ticket creation and updates,
    as listing the full set of external values suddenly incurs hundreds of
    extraneous database queries.
    
    Ensure that a value for category exists for all external CFs, to save
    the erroneous trip to the database.

diff --git a/lib/RT/CustomFieldValues/External.pm b/lib/RT/CustomFieldValues/External.pm
index 52ca1a5..500a967 100644
--- a/lib/RT/CustomFieldValues/External.pm
+++ b/lib/RT/CustomFieldValues/External.pm
@@ -181,6 +181,7 @@ sub _DoSearch {
             customfield => $self->{'__external_cf'},
             sortorder => 0,
             description => '',
+            category => undef,
             creator => RT->SystemUser->id,
             created => undef,
             lastupdatedby => RT->SystemUser->id,

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


More information about the rt-commit mailing list