- Issue created by @freelock
- Status changed to Needs review
8 months ago 4:41pm 18 July 2024 - Issue was unassigned.
- πΊπΈUnited States freelock Seattle
Note that this was introduced in the 2.x branch, does not affect 1.x.
- Status changed to Active
7 months ago 2:27pm 23 July 2024 - π©πͺGermany jurgenhaas Gottmadingen
I can't reproduce this issue. And I can't even find any documentation that would explain that the constructor is not called for unserialized objects. Can you please provide more details on how this can be reproduced?
In any event, using
\Drupal::something
would always create CI pipeline errors. We have to avoid that if we want clean code. So, if this is really an issue, there must be another way of resolving it. - πΊπΈUnited States freelock Seattle
See https://www.php.net/manual/en/function.unserialize.php - after recreating the object, the __wakeup or __unserialize method on the object is called, if one exists.
- π©πͺGermany jurgenhaas Gottmadingen
Yes, I saw that too, but that doesn't say that
__construct
isn't executed.Still, I can't reproduce the problem. I've created a model that adds a job to the queue. And it also contains a cron event for that job that prints a message. All that works without any error message. What can we do here? I'm really uncertain.
- π©πͺGermany mxh Offenburg
The
__construct
method never gets called when an object is being unserialized. The magic method
__wakeup
will be called for this particular case. Since it's about a missing service, using DependencySerializationTrait β withinDrupal\eca_queue\Task
may be the solution path. - Status changed to Needs review
7 months ago 4:33pm 24 July 2024 - π©πͺGermany jurgenhaas Gottmadingen
Ah, good one. Thanks @mxh for the hint. I've committed that to the dev branch 2.1.x, @freelock could you give that a try if this also works in your context?
- π©πͺGermany mxh Offenburg
I don't see the commit at the moment, am I missing something?
-
jurgenhaas β
committed 19601477 on 2.1.x
Issue #3462442 by freelock, jurgenhaas, mxh: ECA Processing Queued Task...
-
jurgenhaas β
committed 19601477 on 2.1.x
- π©πͺGermany jurgenhaas Gottmadingen
My bad, I've been in an issue fork when I committed that yesterday. Fixed now, it's ready for testing in the dev release.
- π©πͺGermany jurgenhaas Gottmadingen
jurgenhaas β changed the visibility of the branch 3462442-eca-processing-queued to hidden.
- π©πͺGermany jurgenhaas Gottmadingen
I still can't reproduce this on most Drupal sites, but we now had a customer site which suffered from the same issue. By applying the fix from #11 the error has gone away.
- Status changed to RTBC
7 months ago 11:52am 29 July 2024 -
jurgenhaas β
committed 2300750f on 2.0.x
Issue #3462442 by freelock, jurgenhaas, mxh: ECA Processing Queued Task...
-
jurgenhaas β
committed 2300750f on 2.0.x
- Status changed to Fixed
7 months ago 11:53am 29 July 2024 - πΊπ¦Ukraine andriy khomych
I can confirm that I have the same issue.
In my case it was decoupled Drupal site and 2 ECA was triggered:
- Entity insert
- Entity update
- And related queue processUpdating to 2.0.1 fixed an issue.
It was hard to find it on the site and even debug it, in my case it ended with the error:
Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed.
Automatically closed - issue fixed for 2 weeks with no activity.
- πΊπΈUnited States freelock Seattle
Ok this just bit me again... the fix does not fix my installation, at least not under PHP 8.1. The DependencySerializationTrait does not appear to be adding the Time service to the _serviceIds[] property of the serialized object, so it does not add it back to the rehydrated Task object.
This has led to thousands of unprocessed queue items...
Can we re-open this issue? The original MR did fix it on my installation -- reapplying that as a patch is fixing it for me. DependencySerializationTrait did not fix it. A simple __unserialize() or __wakeup() method that adds this back might also work -- although it loses any benefit of dependency injection (if a different class was injected in the first place).
- π©πͺGermany jurgenhaas Gottmadingen
@freelock this is really strange since it is working in so many places just fine. Instead of re-opening this issue, please open a new one and provide a model with which this can be reproduced. Then we can see, where this goes wrong and fix it the right way.