Problem/Motivation

We avoid serializing the database connection, if it is serialized we throw an exception.
If you're building a form that needs a database queue instance, you cannot inject it as it will result in 'The database connection is not serializable' as the queue doesn't manage the connection reference on sleep/wakeup.

Proposed resolution

Make Queue use DependencySerializationTrait

Remaining tasks

Review

User interface changes

None

API changes

None

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug because injection throws Exception
Issue priority Normal
Disruption None
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

larowlan’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, queue-injection.patch, failed testing.

larowlan’s picture

Status: Needs work » Needs review
FileSize
624 bytes

meh

larowlan’s picture

larowlan’s picture

larowlan’s picture

Issue summary: View changes

The last submitted patch, 5: queue-serialize-boom-2481729.fail_.patch, failed testing.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

nice

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/system/src/Tests/Queue/QueueSerializationTest.php
@@ -0,0 +1,108 @@
+use Drupal\Core\DependencyInjection\DependencySerializationTrait;
...
+class QueueSerializationTest extends KernelTestBase implements FormInterface {
+
+  use DependencySerializationTrait;

Why does this class need this trait?

larowlan’s picture

Status: Needs work » Reviewed & tested by the community

Because it's a form as well as a test, but it doesn't extend from FormBase

larowlan’s picture

To extrapolate - the intent of the test is to check form serializing, but because the form is also a test, it gets a $this->container property, which can't be serialized, so we add that trait to get past that.

larowlan’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
523 bytes
3.45 KB
3.45 KB

demonstrating reason for the trait
interdiff is between these two patches

Status: Needs review » Needs work

The last submitted patch, 12: queue-serialize-boom-2481729.pass_.patch, failed testing.

Status: Needs work » Needs review

The last submitted patch, 12: queue-serialize-boom-2481729.fail_.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 12: queue-serialize-boom-2481729.pass_.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 12: queue-serialize-boom-2481729.pass_.patch, failed testing.

larowlan’s picture

Status: Needs work » Needs review
FileSize
3.45 KB

no idea

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

Same file passes, back to rtbc

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 843670c and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation to the issue summary.

  • alexpott committed 843670c on 8.0.x
    Issue #2481729 by larowlan: Cannot inject DatabaseQueue instances into...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.