diff -u b/core/lib/Drupal/Core/Entity/entity.api.php b/core/lib/Drupal/Core/Entity/entity.api.php --- b/core/lib/Drupal/Core/Entity/entity.api.php +++ b/core/lib/Drupal/Core/Entity/entity.api.php @@ -938,7 +938,7 @@ */ function hook_entity_insert(Drupal\Core\Entity\EntityInterface $entity) { // Insert the new entity into a fictional table of all entities. - \Drupal::database()->insert('example_entity') + \Drupal::database()->insert('example_entity') ->fields(array( 'type' => $entity->getEntityTypeId(), 'id' => $entity->id(), @@ -947,7 +947,6 @@ )) ->execute(); } - /** * Respond to creation of a new entity of a particular type. * @@ -962,7 +961,7 @@ */ function hook_ENTITY_TYPE_insert(Drupal\Core\Entity\EntityInterface $entity) { // Insert the new entity into a fictional table of this type of entity. - \Drupal::database()->insert('example_entity') + \Drupal::database()->insert('example_entity') ->fields(array( 'id' => $entity->id(), 'created' => REQUEST_TIME, @@ -970,7 +969,6 @@ )) ->execute(); } - /** * Respond to updates to an entity. * only in patch2: unchanged: --- a/core/modules/contact/tests/drupal-7.contact.database.php +++ b/core/modules/contact/tests/drupal-7.contact.database.php @@ -16,7 +16,7 @@ ->execute(); // Add a custom contact category. -db_insert('contact')->fields(array( +\Drupal::database()->insert('contact')->fields(array( 'category', 'recipients', 'reply', only in patch2: unchanged: --- a/core/modules/file/tests/src/Kernel/UsageTest.php +++ b/core/modules/file/tests/src/Kernel/UsageTest.php @@ -20,7 +20,7 @@ class UsageTest extends FileManagedUnitTestBase { */ function testGetUsage() { $file = $this->createFile(); - db_insert('file_usage') + \Drupal::database()->insert('file_usage') ->fields(array( 'fid' => $file->id(), 'module' => 'testing', @@ -29,7 +29,7 @@ function testGetUsage() { 'count' => 1 )) ->execute(); - db_insert('file_usage') + \Drupal::database()->insert('file_usage') ->fields(array( 'fid' => $file->id(), 'module' => 'testing', @@ -80,7 +80,7 @@ function testAddUsage() { function testRemoveUsage() { $file = $this->createFile(); $file_usage = $this->container->get('file.usage'); - db_insert('file_usage') + \Drupal::database()->insert('file_usage') ->fields(array( 'fid' => $file->id(), 'module' => 'testing', only in patch2: unchanged: --- a/core/modules/history/src/Tests/Views/HistoryTimestampTest.php +++ b/core/modules/history/src/Tests/Views/HistoryTimestampTest.php @@ -40,14 +40,14 @@ public function testHandlers() { $this->drupalLogin($account); \Drupal::currentUser()->setAccount($account); - db_insert('history') + \Drupal::database()->insert('history') ->fields(array( 'uid' => $account->id(), 'nid' => $nodes[0]->id(), 'timestamp' => REQUEST_TIME - 100, ))->execute(); - db_insert('history') + \Drupal::database()->insert('history') ->fields(array( 'uid' => $account->id(), 'nid' => $nodes[1]->id(), only in patch2: unchanged: --- a/core/modules/locale/src/Tests/LocaleUpdateBase.php +++ b/core/modules/locale/src/Tests/LocaleUpdateBase.php @@ -279,7 +279,7 @@ protected function setCurrentTranslations() { ); foreach ($data as $file) { $file = array_merge($default, $file); - db_insert('locale_file')->fields($file)->execute(); + \Drupal::database()->insert('locale_file')->fields($file)->execute(); } } only in patch2: unchanged: --- a/core/modules/node/src/Tests/NodeAccessGrantsCacheContextTest.php +++ b/core/modules/node/src/Tests/NodeAccessGrantsCacheContextTest.php @@ -92,7 +92,7 @@ public function testCacheContext() { 'grant_update' => 0, 'grant_delete' => 0, ); - db_insert('node_access')->fields($record)->execute(); + \Drupal::database()->insert('node_access')->fields($record)->execute(); // Put user accessUser (uid 0) in the realm. \Drupal::state()->set('node_access_test.no_access_uid', 0); only in patch2: unchanged: --- a/core/modules/node/src/Tests/NodeQueryAlterTest.php +++ b/core/modules/node/src/Tests/NodeQueryAlterTest.php @@ -151,7 +151,7 @@ function testNodeQueryAlterOverride() { 'grant_update' => 0, 'grant_delete' => 0, ); - db_insert('node_access')->fields($record)->execute(); + \Drupal::database()->insert('node_access')->fields($record)->execute(); // Test that the noAccessUser still doesn't have the 'view' // privilege after adding the node_access record. only in patch2: unchanged: --- a/core/modules/search/src/Tests/SearchRankingTest.php +++ b/core/modules/search/src/Tests/SearchRankingTest.php @@ -101,7 +101,7 @@ public function testRankings() { // to the Statistics module. So instead go ahead and manually update the // counter for this node. $nid = $nodes['views'][1]->id(); - db_insert('node_counter') + \Drupal::database()->insert('node_counter') ->fields(array('totalcount' => 5, 'daycount' => 5, 'timestamp' => REQUEST_TIME, 'nid' => $nid)) ->execute(); only in patch2: unchanged: --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -137,7 +137,7 @@ function simpletest_run_tests($test_list) { unset($test_list['phpunit']); } - $test_id = db_insert('simpletest_test_id') + $test_id = \Drupal::database()->insert('simpletest_test_id') ->useDefaults(array('test_id')) ->execute(); only in patch2: unchanged: --- a/core/modules/system/tests/modules/module_test/module_test.install +++ b/core/modules/system/tests/modules/module_test/module_test.install @@ -29,7 +29,7 @@ function module_test_schema() { */ function module_test_install() { $schema = drupal_get_module_schema('module_test', 'module_test'); - db_insert('module_test') + \Drupal::database()->insert('module_test') ->fields(array( 'data' => $schema['fields']['data']['type'], )) only in patch2: unchanged: --- a/core/modules/views/src/Tests/Plugin/StyleTableTest.php +++ b/core/modules/views/src/Tests/Plugin/StyleTableTest.php @@ -113,7 +113,7 @@ public function testNumericFieldVisible() { // Adds a new datapoint in the views_test_data table to have a person with // an age of zero. $data_set = $this->dataSet(); - $query = db_insert('views_test_data') + $query = \Drupal::database()->insert('views_test_data') ->fields(array_keys($data_set[0])); $query->values(array( 'name' => 'James McCartney', only in patch2: unchanged: --- a/core/modules/views/src/Tests/ViewKernelTestBase.php +++ b/core/modules/views/src/Tests/ViewKernelTestBase.php @@ -71,7 +71,7 @@ protected function setUpFixtures() { // Load the test dataset. $data_set = $this->dataSet(); - $query = db_insert('views_test_data') + $query = \Drupal::database()->insert('views_test_data') ->fields(array_keys($data_set[0])); foreach ($data_set as $record) { $query->values($record); only in patch2: unchanged: --- a/core/modules/views/src/Tests/ViewTestBase.php +++ b/core/modules/views/src/Tests/ViewTestBase.php @@ -52,7 +52,7 @@ protected function enableViewsTestModule() { // Load the test dataset. $data_set = $this->dataSet(); - $query = db_insert('views_test_data') + $query = \Drupal::database()->insert('views_test_data') ->fields(array_keys($data_set[0])); foreach ($data_set as $record) { $query->values($record); only in patch2: unchanged: --- a/core/modules/views/tests/src/Kernel/Plugin/CacheTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/CacheTest.php @@ -89,7 +89,7 @@ public function testTimeResultCaching() { 'age' => 29, 'job' => 'Banjo', ); - db_insert('views_test_data')->fields($record)->execute(); + \Drupal::database()->insert('views_test_data')->fields($record)->execute(); // The result should be the same as before, because of the caching. (Note // that views_test_data records don't have associated cache tags, and hence @@ -243,7 +243,7 @@ function testNoneResultCaching() { 'age' => 29, 'job' => 'Banjo', ); - db_insert('views_test_data')->fields($record)->execute(); + \Drupal::database()->insert('views_test_data')->fields($record)->execute(); // The Result changes, because the view is not cached. $view = Views::getView('test_cache'); only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php @@ -30,7 +30,7 @@ protected function read($name) { } protected function insert($name, $data) { - db_insert('config')->fields(array('name' => $name, 'data' => $data))->execute(); + \Drupal::database()->insert('config')->fields(array('name' => $name, 'data' => $data))->execute(); } protected function update($name, $data) { only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php @@ -68,7 +68,7 @@ function testConcatWsFields() { * Tests escaping of LIKE wildcards. */ function testLikeEscape() { - db_insert('test') + \Drupal::database()->insert('test') ->fields(array( 'name' => 'Ring_', )) @@ -94,7 +94,7 @@ function testLikeEscape() { * Tests a LIKE query containing a backslash. */ function testLikeBackslash() { - db_insert('test') + \Drupal::database()->insert('test') ->fields(array('name')) ->values(array( 'name' => 'abcde\f', only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php @@ -14,7 +14,7 @@ class CaseSensitivityTest extends DatabaseTestBase { function testCaseSensitiveInsert() { $num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField(); - db_insert('test') + \Drupal::database()->insert('test') ->fields(array( 'name' => 'john', // <- A record already exists with name 'John'. 'age' => 2, only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Database/DatabaseTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Database/DatabaseTestBase.php @@ -35,7 +35,7 @@ protected function setUp() { * Sets up tables for NULL handling. */ function ensureSampleDataNull() { - db_insert('test_null') + \Drupal::database()->insert('test_null') ->fields(array('name', 'age')) ->values(array( 'name' => 'Kermit', @@ -57,7 +57,7 @@ function ensureSampleDataNull() { */ static function addSampleData() { // We need the IDs, so we can't use a multi-insert here. - $john = db_insert('test') + $john = \Drupal::database()->insert('test') ->fields(array( 'name' => 'John', 'age' => 25, @@ -65,7 +65,7 @@ static function addSampleData() { )) ->execute(); - $george = db_insert('test') + $george = \Drupal::database()->insert('test') ->fields(array( 'name' => 'George', 'age' => 27, @@ -73,7 +73,7 @@ static function addSampleData() { )) ->execute(); - db_insert('test') + \Drupal::database()->insert('test') ->fields(array( 'name' => 'Ringo', 'age' => 28, @@ -81,7 +81,7 @@ static function addSampleData() { )) ->execute(); - $paul = db_insert('test') + $paul = \Drupal::database()->insert('test') ->fields(array( 'name' => 'Paul', 'age' => 26, @@ -89,7 +89,7 @@ static function addSampleData() { )) ->execute(); - db_insert('test_people') + \Drupal::database()->insert('test_people') ->fields(array( 'name' => 'Meredith', 'age' => 30, @@ -97,7 +97,7 @@ static function addSampleData() { )) ->execute(); - db_insert('test_task') + \Drupal::database()->insert('test_task') ->fields(array('pid', 'task', 'priority')) ->values(array( 'pid' => $john, @@ -136,7 +136,7 @@ static function addSampleData() { )) ->execute(); - db_insert('test_special_columns') + \Drupal::database()->insert('test_special_columns') ->fields(array( 'id' => 1, 'offset' => 'Offset value 1', only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php @@ -15,7 +15,7 @@ class InsertDefaultsTest extends DatabaseTestBase { * Tests that we can run a query that uses default values for everything. */ function testDefaultInsert() { - $query = db_insert('test')->useDefaults(array('job')); + $query = \Drupal::database()->insert('test')->useDefaults(array('job')); $id = $query->execute(); $schema = drupal_get_module_schema('database_test', 'test'); @@ -31,7 +31,7 @@ function testDefaultEmptyInsert() { $num_records_before = (int) db_query('SELECT COUNT(*) FROM {test}')->fetchField(); try { - db_insert('test')->execute(); + \Drupal::database()->insert('test')->execute(); // This is only executed if no exception has been thrown. $this->fail('Expected exception NoFieldsException has not been thrown.'); } @@ -47,7 +47,7 @@ function testDefaultEmptyInsert() { * Tests that we can insert fields with values and defaults in the same query. */ function testDefaultInsertWithFields() { - $query = db_insert('test') + $query = \Drupal::database()->insert('test') ->fields(array('name' => 'Bob')) ->useDefaults(array('job')); $id = $query->execute(); only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php @@ -15,7 +15,7 @@ class InsertLobTest extends DatabaseTestBase { function testInsertOneBlob() { $data = "This is\000a test."; $this->assertTrue(strlen($data) === 15, 'Test data contains a NULL.'); - $id = db_insert('test_one_blob') + $id = \Drupal::database()->insert('test_one_blob') ->fields(array('blob1' => $data)) ->execute(); $r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', array(':id' => $id))->fetchAssoc(); @@ -26,7 +26,7 @@ function testInsertOneBlob() { * Tests that we can insert multiple blob fields in the same query. */ function testInsertMultipleBlob() { - $id = db_insert('test_two_blobs') + $id = \Drupal::database()->insert('test_two_blobs') ->fields(array( 'blob1' => 'This is', 'blob2' => 'a test', only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php @@ -15,7 +15,7 @@ class InsertTest extends DatabaseTestBase { function testSimpleInsert() { $num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField(); - $query = db_insert('test'); + $query = \Drupal::database()->insert('test'); $query->fields(array( 'name' => 'Yoko', 'age' => '29', @@ -37,7 +37,7 @@ function testSimpleInsert() { function testMultiInsert() { $num_records_before = (int) db_query('SELECT COUNT(*) FROM {test}')->fetchField(); - $query = db_insert('test'); + $query = \Drupal::database()->insert('test'); $query->fields(array( 'name' => 'Larry', 'age' => '30', @@ -76,7 +76,7 @@ function testMultiInsert() { function testRepeatedInsert() { $num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField(); - $query = db_insert('test'); + $query = \Drupal::database()->insert('test'); $query->fields(array( 'name' => 'Larry', @@ -118,7 +118,7 @@ function testRepeatedInsert() { function testInsertFieldOnlyDefinition() { // This is useful for importers, when we want to create a query and define // its fields once, then loop over a multi-insert execution. - db_insert('test') + \Drupal::database()->insert('test') ->fields(array('name', 'age')) ->values(array('Larry', '30')) ->values(array('Curly', '31')) @@ -136,8 +136,8 @@ function testInsertFieldOnlyDefinition() { * Tests that inserts return the proper auto-increment ID. */ function testInsertLastInsertID() { - $id = db_insert('test') - ->fields(array( + $id = \Drupal::database()->insert(('test')); + $id ->fields(array( 'name' => 'Larry', 'age' => '30', )) @@ -164,7 +164,7 @@ function testInsertSelectFields() { // SELECT tp.age AS age, tp.name AS name, tp.job AS job // FROM test_people tp // WHERE tp.name = 'Meredith' - db_insert('test') + \Drupal::database()->insert('test') ->from($query) ->execute(); @@ -185,7 +185,7 @@ function testInsertSelectAll() { // SELECT * // FROM test_people tp // WHERE tp.name = 'Meredith' - db_insert('test_people_copy') + \Drupal::database()->insert('test_people_copy') ->from($query) ->execute(); @@ -197,7 +197,7 @@ function testInsertSelectAll() { * Tests that we can INSERT INTO a special named column. */ function testSpecialColumnInsert() { - $id = db_insert('test_special_columns') + $id = \Drupal::database()->insert('test_special_columns') ->fields(array( 'id' => 2, 'offset' => 'Offset value 2', only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php @@ -17,7 +17,7 @@ class InvalidDataTest extends DatabaseTestBase { function testInsertDuplicateData() { // Try to insert multiple records where at least one has bad data. try { - db_insert('test') + \Drupal::database()->insert('test') ->fields(array('name', 'age', 'job')) ->values(array( 'name' => 'Elvis', only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php @@ -94,7 +94,7 @@ public function testConditionOperatorArgumentsSQLInjection() { // Attempt SQLi via union query with no unsafe characters. $this->enableModules(['user']); $this->installEntitySchema('user'); - db_insert('test') + \Drupal::database()->insert('test') ->fields(['name' => '123456']) ->execute(); $injection = "= 1 UNION ALL SELECT password FROM user WHERE uid ="; @@ -111,7 +111,7 @@ public function testConditionOperatorArgumentsSQLInjection() { } // Attempt SQLi via union query - uppercase tablename. - db_insert('TEST_UPPERCASE') + \Drupal::database()->insert('TEST_UPPERCASE') ->fields(['name' => 'secrets']) ->execute(); $injection = "IS NOT NULL) UNION ALL SELECT name FROM {TEST_UPPERCASE} -- "; only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php @@ -22,7 +22,7 @@ class RegressionTest extends DatabaseTestBase { function testRegression_310447() { // That's a 255 character UTF-8 string. $job = str_repeat("é", 255); - db_insert('test') + \Drupal::database()->insert('test') ->fields(array( 'name' => $this->randomMachineName(), 'age' => 20, only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php @@ -381,7 +381,7 @@ function testIndexLength() { */ function tryInsert($table = 'test_table') { try { - db_insert($table) + \Drupal::database()->insert($table) ->fields(array('id' => mt_rand(10, 20))) ->execute(); return TRUE; @@ -457,7 +457,7 @@ function testUnsignedColumns() { */ function tryUnsignedInsert($table_name, $column_name) { try { - db_insert($table_name) + \Drupal::database()->insert($table_name) ->fields(array($column_name => -1)) ->execute(); return TRUE; @@ -585,7 +585,7 @@ protected function assertFieldAdditionRemoval($field_spec) { // Insert some rows to the table to test the handling of initial values. for ($i = 0; $i < 3; $i++) { - db_insert($table_name) + \Drupal::database()->insert($table_name) ->useDefaults(array('serial_column')) ->execute(); } @@ -638,7 +638,7 @@ protected function assertFieldCharacteristics($table_name, $field_name, $field_s // Check that the default value has been registered. if (isset($field_spec['default'])) { // Try inserting a row, and check the resulting value of the new column. - $id = db_insert($table_name) + $id = \Drupal::database()->insert($table_name) ->useDefaults(array('serial_column')) ->execute(); $field_value = db_select($table_name) @@ -722,7 +722,7 @@ protected function assertFieldChange($old_spec, $new_spec, $test_data = NULL) { db_truncate($table_name)->execute(); if ($test_data) { - $id = db_insert($table_name) + $id = \Drupal::database()->insert($table_name) ->fields(['test_field'], [$test_data]) ->execute(); } only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php @@ -209,7 +209,7 @@ function testJoinSubquerySelect() { */ function testExistsSubquerySelect() { // Put George into {test_people}. - db_insert('test_people') + \Drupal::database()->insert('test_people') ->fields(array( 'name' => 'George', 'age' => 27, @@ -239,7 +239,7 @@ function testExistsSubquerySelect() { */ function testNotExistsSubquerySelect() { // Put George into {test_people}. - db_insert('test_people') + \Drupal::database()->insert('test_people') ->fields(array( 'name' => 'George', 'age' => 27, only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php @@ -401,7 +401,7 @@ function testRandomOrder() { // after shuffling it (in other words, nearly impossible). $number_of_items = 52; while (db_query("SELECT MAX(id) FROM {test}")->fetchField() < $number_of_items) { - db_insert('test')->fields(array('name' => $this->randomMachineName()))->execute(); + \Drupal::database()->insert('test')->fields(array('name' => $this->randomMachineName()))->execute(); } // First select the items in order and make sure we get an ordered list. only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php @@ -57,7 +57,7 @@ protected function transactionOuterLayer($suffix, $rollback = FALSE, $ddl_statem $txn = db_transaction(); // Insert a single row into the testing table. - db_insert('test') + \Drupal::database()->insert('test') ->fields(array( 'name' => 'David' . $suffix, 'age' => '24', @@ -107,7 +107,7 @@ protected function transactionInnerLayer($suffix, $rollback = FALSE, $ddl_statem $this->assertTrue($depth < $depth2, 'Transaction depth is has increased with new transaction.'); // Insert a single row into the testing table. - db_insert('test') + \Drupal::database()->insert('test') ->fields(array( 'name' => 'Daniel' . $suffix, 'age' => '19', @@ -310,7 +310,7 @@ function testTransactionWithDdlStatement() { * Inserts a single row into the testing table. */ protected function insertRow($name) { - db_insert('test') + \Drupal::database()->insert('test') ->fields(array( 'name' => $name, )) only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php @@ -15,7 +15,7 @@ class UpdateLobTest extends DatabaseTestBase { function testUpdateOneBlob() { $data = "This is\000a test."; $this->assertTrue(strlen($data) === 15, 'Test data contains a NULL.'); - $id = db_insert('test_one_blob') + $id = \Drupal::database()->insert('test_one_blob') ->fields(array('blob1' => $data)) ->execute(); @@ -33,7 +33,7 @@ function testUpdateOneBlob() { * Confirms that we can update two blob columns in the same table. */ function testUpdateMultipleBlob() { - $id = db_insert('test_two_blobs') + $id = \Drupal::database()->insert('test_two_blobs') ->fields(array( 'blob1' => 'This is', 'blob2' => 'a test', only in patch2: unchanged: --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php @@ -124,7 +124,7 @@ function testFieldLoad() { // Generate values and insert them directly in the storage tables. $values = array(); - $query = db_insert($this->revisionTable)->fields($columns); + $query = \Drupal::database()->insert($this->revisionTable)->fields($columns); foreach ($revision_ids as $revision_id) { // Put one value too many. for ($delta = 0; $delta <= $this->fieldCardinality; $delta++) { @@ -134,7 +134,7 @@ function testFieldLoad() { } $query->execute(); } - $query = db_insert($this->table)->fields($columns); + $query = \Drupal::database()->insert($this->table)->fields($columns); foreach ($values[$revision_id] as $delta => $value) { $query->values(array($bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value)); } @@ -168,8 +168,8 @@ function testFieldLoad() { // loaded. $unavailable_langcode = 'xx'; $values = array($bundle, 0, $entity->id(), $entity->getRevisionId(), 0, $unavailable_langcode, mt_rand(1, 127)); - db_insert($this->table)->fields($columns)->values($values)->execute(); - db_insert($this->revisionTable)->fields($columns)->values($values)->execute(); + \Drupal::database()->insert($this->table)->fields($columns)->values($values)->execute(); + \Drupal::database()->insert($this->revisionTable)->fields($columns)->values($values)->execute(); $entity = $storage->load($entity->id()); $this->assertFalse(array_key_exists($unavailable_langcode, $entity->{$this->fieldName})); }