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

  1. Configure Webform exporter temp directory to private://webform-exports (/admin/structure/webform/config/exporters)
  2. Visit the results -> download page for a webform, choose "XLSX" as download format and click on "Download"
  3. The export fails.
  4. 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

Comments

jedihe created an issue. See original summary.

jedihe’s picture

Attached patch is working fine for some quick tests I ran.

jedihe’s picture

Issue summary: View changes
jedihe’s picture

Issue summary: View changes

  • prudloff committed 9a471cb0 on 8.x-1.x
    Issue #3391722 by jedihe: Export fails when destination is a stream...
prudloff’s picture

Status: Active » Fixed

Thanks for the patch!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.