webform_results_export_batch() includes this comment for the $options parameter:
* (optional) An associative array of options that define the output format.
* These are generally passed through from the GUI interface. Possible options
* include:
* - sids: An array of submission IDs to which this export may be filtered.
* May be used to generate exports that are per-user or other groups of
* submissions.
However, webform_results_batch_rows() does not actually support the 'sids' option. It calls webform_download_sids_query() to generate a query, applies only the range options, joins the users table, and then passes the query to webform_get_submissions_load().
I am implementing a webform export form which calls webform_results_export_batch() and provides a pre-filtered set of sids however, I always get all results.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | webform_filter_by_sids-2764465.patch | 609 bytes | jroberts |
Comments
Comment #2
jroberts commentedHere is a patch for the above issue which allows exports generated by webform_results_export_batch() to use $options['sids'] filtering. This brings the behavior of webform_results_export_batch() in line with webform_results_download_rows() and its own documentation.
Comment #3
danchadwick commentedNeeds review by community.
Comment #4
liam morland@jayroberts Thanks for the patch. Can you write a test for this functionality?
Comment #5
jroberts commented@Liam I spent some time looking into it but creating a test for this specific case is non-trivial.
First we'd need to add test/report.test to Webform with a test case like testWebformReportExportBatchSids(). Then we'd set up test data with testWebformForm() and a few calls to testWebformPost() and drupalPost(). So far so good.
However, at this point we'd need to call webform_results_export_batch() with the sids options specified but you can't invoke a batch operation while Simpletest itself is running.
Unfortunately the querying behavior in webform_results_batch_rows() is coupled tightly with the file output and batching behavior so it's difficult to test them in isolation.
We'd need to implement a module which provides menu hooks that invoke the batch process for simpletest to call (See simpletests/tests/batch_test.module). I'd want some input from a module maintainer before going ahead and writing all of that infrastructure.
Comment #7
liam morlandThanks. Yes, I see the difficulty in having tests for this when there is not already tests for that function.