I tagged this on the end of Compatibility with Workflow 2.5 API changes but since that issue is closed I thought I'd better make a new one instead. Hope this is OK.

Notice: Trying to get property of non-object in workflow_fields_field_access() (line 604 of [..]/sites/all/modules/workflow_fields/workflow_fields.module).

Line 604: $type_map = workflow_get_workflow_type_map_by_type($node->type);

Issue is when entity_type is "profile2" or using node/entity reference fields to node/entity that don't have workflows and $node is NULL.

NB: $entity (a.k.a. $node in the module code) is actually optional in hook_field_access($op, $field, $entity_type, $entity, $account)
REF: https://api.drupal.org/api/drupal/modules!field!field.api.php/function/h...

In 7.x-1.0-beta1 lines 594-598 had the following

if ($entity_type == 'node' || !$node) {
    $sid = workflow_node_current_state($node);
    if (!$sid) {
      return TRUE;
    }

In 7.x-1.0-beta3 lines 588-590 this has been changed to:

if ($entity_type == 'node' || !$node) {
    $sid = NULL;
    $workflow_fields = array('');

Since line 604 in beta3 resets $sid to FALSE for fields without workflow anyway
$sid = workflow_node_current_state($node, 'node', $workflow_field_name);
Changing beta3 to:

if ($entity_type == 'node' || !$node) {
    $sid = workflow_node_current_state($node);
    if(!$sid){return;}
    $workflow_fields = array('');

stops the issue but does it impact adversely on the rest of the code?

As mentioned previously, I'm using Workflow 1.0 and the changes to the beta are for Workflow 2.0.

Comments

gramsuy’s picture

Hello,

Have you had any issue with this change?

Regards

pjurski’s picture

I tried this but it is still showing the same error message.