Skip to content

Warning if using sub-property on empty field in publicFieldsInfo() #13

@rroblik

Description

@rroblik

There is a lot of warnings if we are mapping a field and using sub-propertyon it if this field is empty. As we speak about search results, some entities (nodes) can have optional(s) field(s), and some of them on some entities can be empty.

Message (watchdog) :
Notice : Undefined index: und in RestfulDataProviderSearchAPI->mapSearchResultToPublicFields() (line 344 in /xxx/sites/all/modules/contrib/restful_search_api/include/RestfulDataProviderSearchAPI.php).

Example :

public function publicFieldsInfo() {
    $fields_info = array(
      'illustration' => array(
        'property' => 'field_content_picture',
        'sub-property' => LANGUAGE_NONE . '::0',
      ),
      // ...
    );

    return $fields_info;
}

This example throw warning if in one (or more) result, the field_content_picture is empty.

In mapSearchResultToPublicFields(), existence of field / key in set of results should be done to avoid that.

Regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions