summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-09-23 13:04:08 (GMT)
committerAlex Pott2013-09-23 13:04:08 (GMT)
commite40eb19722c143617a1015c3ebcd98bd037e8c18 (patch)
tree6c4cfada177e385936c9894f8d51e2c516fe583c
parent47ec9cf0be7358abcfc2b1835c6d098c9f5f3ec8 (diff)
Issue #2086095 by yched, swentel, Hydra: Fixed Remove remaining references to field_sql_storage().
-rw-r--r--core/lib/Drupal/Core/Entity/DatabaseStorageController.php28
-rw-r--r--core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerInterface.php5
-rw-r--r--core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php2
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/Config/NodeImportChangeTest.php2
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/Config/NodeImportCreateTest.php2
-rw-r--r--core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php6
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php3
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php31
-rw-r--r--core/modules/system/tests/modules/entity_test/entity_test.module6
11 files changed, 60 insertions, 29 deletions
diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
index 2bed3f6..9d13fcd 100644
--- a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
+++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
@@ -867,22 +867,22 @@ class DatabaseStorageController extends FieldableEntityStorageControllerBase {
* {@inheritdoc}
*/
public function onBundleRename($bundle, $bundle_new) {
- // We need to account for deleted or inactive fields and instances.
- $instances = field_read_instances(array('entity_type' => $this->entityType, 'bundle' => $bundle_new), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
+ // We need to account for deleted or inactive fields and instances. The
+ // method runs before the instance definitions are updated, so we need to
+ // fetch them using the old bundle name.
+ $instances = field_read_instances(array('entity_type' => $this->entityType, 'bundle' => $bundle), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
foreach ($instances as $instance) {
$field = $instance->getField();
- if ($field['storage']['type'] == 'field_sql_storage') {
- $table_name = static::_fieldTableName($field);
- $revision_name = static::_fieldRevisionTableName($field);
- $this->database->update($table_name)
- ->fields(array('bundle' => $bundle_new))
- ->condition('bundle', $bundle)
- ->execute();
- $this->database->update($revision_name)
- ->fields(array('bundle' => $bundle_new))
- ->condition('bundle', $bundle)
- ->execute();
- }
+ $table_name = static::_fieldTableName($field);
+ $revision_name = static::_fieldRevisionTableName($field);
+ $this->database->update($table_name)
+ ->fields(array('bundle' => $bundle_new))
+ ->condition('bundle', $bundle)
+ ->execute();
+ $this->database->update($revision_name)
+ ->fields(array('bundle' => $bundle_new))
+ ->condition('bundle', $bundle)
+ ->execute();
}
}
diff --git a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerInterface.php b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerInterface.php
index 31d59ab..a52a5ad 100644
--- a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerInterface.php
+++ b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerInterface.php
@@ -81,6 +81,9 @@ interface FieldableEntityStorageControllerInterface extends EntityStorageControl
/**
* Allows reaction to a bundle being renamed.
*
+ * This method runs before field instance definitions are updated with the new
+ * bundle name.
+ *
* @param string $bundle
* The name of the bundle being renamed.
* @param string $bundle_new
@@ -91,6 +94,8 @@ interface FieldableEntityStorageControllerInterface extends EntityStorageControl
/**
* Allows reaction to a bundle being deleted.
*
+ * This method runs before field and instance definitions are deleted.
+ *
* @param string $bundle
* The name of the bundle being deleted.
*/
diff --git a/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php b/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php
index 145ca53..414a284 100644
--- a/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php
+++ b/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php
@@ -30,7 +30,7 @@ abstract class NormalizerTestBase extends DrupalUnitTestBase {
*
* @var array
*/
- public static $modules = array('entity', 'entity_test', 'entity_reference', 'field', 'field_sql_storage', 'hal', 'language', 'rest', 'serialization', 'system', 'text', 'user', 'filter');
+ public static $modules = array('entity', 'entity_test', 'entity_reference', 'field', 'hal', 'language', 'rest', 'serialization', 'system', 'text', 'user', 'filter');
/**
* The mock serializer.
diff --git a/core/modules/node/lib/Drupal/node/Tests/Config/NodeImportChangeTest.php b/core/modules/node/lib/Drupal/node/Tests/Config/NodeImportChangeTest.php
index 8f162e0..d50d6ce 100644
--- a/core/modules/node/lib/Drupal/node/Tests/Config/NodeImportChangeTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/Config/NodeImportChangeTest.php
@@ -19,7 +19,7 @@ class NodeImportChangeTest extends DrupalUnitTestBase {
*
* @var array
*/
- public static $modules = array('node', 'entity', 'field', 'text', 'field_sql_storage', 'system', 'node_test_config');
+ public static $modules = array('node', 'entity', 'field', 'text', 'system', 'node_test_config');
/**
* Set the default field storage backend for fields created during tests.
diff --git a/core/modules/node/lib/Drupal/node/Tests/Config/NodeImportCreateTest.php b/core/modules/node/lib/Drupal/node/Tests/Config/NodeImportCreateTest.php
index cd117bb..0a1db9c 100644
--- a/core/modules/node/lib/Drupal/node/Tests/Config/NodeImportCreateTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/Config/NodeImportCreateTest.php
@@ -19,7 +19,7 @@ class NodeImportCreateTest extends DrupalUnitTestBase {
*
* @var array
*/
- public static $modules = array('node', 'entity', 'field', 'text', 'field_sql_storage', 'system');
+ public static $modules = array('node', 'entity', 'field', 'text', 'system');
/**
* Set the default field storage backend for fields created during tests.
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
index 4fbdffd..4e598bf 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
@@ -108,7 +108,7 @@ class DrupalUnitTestBaseTest extends DrupalUnitTestBase {
*/
function testEnableModulesInstallContainer() {
// Install Node module.
- $this->enableModules(array('field_sql_storage', 'field', 'node'));
+ $this->enableModules(array('field', 'node'));
$this->installSchema('node', array('node', 'node_field_data'));
// Perform an entity query against node.
@@ -206,12 +206,12 @@ class DrupalUnitTestBaseTest extends DrupalUnitTestBase {
$this->assertTrue(TRUE == entity_get_info('entity_test'));
// Load some additional modules; entity_test should still exist.
- $this->enableModules(array('entity', 'field', 'field_sql_storage', 'text', 'entity_test'));
+ $this->enableModules(array('entity', 'field', 'text', 'entity_test'));
$this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
$this->assertTrue(TRUE == entity_get_info('entity_test'));
// Install some other modules; entity_test should still exist.
- $this->container->get('module_handler')->install(array('field', 'field_sql_storage', 'field_test'), FALSE);
+ $this->container->get('module_handler')->install(array('field', 'field_test'), FALSE);
$this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
$this->assertTrue(TRUE == entity_get_info('entity_test'));
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php
index 9349484..7f7d2c4 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php
@@ -6,9 +6,6 @@
*/
namespace Drupal\system\Tests\Entity;
-use Drupal\field_sql_storage\Entity\ConditionAggregate;
-use Drupal\simpletest\DrupalUnitTestBase;
-
/**
* Defines a test for testing aggregation support for entity query.
*
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php
index 9f95373..4a417f8 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php
@@ -20,7 +20,7 @@ class EntityQueryRelationshipTest extends EntityUnitTestBase {
public static $modules = array('taxonomy', 'options');
/**
- * @var \Drupal\field_sql_storage\Entity\QueryFactory
+ * @var \Drupal\Core\Entity\Query\QueryFactory
*/
protected $factory;
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php
index 384c815..7395dfa 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php
@@ -19,7 +19,7 @@ class FieldAccessTest extends DrupalUnitTestBase {
*
* @var array
*/
- public static $modules = array('entity', 'entity_test', 'field', 'field_sql_storage', 'system', 'text', 'filter', 'user');
+ public static $modules = array('entity', 'entity_test', 'field', 'system', 'text', 'filter', 'user');
/**
* Holds the currently active global user ID that initiated the test run.
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php
index 4988b49..34818e0 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php
@@ -26,7 +26,7 @@ class FieldSqlStorageTest extends EntityUnitTestBase {
*
* @var array
*/
- public static $modules = array('field', 'field_test', 'text', 'number', 'entity_test');
+ public static $modules = array('system', 'field', 'field_test', 'text', 'number', 'entity_test');
/**
* The name of the created field.
@@ -67,6 +67,7 @@ class FieldSqlStorageTest extends EntityUnitTestBase {
function setUp() {
parent::setUp();
$this->installSchema('entity_test', array('entity_test_rev', 'entity_test_rev_revision'));
+ $this->installSchema('system', array('variable'));
$entity_type = 'entity_test_rev';
$this->field_name = strtolower($this->randomName());
@@ -459,6 +460,34 @@ class FieldSqlStorageTest extends EntityUnitTestBase {
}
/**
+ * Tests reacting to a bundle being renamed.
+ */
+ function testFieldSqlStorageBundleRename() {
+ $entity_type = $bundle = 'entity_test_rev';
+
+ // Create an entity.
+ $value = mt_rand(1, 127);
+ $entity = entity_create($entity_type, array(
+ 'type' => $bundle,
+ $this->field->name => $value,
+ ));
+ $entity->save();
+
+ // Rename the bundle.
+ $bundle_new = $bundle . '_renamed';
+ entity_test_rename_bundle($bundle, $bundle_new, $entity_type);
+
+ // Check that the 'bundle' column has been updated in storage.
+ $row = db_select($this->table, 't')
+ ->fields('t', array('bundle', $this->field->name . '_value'))
+ ->condition('entity_id', $entity->id())
+ ->execute()
+ ->fetch();
+ $this->assertEqual($row->bundle, $bundle_new);
+ $this->assertEqual($row->{$this->field->name . '_value'}, $value);
+ }
+
+ /**
* Tests table name generation.
*/
public function testTableNames() {
diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module
index 4ef754d..9ca18e7 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.module
+++ b/core/modules/system/tests/modules/entity_test/entity_test.module
@@ -80,7 +80,7 @@ function entity_test_entity_info_alter(&$info) {
* 'entity_test'.
*/
function entity_test_create_bundle($bundle, $text = NULL, $entity_type = 'entity_test') {
- $bundles = \Drupal::state()->get($entity_type . '.bundles') ?: array('entity_test' => array('label' => 'Entity Test Bundle'));
+ $bundles = \Drupal::state()->get($entity_type . '.bundles') ?: array($entity_type => array('label' => 'Entity Test Bundle'));
$bundles += array($bundle => array('label' => $text ? $text : $bundle));
\Drupal::state()->set($entity_type . '.bundles', $bundles);
@@ -99,7 +99,7 @@ function entity_test_create_bundle($bundle, $text = NULL, $entity_type = 'entity
* 'entity_test'.
*/
function entity_test_rename_bundle($bundle_old, $bundle_new, $entity_type = 'entity_test') {
- $bundles = \Drupal::state()->get($entity_type . '.bundles') ?: array('entity_test' => array('label' => 'Entity Test Bundle'));
+ $bundles = \Drupal::state()->get($entity_type . '.bundles') ?: array($entity_type => array('label' => 'Entity Test Bundle'));
$bundles[$bundle_new] = $bundles[$bundle_old];
unset($bundles[$bundle_old]);
\Drupal::state()->set($entity_type . '.bundles', $bundles);
@@ -117,7 +117,7 @@ function entity_test_rename_bundle($bundle_old, $bundle_new, $entity_type = 'ent
* 'entity_test'.
*/
function entity_test_delete_bundle($bundle, $entity_type = 'entity_test') {
- $bundles = \Drupal::state()->get($entity_type . '.bundles') ?: array('entity_test' => array('label' => 'Entity Test Bundle'));
+ $bundles = \Drupal::state()->get($entity_type . '.bundles') ?: array($entity_type => array('label' => 'Entity Test Bundle'));
unset($bundles[$bundle]);
\Drupal::state()->set($entity_type . '.bundles', $bundles);