Implement life cycle for translated documents

Created on 11 September 2025, 28 days ago

Problem/Motivation

Document translation was implemented in Support translation of documents Active

Translated documents are created as a temporary file in the Drupal file system. This implementation is incomplete: a (private) temporary file can only be viewed by the owner. In a system were the original file is owned by another user, the translated file cannot be viewed by the user reviewing the translation job.

Steps to reproduce

  1. Add a node with a translatable file stored in the private file system as user #1
  2. Translate the file through Deepl as user #2
  3. Notice the translated file download returns 'Access denied'

Proposed resolution

Implement life cycle for translated documents:

  1. Register the translated document as a permanent file
  2. Register the translated document in file usage
  3. Implement hook_file_download and allow access when the file is part of a Job handled by tmgmt_deepl (and the user is allowed to view the job)
  4. Delete the file usage entry when the Job is deleted. The file will be cleaned up in cron if this was the last registered usage (if enabled, see https://www.drupal.org/node/2891902 )

Remaining tasks

  1. Write a merge request
  2. Review
  3. Commit

User interface changes

None

API changes

Translated documents are now permanent files

Data model changes

None

📌 Task
Status

Active

Version

2.3

Component

Code

Created by

🇳🇱Netherlands idebr

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024