diff --git a/core/modules/field_sql_storage/field_sql_storage.install b/core/modules/field_sql_storage/field_sql_storage.install index 4bf79df..03390a6 100644 --- a/core/modules/field_sql_storage/field_sql_storage.install +++ b/core/modules/field_sql_storage/field_sql_storage.install @@ -8,32 +8,6 @@ use Drupal\field\Plugin\Core\Entity\Field; /** - * Implements hook_schema(). - */ -function field_sql_storage_schema() { - $schema = array(); - - // Loading entities within hook_schema() triggers lots of race conditions. - // Read definitions for raw storage instead (configuration, and state for - // deleted fields). - $fields = array(); - foreach (config_get_storage_names_with_prefix('field.field') as $name) { - $fields[] = config($name)->get(); - } - $deleted_fields = Drupal::state()->get('field.field.deleted') ?: array(); - $fields = array_merge($fields, $deleted_fields); - - foreach ($fields as $field) { - if ($field['storage']['type'] == 'field_sql_storage') { - $field = new Field($field); - $schema += _field_sql_storage_schema($field); - } - } - - return $schema; -} - -/** * Writes field data directly to SQL storage. * * @ingroup update_api diff --git a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php index e5b6fe1..5263787 100644 --- a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php +++ b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php @@ -449,7 +449,8 @@ function testFieldSqlStorageForeignKeys() { $this->assertEqual($field['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', t('Foreign key column name modified after update')); // Now grab the SQL schema and verify that too. - $schema = drupal_get_schema(_field_sql_storage_tablename($field), TRUE); + $schemas = _field_sql_storage_schema($field); + $schema = $schemas[_field_sql_storage_tablename($field)]; $this->assertEqual(count($schema['foreign keys']), 1, 'There is 1 foreign key in the schema'); $foreign_key = reset($schema['foreign keys']); $foreign_key_column = _field_sql_storage_columnname($field['field_name'], $foreign_key_name); diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php index b91d9af..ad92165 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php @@ -146,11 +146,7 @@ function testImageFieldSettings() { $widget_settings = array( 'preview_image_style' => 'medium', ); - $field = $this->createImageField($field_name, 'article', array(), $instance_settings, $widget_settings); - $field['deleted'] = 0; - $table = _field_sql_storage_tablename($field); - $schema = drupal_get_schema($table, TRUE); - $instance = field_info_instance('node', $field_name, 'article'); + $instance = $this->createImageField($field_name, 'article', array(), $instance_settings, $widget_settings); $this->drupalGet('node/add/article'); $this->assertText(t('Files must be less than 50 KB.'), 'Image widget max file size is displayed on article form.'); @@ -198,12 +194,13 @@ function testImageFieldSettings() { $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][title]' => $this->randomName($test_size), ); $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save and keep published')); + $schema = $instance->getField()->getSchema(); $this->assertRaw(t('Alternate text cannot be longer than %max characters but is currently %length characters long.', array( - '%max' => $schema['fields'][$field_name .'_alt']['length'], + '%max' => $schema['columns']['alt']['length'], '%length' => $test_size, ))); $this->assertRaw(t('Title cannot be longer than %max characters but is currently %length characters long.', array( - '%max' => $schema['fields'][$field_name .'_title']['length'], + '%max' => $schema['columns']['title']['length'], '%length' => $test_size, ))); }