Problem/Motivation
Setting Webform's settings export.temp_directory to e.g. private://webform-exports causes exports to fail. Using a private:// uri is a workaround for infra setups with multiple backend servers that don't have session persistence/sticky sessions. Batched exports will fail randomly in such infra setups since /tmp is not sync'ed among servers (public://, private:// must be sync'ed).
Taking a closer look at phpoffice/phpspreadsheet, it looks like it's not compatible with Drupal stream wrappers: https://github.com/PHPOffice/PhpSpreadsheet/issues/2907
Steps to reproduce
- Configure Webform exporter temp directory to private://webform-exports (/admin/structure/webform/config/exporters)
- Visit the results -> download page for a webform, choose "XLSX" as download format and click on "Download"
- The export fails.
- Visit the error log, an error is logged with message "PhpOffice\PhpSpreadsheet\Reader\Exception: Unable to identify a reader for this file in PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile() (line 172 of /path/to/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php)."
Proposed resolution
Add some glue code to transparently resolve uris for local files into a normal file path. Ignore remote URIs for now (which should trigger the exception).
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3391722-webform_xlsx_export-stream-wrappers-support-2.patch | 2.31 KB | jedihe |
Comments
Comment #2
jedihe commentedAttached patch is working fine for some quick tests I ran.
Comment #3
jedihe commentedComment #4
jedihe commentedComment #6
prudloff commentedThanks for the patch!