Session is not set when generating PDFs using commands (eg queue workers)

Created on 10 August 2023, about 2 years ago

Problem/Motivation

When generating PDFs via browser - request and session are set and are not null.
When generating PDFs via command on server side (eg via drush command or queue worker - to prevent timeout on HUGE PDFs) - request and session are not set which results in "Session not set exception" and process fails to generated PDF.

Steps to reproduce

Run PDF generation without session (as a command).

Proposed resolution

Catch exception and create new session:

    // FILE: entity_print/src/Plugin/EntityPrint/PrintEngine/DomPdf.php @ line 310
    try {
      $session = $this->request->getSession();
    }
    catch (SessionNotFoundException $noSession) {
      $session = \Drupal::service('session_manager');
    }

Remaining tasks

create patch

User interface changes

none

API changes

none

Data model changes

none

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇦🇺Australia jannakha Brisbane!

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

Comments & Activities

Production build 0.71.5 2024