Reports: don't add query to developer tab if we are downloading the data
When running a report, if you choose an output format of pdf, print or csv (others?) the developer tab is not displayed, so adding queries to this tab is wasted CPU cycles.
It would not be such a big deal except I discovered that in some cases, it can cause CiviCRM to hang for a very long time. For example, if you run CRM_Report_Form_Contribute_Detail with more than 1,000 records and try to download as a CSV file, it will hang for more time than I have patience for.
The cause comes from https://github.com/civicrm/civicrm-core/pull/11898 (ping @eileen) - in which a few extra sql statements are helpfully added to the developers tab - but they are sql statements that are execute for each row in the results.
The addition of the sql statements to the developers tab is not a big deal under normal operations (since most reports limit to just 50 rows per page), however, when downloading via csv then all the rows are returned, so addToDeveloperTab gets called once for each row and that seems to gum up the works.
We could arguably remove any call to addToDevelopersTab that would operate on each row, but I think if we just add something like this to the addToDevelopersTab function it would be more flexible:
$ignored_output_modes = array('pdf', 'csv', 'print');
if (in_array($this->_outputMode, $ignored_output_modes)) {
return;
}
What do others think?