Export fails when destination is a stream wrapper URI

Created on 4 October 2023, about 1 year ago
Updated 10 June 2024, 5 months ago

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

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇨🇴Colombia jedihe

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024