Mpdf tmp directory should be set to use the Drupal one

Created on 15 May 2025, 17 days ago

Problem/Motivation

On some hosting environment (like Platform.sh) the file system is read-only, which make mpdf file generation fail.

According to the documentation (https://github.com/mpdf/mpdf?tab=readme-ov-file#setup--configuration):

It is recommended to set one's own temporary directory via tempDir configuration variable. The directory must have write permissions (mode 775 is recommended) for users using mPDF (typically cli, webserver, fpm).

Warning: mPDF will clean up old temporary files in the temporary directory. Choose a path dedicated to mPDF only.

$mpdf = new \Mpdf\Mpdf(['tempDir' => __DIR__ . '/tmp']);

By default, the temporary directory will be inside vendor directory and will have write permissions from post_install composer script.

Steps to reproduce

- Enable media_thumbnails_word on a read-only file system hosting
- Upload a word file (it will fail upon saving)

Proposed resolution

Mpdf allows (and reccomends) to set a temporary folder. We should use the temporary folder setup for Drupal, since we know it's already set-up correctly

Remaining tasks

- [ ] check compatibility with other renderers

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇦🇺Australia elgandoz Canberra

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024