From aa9ab3d9a7f9aaf9b2cdbc59e6cc28479977782e Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 25 Mar 2016 17:29:18 -0500
Subject: [PATCH] export: Pre-fetch staff objects

This is required because using unbuffered MySQL queries means that no other
SQL queries can be run until the export is finished. Since the Staff model
will lazily query the config table, the queries need to be fetched in
advance.
---
 include/class.export.php | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/class.export.php b/include/class.export.php
index 485628aa3..d5d13a286 100644
--- a/include/class.export.php
+++ b/include/class.export.php
@@ -75,6 +75,11 @@ class Export {
                     ->aggregate(array('count' => SqlAggregate::COUNT('entries__id'))),
             ));
 
+        // Fetch staff information
+        // FIXME: Adjust Staff model so it doesn't do extra queries
+        foreach (Staff::objects() as $S)
+            $S->get('junk');
+
         return self::dumpQuery($tickets,
             array(
                 'number' =>         __('Ticket Number'),
-- 
GitLab