diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php index ceb1618..267e10c 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php @@ -322,11 +322,11 @@ protected function buildQuery($ids, $revision_id = FALSE) { } // Add fields from the {entity} table. - $entity_fields = drupal_schema_fields_sql($this->entityInfo['base_table']); + $entity_fields = $this->entityInfo['schema_fields_sql']['base_table']; if ($this->revisionKey) { // Add all fields from the {entity_revision} table. - $entity_revision_fields = drupal_map_assoc(drupal_schema_fields_sql($this->entityInfo['revision_table'])); + $entity_revision_fields = drupal_map_assoc($this->entityInfo['schema_fields_sql']['revision_table']); // The id field is provided by entity, so remove it. unset($entity_revision_fields[$this->idKey]); diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php index 86a5544..6f22d83 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php @@ -234,7 +234,7 @@ protected function invokeHook($hook, EntityInterface $entity) { */ protected function mapToStorageRecord(EntityInterface $entity) { $record = new \stdClass(); - foreach (drupal_schema_fields_sql($this->entityInfo['base_table']) as $name) { + foreach ($this->entityInfo['schema_fields_sql']['base_table'] as $name) { $record->$name = $entity->$name->value; } return $record; diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 88678e8..a75dc44 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -282,12 +282,12 @@ protected function processDefinition(&$definition, $plugin_id) { } // Prepare entity schema fields SQL info for // Drupal\Core\Entity\DatabaseStorageControllerInterface::buildQuery(). - //if (isset($definition['base_table'])) { - // $definition['schema_fields_sql']['base_table'] = drupal_schema_fields_sql($definition['base_table']); - // if (isset($definition['revision_table'])) { - // $definition['schema_fields_sql']['revision_table'] = drupal_schema_fields_sql($definition['revision_table']); - // } - //} + if (isset($definition['base_table'])) { + $definition['schema_fields_sql']['base_table'] = drupal_schema_fields_sql($definition['base_table']); + if (isset($definition['revision_table'])) { + $definition['schema_fields_sql']['revision_table'] = drupal_schema_fields_sql($definition['revision_table']); + } + } } } diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index a854787..aa0d361 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -1603,16 +1603,10 @@ function field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) { field_cache_clear(); entity_info_cache_clear(); - // Rename bundle settings. - // @fieldcmi entity_load('bundle', '$entity_type . '.' . $bundle_old');? - if (config('field.bundle.' . $entity_type . '.' . $bundle_old)->get()) { - $new_bundle_id = $entity_type . '.' . $bundle_new; - config('field.bundle.' . $entity_type . '.' . $bundle_old)->rename('field.settings.' . $new_bundle_id); - config('field.settings.' . $new_bundle_id) - ->set('id', $new_bundle_id) - ->set('label', $new_bundle_id) - ->save(); - } + // Update bundle settings. + $settings = variable_get('field_bundle_settings_' . $entity_type . '__' . $bundle_old, array()); + variable_set('field_bundle_settings_' . $entity_type . '__' . $bundle_new, $settings); + variable_del('field_bundle_settings_' . $entity_type . '__' . $bundle_old); // Let other modules act on renaming the bundle. module_invoke_all('field_attach_rename_bundle', $entity_type, $bundle_old, $bundle_new); @@ -1650,12 +1644,7 @@ function field_attach_delete_bundle($entity_type, $bundle, $field_cleanup = TRUE field_cache_clear(); // Clear bundle display settings. - // @fieldcmi - $bundle = entity_load('bundle', $entity_type . '.' . $bundle); - if ($bundle) { - $bundle->delete(); - } - //config('field.settings.' . $entity_type . '.' . $bundle)->delete(); + variable_del('field_bundle_settings_' . $entity_type . '__' . $bundle); // Let other modules act on deleting the bundle. module_invoke_all('field_attach_delete_bundle', $entity_type, $bundle, $instances); diff --git a/core/modules/field/field.info b/core/modules/field/field.info index b138b52..75b1bed 100644 --- a/core/modules/field/field.info +++ b/core/modules/field/field.info @@ -3,6 +3,5 @@ description = Field API to add fields to entities like nodes and users. package = Core version = VERSION core = 8.x -;dependencies[] = field_sql_storage required = TRUE stylesheets[all][] = theme/field.css diff --git a/core/modules/field/field.install b/core/modules/field/field.install index afef7cd..398d7c5 100644 --- a/core/modules/field/field.install +++ b/core/modules/field/field.install @@ -352,23 +352,6 @@ function field_update_8001() { state()->set('field.field.deleted', $deleted_fields); state()->set('field.instance.deleted', $deleted_instances); - // Convert the field bundle settings variables. - $results = db_query("SELECT name, value FROM {variable} WHERE name LIKE 'field_bundle_settings_%'"); - foreach ($results as $record) { - $identifier = str_replace('field_bundle_settings_', '', $record->name); - list($entity_type, $bundle) = explode('__', $identifier); - - // Save the configuration. - entity_create('bundle', array( - 'id' => $entity_type. '.' . $bundle, - 'label' => $entity_type. '.' . $bundle, - 'data' => unserialize($record->value), - ))->save(); - - // Remove the variable. - update_variable_del($record->name); - } - // Drop the tables. db_drop_table('field_config'); db_drop_table('field_config_instance'); diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 65f9fe2..777e1e6 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -409,7 +409,7 @@ function field_config_import_delete($name, $new_config, $old_config) { */ function field_system_info_alter(&$info, $file, $type) { // During a Drupal 7 to Drupal 8 upgrade it is only safe to call - // field_read_fields() once the field_update_8001 has finished. + // field_read_fields() once field_update_8001() has finished. if ($type == 'module' && module_hook($file->name, 'field_info') && drupal_get_installed_schema_version('field') >= 8001) { $fields = field_read_fields(array('module' => $file->name), array('include_deleted' => TRUE)); if ($fields) { @@ -783,33 +783,12 @@ function _field_sort_items_value_helper($a, $b) { * If no $settings are passed, the current settings are returned. */ function field_bundle_settings($entity_type, $bundle, $settings = NULL) { - $identifier = $entity_type . '.' . $bundle; - if (isset($settings)) { - // @fieldcmi - $e_bundle = entity_load('bundle', $identifier); - if ($e_bundle) { - $e_bundle->data = $settings; - } - else { - $e_bundle = entity_create('bundle', array( - 'id' => $identifier, - 'label' => $identifier, - 'data' => $settings, - )); - } - $e_bundle->save(); - // config('field.settings.' . $identifier)->setData($settings)->save(); + variable_set('field_bundle_settings_' . $entity_type . '__' . $bundle, $settings); field_info_cache_clear(); } else { - $e_bundle = entity_load('bundle', $identifier); - if ($e_bundle) { - $settings = $e_bundle->data; - } - else { - $settings = array(); - } + $settings = variable_get('field_bundle_settings_' . $entity_type . '__' . $bundle, array()); $settings += array( 'view_modes' => array(), 'extra_fields' => array(), diff --git a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Bundle.php b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Bundle.php deleted file mode 100644 index dedf431..0000000 --- a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Bundle.php +++ /dev/null @@ -1,60 +0,0 @@ -= 8001) { // Dynamic (data) tables. - //module_load_include('module', 'field'); - //drupal_classloader_register('field', dirname(drupal_get_filename('module', 'field'))); - $fields = field_read_fields(array(), array('include_deleted' => TRUE, 'include_inactive' => TRUE)); + // We don't call field_read_fields() as this will cause endless loops + // in entity_get_info(). + $fields = config_get_storage_names_with_prefix('field.field'); drupal_load('module', 'field_sql_storage'); - foreach ($fields as $field) { + foreach ($fields as $name) { + $field = config($name)->get('data'); if ($field['storage']['type'] == 'field_sql_storage') { $schema += _field_sql_storage_schema($field); } diff --git a/core/modules/field/modules/link/link.info b/core/modules/field/modules/link/link.info index 0bee0d1..a43c222 100644 --- a/core/modules/field/modules/link/link.info +++ b/core/modules/field/modules/link/link.info @@ -4,4 +4,3 @@ core = 8.x package = Core version = VERSION dependencies[] = field -dependencies[] = field_sql_storage diff --git a/core/modules/field/modules/number/number.info b/core/modules/field/modules/number/number.info index 5785127..aabe3d7 100644 --- a/core/modules/field/modules/number/number.info +++ b/core/modules/field/modules/number/number.info @@ -4,4 +4,3 @@ package = Core version = VERSION core = 8.x dependencies[] = field -dependencies[] = field_sql_storage diff --git a/core/modules/field/modules/options/options.info b/core/modules/field/modules/options/options.info index eebb593..f19e952 100644 --- a/core/modules/field/modules/options/options.info +++ b/core/modules/field/modules/options/options.info @@ -4,4 +4,3 @@ package = Core version = VERSION core = 8.x dependencies[] = field -dependencies[] = field_sql_storage diff --git a/core/modules/field/modules/text/text.info b/core/modules/field/modules/text/text.info index 5eab8ac..3ba8357 100644 --- a/core/modules/field/modules/text/text.info +++ b/core/modules/field/modules/text/text.info @@ -4,5 +4,4 @@ package = Core version = VERSION core = 8.x dependencies[] = field -dependencies[] = field_sql_storage required = TRUE diff --git a/core/modules/node/node.module b/core/modules/node/node.module index a4c53b4..a6a64ae 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -195,11 +195,6 @@ function node_cron() { * Implements hook_entity_info_alter(). */ function node_entity_info_alter(&$info) { - if (!db_table_exists('node_type')) { - // entity_get_info() is called in drupal_get_schema now this means this can - // be called before the schema is installed. - return; - } // Add a translation handler for fields if the language module is enabled. if (module_exists('language')) { $info['node']['translation']['node'] = TRUE; diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 742a245..2e04773 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -390,11 +390,6 @@ function rdf_modules_uninstalled($modules) { * */ function rdf_entity_info_alter(&$entity_info) { - if (!db_table_exists('rdf_mapping')) { - // entity_get_info() is called in drupal_get_schema now this means this can - // be called before the schema is installed. - return; - } // Loop through each entity type and its bundles. foreach ($entity_info as $entity_type => $entity_type_info) { if (!empty($entity_type_info['bundles'])) { diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 1a14090..8da637f 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -109,11 +109,6 @@ function taxonomy_permission() { * Implements hook_entity_info_alter(). */ function taxonomy_entity_info_alter(&$info) { - if (!db_table_exists('taxonomy_vocabulary')) { - // entity_get_info() is called in drupal_get_schema now this means this can - // be called both the schema is installed. - return; - } foreach (taxonomy_vocabulary_get_names() as $machine_name => $vocabulary) { $info['taxonomy_term']['bundles'][$machine_name] = array( 'label' => $vocabulary->name,