Hi @all,

The Problem

When a user is creating a node and the node has a field where the user has no access to create/edit it, this field will not be displayed in the form and it will be populated with the default value. But if the field is translatable the default value is ignored.

Steps to reproduce the bug:

  • Create a field with restricted access for creation (e.g. using field_permissions module)
  • Define a default value for this field
  • Set this field translatable (e.g. using entity_translation module)
  • Create a node of the certain type with a user who has not the permission to create the 'privete' field

You will see a notice:

Notice: Undefined property: stdClass::$field_private in locale_field_node_form_submit() (line 409 of /opt/lampp/htdocs/drupal7/modules/locale/locale.module).

And this 'private' field will not have any value.

As soon as you make the field not translatable and the same user creates a new node, the 'private' field will have the default value and there will not be any notice.

Hope someone could take a look at this.
Thanks.

Comments

Zgear’s picture

I couldn't reproduce the error, or the situation for it to occur under because the directions are slightly unclear. Please clarify "Create a node of the certain type with a user who has not the permission to create the 'privete' field"

xjm’s picture

Status: Active » Postponed (maintainer needs more info)
xjm’s picture

Also, this might be better filed against one of the contributed modules you mention (often error messages like the one you see are due to contrib modules passing incomplete data to core API functions). So I'd suggest determining which module is required for the issue, and changing the project to that module.

braindrift’s picture

Hi,

thanks for the reply.

@Zgear: First you need to define a text field (e.g. name: "field_private") lets say in the content type: Basic page. In the field creation form define a default value for this field. Than you have to mark this new field as translateable (e.g. using entity_translation module or simply by hacking the DB-Table field_config). Than create a user, lets say Thomas. Give Thomas the permission to create nodes of type "Basic page". Restrict edit-access for the field "field_private" so that Thomas does not see this field when creating the node of type "Basic page" (by implementing the hook_field_access in your own module or use field_permissions module). Now login as Thomas and create a node of type "Basic page". After Thomas saves the node, he gets:
Notice: Undefined property: stdClass::$field_private in locale_field_node_form_submit() (line 409 of C:\xampp\htdocs\drupal7\modules\locale\locale.module).
Now login as admin (user-1) and edit the node created by Thomas. You will see, that the field "field_private" is empty. I would expect that the field has the defined default value.

@xjm: I don't think that the missfunction is in a contributed module because you do not need to use one. I reproduced this error on a fresh drupal deployment. The only module I activated additionally is the one (written by myself) that implements the hook_field_access.
Hook code:

function private_field_field_access($op, $field, $entity_type, $entity, $account){
	global $user;
	if($op == 'edit' && !isset($entity->nid) && $field['field_name'] == 'field_private' && $user->uid != 1){
		return false;
	}
}

Hope this was clearly enough.

Thanks,
dendie

braindrift’s picture

Status: Postponed (maintainer needs more info) » Active
braindrift’s picture

Nobody there who can reproduce the bug?

braindrift’s picture

Issue summary: View changes

typo

Version: 7.7 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.