summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2016-10-12 12:37:13 (GMT)
committerAlex Pott2016-10-12 12:37:13 (GMT)
commit01ed544c7afd543ed29d756222ae36eaaf85482e (patch)
tree34c1417c6a64868d1b02edcf699bede6cfff026d
parentdbf2b0ed1b6242b7a3a01cad332c1bc6738f11f5 (diff)
Revert "Issue #2609252 by eiriksm, lokapujya, toncic92, Arla, chx, Berdir: Boolean field with #access FALSE cause EntityStorageException"
This reverts commit f4da72865ebbf41bd6da6a5f1070b0bae98bcf31.
-rw-r--r--core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php4
-rw-r--r--core/modules/field/src/Tests/Boolean/BooleanFieldTest.php69
-rw-r--r--core/modules/field/tests/modules/field_test_boolean_access_denied/field_test_boolean_access_denied.info.yml8
-rw-r--r--core/modules/field/tests/modules/field_test_boolean_access_denied/field_test_boolean_access_denied.module20
4 files changed, 2 insertions, 99 deletions
diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
index b5182bc..2ea450d 100644
--- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
+++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
@@ -1257,9 +1257,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
foreach ($storage_definition->getColumns() as $column => $attributes) {
$column_name = $table_mapping->getFieldColumnName($storage_definition, $column);
// Serialize the value if specified in the column schema.
- $value = drupal_schema_get_field_value($attributes, $item->$column);
- $record[$column_name] = !empty($attributes['serialize'])
- ? serialize($value) : $value;
+ $record[$column_name] = !empty($attributes['serialize']) ? serialize($item->$column) : $item->$column;
}
$query->values($record);
if ($this->entityType->isRevisionable()) {
diff --git a/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php b/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php
index 5fa491b..30f67d1 100644
--- a/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php
+++ b/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php
@@ -20,12 +20,7 @@ class BooleanFieldTest extends WebTestBase {
*
* @var array
*/
- public static $modules = [
- 'entity_test',
- 'field_ui',
- 'options',
- 'field_test_boolean_access_denied',
- ];
+ public static $modules = array('entity_test', 'field_ui', 'options');
/**
* A field to use in this test class.
@@ -184,66 +179,4 @@ class BooleanFieldTest extends WebTestBase {
$this->assertFieldById('edit-settings-off-label', $off);
}
- /**
- * Test field access.
- */
- public function testFormAccess() {
- $on = 'boolean_on';
- $off = 'boolean_off';
- $label = 'boolean_label';
- $field_name = 'boolean_name';
- $this->fieldStorage = FieldStorageConfig::create([
- 'field_name' => $field_name,
- 'entity_type' => 'entity_test',
- 'type' => 'boolean',
- ]);
- $this->fieldStorage->save();
- $this->field = FieldConfig::create([
- 'field_name' => $field_name,
- 'entity_type' => 'entity_test',
- 'bundle' => 'entity_test',
- 'label' => $label,
- 'settings' => [
- 'on_label' => $on,
- 'off_label' => $off,
- ],
- ]);
- $this->field->save();
-
- // Create a form display for the default form mode.
- entity_get_form_display('entity_test', 'entity_test', 'default')
- ->setComponent($field_name, [
- 'type' => 'boolean_checkbox',
- ])
- ->save();
-
- // Create a display for the full view mode.
- entity_get_display('entity_test', 'entity_test', 'full')
- ->setComponent($field_name, [
- 'type' => 'boolean',
- ])
- ->save();
-
- // Display creation form.
- $this->drupalGet('entity_test/add');
- $this->assertFieldByName("{$field_name}[value]");
-
- // Should be posted OK.
- $this->drupalPostForm(NULL, [], t('Save'));
- preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
- $id = $match[1];
- $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
-
- // Tell the test module to disable access to the field.
- \Drupal::state()->set('field.test_boolean_field_access_field', $field_name);
- $this->drupalGet('entity_test/add');
- // Field should not be there anymore.
- $this->assertNoFieldByName("{$field_name}[value]");
- // Should still be able to post the form.
- $this->drupalPostForm(NULL, [], t('Save'));
- preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
- $id = $match[1];
- $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
- }
-
}
diff --git a/core/modules/field/tests/modules/field_test_boolean_access_denied/field_test_boolean_access_denied.info.yml b/core/modules/field/tests/modules/field_test_boolean_access_denied/field_test_boolean_access_denied.info.yml
deleted file mode 100644
index d1b578f..0000000
--- a/core/modules/field/tests/modules/field_test_boolean_access_denied/field_test_boolean_access_denied.info.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-name: 'Boolean field Test'
-type: module
-description: 'Support module for the field and entity display tests.'
-core: 8.x
-package: Testing
-version: VERSION
-dependencies:
- - field
diff --git a/core/modules/field/tests/modules/field_test_boolean_access_denied/field_test_boolean_access_denied.module b/core/modules/field/tests/modules/field_test_boolean_access_denied/field_test_boolean_access_denied.module
deleted file mode 100644
index be56c37..0000000
--- a/core/modules/field/tests/modules/field_test_boolean_access_denied/field_test_boolean_access_denied.module
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/**
- * @file
- * Helper module for the boolean field tests.
- *
- * @see \Drupal\field\Tests\Boolean\BooleanFieldTest::testFormAccess()
- */
-
-use Drupal\Core\Access\AccessResult;
-use Drupal\Core\Field\FieldDefinitionInterface;
-use Drupal\Core\Field\FieldItemListInterface;
-use Drupal\Core\Session\AccountInterface;
-
-/**
- * Implements hook_entity_field_access().
- */
-function field_test_boolean_access_denied_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
- return AccessResult::forbiddenIf($field_definition->getName() === \Drupal::state()->get('field.test_boolean_field_access_field'));
-}