- πΊπΈUnited States bluegeek9
Field Permissions does not support Drupal 7.
I saw a warning like this in my watchdog, from a node form preview request:
Warning: Illegal string offset 'value' in some_custom_function_with_date_field()
.
I did some debugging, and found this:
In a node preview, field items for display are built from form values.
If this happens with
- a date field protected by field permissions
- for a user who has no access to this field,
then the field items will contain one non-array item, where the value is just an empty string.
So, the result of field_get_items('node', $node, 'field_some_date') items might be sth like this:
array(
'und' => array(
0 => array('value' => .., 'value2' => .., 'timezone' => .., '..),
1 => '',
),
)
The items are collected in field_default_extract_form_values(), and later filtered in _field_filter_items() via hook_field_is_empty().
To make the problem complete, date_field_is_empty() returns FALSE for non-array items, to support a weird case where the item is an object.
function date_field_is_empty($item, $field) {
// Sometimes a $item is a date object.
// Coming from repeating dates. Why??
if (!is_array($item)) {
return FALSE;
}
If these field items are used anywhere during the preview via $item['value'], while $item === ''
, then you get "illegal string offset".
This is all a bit weird, but I suspect it is thanks to field_permissions that the form value for the field item is an empty string.
Closed: outdated
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Field Permissions does not support Drupal 7.