Active
Project:
Drupal core
Version:
main
Component:
migration system
Priority:
Normal
Category:
Plan
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 Jan 2021 at 01:30 UTC
Updated:
9 Nov 2023 at 14:22 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
quietone commentedAnother one. This one from \Drupal\Tests\migrate_drupal\Kernel\d7\FieldDiscoveryTest::testAddAllFieldProcessesAlters when there is an error in the source data, just change any line in the provider and you get this unhelpful message when the test fails.
PHPUnit\Framework\Exception: PHP Fatal error: Uncaught LogicException: The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution. in /var/www/html/core/lib/Drupal/Core/Database/Connection.php:1831Comment #3
matroskeenI started this funny debug session and would like to share in-between results so maybe it'll help someone else to find a proper fix.
If the test is failing with exception, then PHP is trying to serialize a stack trace, that contains functions, methods, classes that have already been executed.
One of these functions is recognized as Closure in the stack trace (see the screenshot). I'm not 100% sure yet, but I think this is the problem.

Comment #4
matroskeenThe following patch should help to get rid of the issue described in the IS.
However, the error is now strange:
I expected to see something like "Column td.foo not found".
As I see, it won't be possible to add a test, because the serialization happens when the test is already executed.
Although it's not usual to have
array_walk()insidearray_walk(), someone can write such piece of code again 🤷Comment #5
matroskeenComment #6
matroskeenThe case described in #2 gives me another error:
Fatal error: Uncaught AssertionError: The container was serialized. in /var/www/docroot/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php on line 152Those issues seem similar, but can be occurred because of different reasons. Do we want to keep them in a single issue or we should have a META task?
Comment #7
quietone commented@Matroskeen, Yes, a meta sounds good. These error are happening too often. Can you do that?
Comment #8
matroskeenSure! I decided to turn this one into meta and create a spin-off task for the first issue: #3197324: Exception trace cannot be serialized because of closure.
Comment #9
matroskeenComment #10
wim leersReplying to #3189064-22: Migration sql source plugins can not be serialised because of reference to the database connection here:
No, but I'm looking into caching
\Drupal\migrate\Plugin\Migrationobjects for performance reasons — that's how I ran into this.Comment #15
anybodyJust ran into this at #3360993: The migration tests are currently not running
Comment #17
pingwin4egI also encountered the "container was serialized" issue with a migration test in Style Switcher module with D 9.5.11, PHP 8.1, PHPUnits 8.5.31 (local) and 9.5.28 (DrupalCI):
When I switched PHP to 7.3 locally I saw the actual error:
The workaround was to call
$this->startCollectingMessages();before$this->executeMigrations(...).Comment #18
johnvRelating to another meta issue [33400483]