ECA Processing Queued Task error

Created on 18 July 2024, about 2 months ago
Updated 21 August 2024, 17 days ago

Problem/Motivation

When processing a task from the queue, \Drupal\eca_queue\Task::isDueForProcessing() throws an exception, "Typed property Drupal\eca_queue\Task::$time must not be accessed before initialization". This makes queue processing fail.

Steps to reproduce

Create a model that uses the ECA processing queued task event. Use an "Add to queue" action to add something to the queue. Run cron.

Proposed resolution

This is a regression from Commit 776e9526, for πŸ“Œ PHPStand level 6 fixes Fixed . That commit added dependency injection to inject the time service, instead of calling it using the non-DI \Drupal::time() call.

The problem is, this task object is unserialized from the queue, and so its constructor is not called -- according to the docs for unserialize(), it explicitly skips the constructor.

Remaining tasks

We could implement an __unserialize() method to re-add the time service, but I'm thinking it's easier/cleaner to just revert to using \Drupal::time() -- I'm not aware of a standard way to do dependency injection on unserialized objects, so I would tend to go with the simpler solution rather than adding complexity here.

πŸ› Bug report
Status

Fixed

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States freelock Seattle

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