Closed (fixed)
Project:
Drupal core
Version:
8.7.x-dev
Component:
database system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
6 Feb 2017 at 09:12 UTC
Updated:
14 Sep 2018 at 01:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
gaurav.kapoor commentedReplaced calls to Db_delete with new syntax.
Comment #3
dhruveshdtripathi commentedComment #4
dhruveshdtripathi commentedThe patch seems OK according to standards.
Comment #5
xjmGood work on this so far! I think that this patch takes a good approach and scope to fixing these.
I have queued test runs with Postgres and SQLite to be safe (always advisable for patches for the DB API or Views).
When I apply the patch, there are still a few usages we are missing, as well as documentation references:
Let's fix those in the same way as we did for this patch so far. The documentation references will need a different approach. (They will need to reference the method on the fully-namespaced interface used for the service.) That can be done in a followup to make things easier.
Comment #6
cilefen commentedThis:
... makes me think some of these will have to be fixed one-by-one.
Comment #7
xjmOn #2848161: [meta] Replace calls to deprecated db_*() wrappers I have recommended replacing all code usages first, and then having possibly a single followup to remove documentation references for things like #6.
Comment #8
sharique commentedReplaced db_delete calls in tests.
Comment #9
jeetendrakumar commentedinject the dependency in ShortcutSetStorage.php file.
Comment #10
jeetendrakumar commentedComment #11
hgunicamp commentedI applied the 'replace_all_calls_to_db_delete-2850033-10.patch' patch and evaluated how many 'db_delete' calls there still exist.
- Before
find . -type f \( -name '*.inc' -or -name '*.module' -or -name '*.php' \) -exec grep db_delete\( {} \+ | wc -l
37
- After
find . -type f \( -name '*.inc' -or -name '*.module' -or -name '*.php' \) -exec grep db_delete\( {} \+ | wc -l
12
The remaining calls are these files:
find . -type f \( -name '*.inc' -or -name '*.module' -or -name '*.php' \) -exec grep db_delete\( {} \+ | cut -f1 -d':' | uniq
./core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php
./core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php
./core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
./core/modules/tracker/tests/src/Functional/TrackerTest.php
./core/modules/dblog/src/Tests/DbLogTest.php
./core/includes/database.inc
./core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
./core/lib/Drupal/Core/Database/database.api.php
Comment #12
sharique commentedKeeping in
./core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php
./core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php
as these looks to self test to me.
Reset of remaining occurrences are documentation, which will be updated separately.
Comment #13
pk188 commentedUpdated.
Comment #16
yogeshmpawarComment #17
yogeshmpawarPrevious patch #13 failed to apply on 8.6.x branch because file path change from core/modules/dblog/src/Tests/DbLogTest.php to core/modules/dblog/tests/src/Functional/DbLogTest.php
Comment #19
piggito commentedReverting wrongly change for db_insert instance.
Comment #20
volegerUpdated naming of a parameter.
Comment #22
andypostneeds wrap on 80 chars
use variable for `\Drupal::database()`
Comment #23
andypostRerolled and updated patch
Comment #24
andypostone more fix
Comment #26
andypostreroll after #2848821: Replace all calls to db_close, which is deprecated
Comment #27
mondrakehere we need to get a final decision how to properly get the database connection in test contexts, #2991337: Document the recommended ways to obtain the database connection object
here you can directly use
$this->connectionas the class is extending fromDatabaseTestBase. SeetestTruncateInTransactionandtestTruncateTransactionRollbackwhich are already doing that.Comment #28
andypostUpdated patch
- Using
$this->connectioninDeleteTruncateTestas this inherited fromDatabaseTestBase-
DatabaseStorageTest.phpis Kernel test which everywhere usingDatabase::getConnection()Functional tests still depends on #2991337: Document the recommended ways to obtain the database connection object
Comment #30
andypostFixed functional tests - I think better to make test connections running in each testcase are independent from container
That's because no matter on container rebuild testing mocked database connection will remain the same
Comment #31
mondrakeNit: \Drupal::database()->delete() can just be ::delete() here, we're in the Connection object and it's a method of the class
Can we test a real delete here instead, for instance c/p from DeleteTruncateTest::testSimpleDelete?
I think this is more than ready otherwise... just we do not have a conclusion on #2991337: Document the recommended ways to obtain the database connection object yet. Will set that one as a blocker as we're getting stuck on the more complicated db_* deprecation issues without that. Tagging for Framework Manager review, also.
Comment #32
andypostNo, we should test result of the function which is Delete object - this test intended for test that legacy function works
Comment #33
andypostfixed docs
Comment #34
mondrakeok then
Comment #37
andypostRe-roll after #2848137: Replace all calls to db_update, which is deprecated
Comment #38
catchCommitted 84bde9d and pushed to 8.7.x. Thanks!