Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.
Problem/Motivation
Trash module cannot be installed at the same time as node on Drupal 11.x. This suggests the fix implemented in #3494212: Modules that provide fields for entities of other modules can't be installed was only a partial fix.
Steps to reproduce
Run \Drupal\Tests\trash\Functional\TrashNodeTest::testTrashAndRestoreNode on 11.x and see the error:
1) Drupal\Tests\trash\Functional\TrashNodeTest::testTrashAndRestoreNode
Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. Cannot add field 'node_field_data.deleted': table doesn't exist.
Proposed resolution
Install all modules entity schema prior to installing configuration.
Remaining tasks
User interface changes
None
Introduced terminology
N/a
API changes
None
Data model changes
None
Release notes snippet
N/a
Issue fork drupal-3496558
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
alexpottThis is happening because Trash has a config listener \Drupal\trash\EventSubscriber\TrashConfigSubscriber::onSave() that is triggered when trash.settings is saved an adds fields to any enabled entity types. At this point the node module has been enabled but is yet to be processed by the loop that processes the entity installations and simple config in config/install.
A core fix could be
Or we could move this to the trash module and use the container_rebuild_required flag.
Comment #4
alexpottComment #5
alexpottThis feels amazing but this has broken \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest::testGlobalEvents() - I wonder how this has broken that and how that test is the only test of something in the module installer!!!!
Comment #6
alexpott#5 turned out to be unrelated - it was caused by a recent commit to HEAD - see #3492582: Replace some of obj && obj.prop with optional chaining
Comment #7
alexpottI've discussed this with @amateescu and we both think that this change is likely to make the move to multi-module install easier as it means that database schema will be correct before any modules start installing config.
Comment #8
alexpottComment #9
alexpottNote that the trash module is now fixed due to #3496091: Improve the way we enable Trash support by default for nodes being committed.
Comment #10
alexpottNote that the trash module is now fixed due to #3496091: Improve the way we enable Trash support by default for nodes being committed.
Comment #11
smustgrave CreditAttribution: smustgrave at Mobomo commentedWhat’s a good way to test this one? Or just follow steps to reproduce
Comment #12
smustgrave CreditAttribution: smustgrave at Mobomo commentedNW for the tests, but admit I'm not super familiar with the trash module (didn't know of it will this ticket) but wonder if whatever it was doing could be copied in a core test module?
Comment #14
godotislate CreditAttribution: godotislate at Digital Polygon commentedAdded a test. The test works similarly to how trash does: there is a new test module with event subscriber for saving simple config provided by the module. When node and the test module are installed at the same time, the subscriber sets a flag in keyvalue for whether the node entity field table exists at the time of config save.