Problem/Motivation
Follow-up to #2994904: Convert query('SELECT ... FROM {xxx}') to select('xxx')->... in tests
Core should not use direct db calls to entity tables because they are managed by the table mapper entity API.
Proposed resolution
All db_query() and similar should be replaced with \Drupal::entityQuery() or with injected entity storage, and updates/deletes should be done via the Entity API.
From #3012599-11: Replace all db calls to aggregator_feed and aggregator_item tables with Entity APIs:
Potential (non-exhaustive) list of tests affected:
- core\modules\content_moderation\tests\src\Functional\DefaultContentModerationStateRevisionUpdateTest.php
- core\modules\node\tests\src\Kernel\NodeAccessRecordsTest.php
DONE:
- core\modules\node\tests\src\Functional\NodeAccessBaseTableTest.php #3152001: Replace the database queries with an entity queries in NodeAccessBaseTableTest
- core\modules\node\tests\src\Functional\NodeRevisionsTest.php #3151975: Replace the database query with an entity query in NodeRevisionsTest
- core\modules\node\tests\src\Functional\NodeTranslationUITest.php #3151968: Replace the database query with an entity query in NodeTranslationUITest
- core\modules\path\tests\src\Functional\PathTaxonomyTermTest.php #3151959: Replace the database query with an entity query in PathTaxonomyTermTest
- core\modules\node\tests\src\Functional\NodeRevisionPermissionsTest.php #3151990: Replace the database queries with an entity queries in NodeRevisionPermissionsTest
- core\modules\node\tests\src\Functional\NodeRevisionsAllTest.php #3151981: Replace the database query with an entity query in NodeRevisionsAllTest
- core\modules\taxonomy\tests\src\Functional\TermTranslationUITest.php #3151953: Replace the database query with an entity query in TermTranslationUITest
- core\modules\user\tests\src\Kernel\UserInstallTest.php #3151520: Replace the database query with an entity query in UserInstallTest
core\modules\aggregator\tests\src\Functional\FeedParserTest.php#3012599: Replace all db calls to aggregator_feed and aggregator_item tables with Entity APIscore\modules\aggregator\tests\src\Functional\UpdateFeedItemTest.php#3012599: Replace all db calls to aggregator_feed and aggregator_item tables with Entity APIscore\modules\file\tests\src\Functional\SaveUploadFormTest.php#3014950: Replace all db calls to file_managed table with Entity APIscore\modules\file\tests\src\Functional\SaveUploadTest.php#3014950: Replace all db calls to file_managed table with Entity APIscore\modules\file\tests\src\FunctionalJavascript\FileManagedFileElementTest.php#3014950: Replace all db calls to file_managed table with Entity APIs- core\modules\block_content\tests\src\Functional\BlockContentSaveTest.php #3015855: Replace all db calls to block_content table with Entity APIs
- core\modules\block_content\tests\src\Functional\BlockContentTranslationUITest.php #3015855: Replace all db calls to block_content table with Entity APIs
Remaining tasks
Open child issues for each entity type with code that still has direct db calls to convert them.
User interface changes
no
API changes
no
Data model changes
no
Comments
Comment #2
mondrakeComment #3
mondrakeComment #4
mondrakeComment #5
mondrakeComment #6
mondrakeComment #9
mondrakeComment #10
mondrakeComment #12
daffie commentedComment #13
daffie commentedComment #14
daffie commentedComment #15
daffie commentedComment #16
daffie commentedComment #17
daffie commentedComment #18
daffie commentedComment #19
daffie commentedComment #20
mondrakeComment #21
mondrakeComment #22
daffie commentedComment #23
andypostLooks all child items are fixed
Comment #24
voleger#23 Yes, they are fixed.
If no more remaining tasks left then that issue can be marked as fixed.
Comment #25
catchThis didn't need to be RTBC - could just be marked fixed, but great :)