ECA Processing Queued Task error
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3462442. -->
Reported by: [freelock](https://www.drupal.org/user/313537)
Related to !436
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>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.</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>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.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>This is a regression from Commit 776e9526, for <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/eca/-/work_items/3375167" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/eca/-/work_items/3375167</a></span>. That commit added dependency injection to inject the time service, instead of calling it using the non-DI \Drupal::time() call.</p>
<p>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.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>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.</p>
issue