Our client reported an error when attempting to export ~13K rows to Excel; they've reported similar in the past on other sites with up to as many as +70K rows. All of their sites are running with 128M of PHP memory...in the error logs, I'm seeing this when re-creating the issue: "[07-Nov-2013 09:45:13] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in docroot/sites/all/modules/contrib/webform/includes/webform.submissions.inc on line 689"
Digging in to the webform_results_export() function a bit, it occurred to me that we could patch and temporarily uncap PHP's memory limit specifically for these exports...the patch worked for our 7.x-3.19 version. Reviewing the 7.x-4.x branch, it looks like the same issue will probably occur there.
I believe @gnosis has been in touch with the Webform maintainers in the past about potentially introducing the Batch API to these export functions as well; I agree that approach is likely best long-term...these patches are really just a bridge fix until that's all been worked through.
Attaching these simple patches for review...maybe they'll help others work around similar limitations.
7.x-3.x patch: export-out-of-memory-2130101-1.patch
7.x-4.x patch: export-out-of-memory-2130101-2.patch
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | export-out-of-memory-2130101-2.patch | 595 bytes | natemow |
| #1 | export-out-of-memory-2130101-1.patch | 568 bytes | natemow |
Comments
Comment #1
natemow commentedComment #2
quicksketchIn Webform 4.x, we already batch exported data so you shouldn't run out of memory when exporting any number of submissions. For 3.x, I would recommend disabling the PHP limit on your site via a custom module. Disabling the memory limit as an out-of-box setting could result in users of Webform overwhelming their hosting providers.