Problem/Motivation

Using field permissions 8.x-1.0-beta1. When using custom permissions for a boolean field, an exception is thrown when a user with no permissions for the boolean field attempts to create content which contains this boolean field. Here is the exception:

Drupal\Core\Entity\EntityStorageException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'field_test_boolean_value' at row 1: INSERT INTO {node__field_test_boolean} (entity_id, revision_id, bundle, delta, langcode, field_test_boolean_value) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 10 [:db_insert_placeholder_1] => 39 [:db_insert_placeholder_2] => article [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => en [:db_insert_placeholder_5] => ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 770 of /var/www/build/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Steps to reproduce:
1. Add a boolean field to a node bundle, e.g. Article.
2. Set custom permissions on the boolean field. Give no access to the field except for admin role.
3. Log in as a user without an admin role, and has permission to create an Article, and attempt to create an Article.
4. Exception is thrown when saving.

If the user has permission to create a value for this boolean field, then it's fine for content creation, but defeats the purpose, since this field is now visible, and the point of not giving permission to the field was so they could not see or set a value for the field. Even if you give the create permission as a workaround, the problem will surface again if the user has permissions to edit the content, and no permission to edit the boolean field, as it will throw a similar exception about not being able to insert an empty string where it expects an integer value.

Custom field permissions appear to work just fine for other field types.

Proposed resolution

I haven't had time to debug this, my guess is that since it's a boolean field the database expects something to get set.

Remaining tasks

Debug, patch.

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

mroycroft created an issue. See original summary.

mroycroft’s picture

Issue summary: View changes
davisa’s picture

I can confirm this issue.

acy76’s picture

brenk28’s picture

Status: Active » Closed (won't fix)

The patch referred to in #4 (which has been rolled into latest core release) fixes this issue.