Given that there are several duplicates of the same issue, but none that stood out to cover all parts of the problem, I wanted to create this "Master Issue" that could be used to cover all parts of this optimization & configuration effort.
Many users have complained of problems exporting aka downloading the results/submissions from webforms, either as CSV/delimited files or as Excel spreadsheets with either error messages or more commonly just blank screens after several minutes waiting. Further, the watchdog log / dblog may not record any error messages.
There are two parts to this problem:
- memory limits building the output
- timeouts because it takes too long to finish building the output
Solving Problem 1: Memory Limits
Resolving memory limits may be as simple as adjusting the .htaccess file where it says:
# PHP 5, Apache 1 and 2.
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0
just add the following extra lines before the line:
# New settings:
php_value memory_limit 128M
Unfortunately some web hosts may limit your control over this and may not allow the memory_limit value be configured through a .htaccess file, in which case it may have to be modified in the system's primary php.ini file. The standard system requirements call for this to be 16M (i.e. 16 megabytes) but you may find a need for it to be 64M, 96M or even 128M depending on the number of records or fields in the webform.
Solving Problem 2: Timeout
The PHP configuration variable max_execution_time controls how long the PHP parser will allow a script to run before being forcibly terminated. By default this is set to 30 seconds, but depending on the number of records and fields this will probably not be sufficient. Similarly to the memory limit, this can be configured through the .htaccess file, as follows:
# New settings:
php_value max_execution_time 180 #seconds
Unfortunately, even this may not be sufficient as it may still take a very long time to complete.
The output generation is controlled by the webform_results_download() function in webform_report.inc which generates a delimited file in the desired format. Tracing through the file, the initial lines run rather quickly but the