Field field mapper: provide support for fseek on external files.

Created on 4 September 2025, 27 days ago

Problem/Motivation

In some cases, the Drupal sub-system needs to access a remote file using fseek() (XnttStream::stream_seek()). This works well on local files but not on remote file served through HTTP, leading to a hidden fseek(): Stream does not support seeking error.

Steps to reproduce

With some JPEG files which contain their image size beyond the first block of data read, the GD toolkit needs to do a (second) fseek() to get the info, leading to an error that is not displayed and resulting in a remote image not loaded. Therefor, an image style cannot be applied.

Note: some JPEG image will work just fine if the size is available from the first block read.

Proposed resolution

In XnttStream::stream_seek(), check if we got a remote file and a failure when calling fseek(). When it happens, download the whole file in memory and emulate fseek behavior (other methods may need to be adjusted such as fread, feof, ...). Also, an admin setting should be added somewhere to manage the maximum size allowed for files to be downloaded that way.

Remaining tasks

Implement and test.

User interface changes

An admin setting somewhere to manage the maximum size of downloadable files and maybe also add restrictions on the file extensions, streams (http/ftp? has ftp also the fseek problem? need to check). Also allow extensions to override that interface/limits to provide a better UI or alter limits.

API changes

None. The XNTT stream wrapper remains the same.

Feature request
Status

Postponed

Version

3.0

Component

Code

Created by

🇫🇷France guignonv Montpellier

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

Comments & Activities

Production build 0.71.5 2024