The latest update to Workflow has caused this error to appear while Rules tried to intervene in a state change:
Fatal error: Call to undefined method stdClass::value() in /home/user/public_html/sites/all/modules/workflow/workflow_rules/workflow_rules.rules-callback.inc on line 111

I double checked the rule's validation to see if any configuration changes were needed and rules says the rule is still valid.

An exported version of this rule that is experiencing this problem is as follows

{ "rules_set_vua_draft_from_issued_state" : {
    "LABEL" : "Set VUA Draft from Issued State",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "workflow_rules" ],
    "ON" : { "workflow_state_changed" : [] },
    "IF" : [
      { "workflow_check_transition" : {
          "node" : [ "node" ],
          "old_state" : { "value" : { "5" : "5" } },
          "new_state" : { "value" : { "6" : "6" } }
        }
      }
    ],
    "DO" : [
      { "workflow_rules_set_state" : {
          "node" : [ "node" ],
          "workflow_state" : { "value" : { "4" : "4" } },
          "workflow_comment" : "A new version of the Venue Usage Agreement is in the process of being drafted because of a recent change request or an error was found in the current version."
        }
      }
    ]
  }
}

As a result of this my immediate solution was to revert to 7.x-2.3.

Comments

rbrownell’s picture

I can also confirm that this is an issue in 7.x-2.3-beta3

rbrownell’s picture

Title: Updates Breaks Rules » Rules Error: Call to undefined method stdClass::value() line 111

Updated title to be more specific.

rbrownell’s picture

Title: Rules Error: Call to undefined method stdClass::value() line 111 » Rules Error: Call to undefined method stdClass::value() workflow_rules.rules-callback.inc line 111
johnv’s picture

Are you using Workflow Node?

rbrownell’s picture

johnv: Yes

bharathkumarkn’s picture

Subscribing

doxigo’s picture

I managed to reproduce this issue with a slightly different rule, this only happens in 7.x-2.4 when there's a permission issue, for instance if you set a rule to change the state of workflow but the system doesn't have the proper permission to do such transition, we end up with this error,
but in case of 7.x-2.3 version, the module returns a Error Message saying that the transition is not possible, which is the right thing to happen.

I assume it's a small bug regarding how to produce the Error message in 7.x-2.4 version.

derekw’s picture

Not a permission issue... the code comments specifically say the action is for forcing a transition.

The reason the ->value() and ->type() functions aren't working is that the node isn't wrapped.

Since it appears the code is set up for a wrapped entity and not a node, I changed:

workflow_rules.node.inc

118: 'type' => 'node',

to
workflow_rules.node.inc

118: 'type' => 'entity',

Then flushed the cache, edited my Set Workflow State action (which now asks for Entity vs Content), and it all works.

mgadrat’s picture

Well that seems to do the trick... patch?

johnv’s picture

#8 is not the answer, since it will break allcurrent implementations in the wild. ( that will be a lot since this is for WorkflowNode).

I am planning to wrap the node explicitely in an entitywrapper. Would that do the trick?

mgadrat’s picture

I am planning to wrap the node explicitely in an entitywrapper. Would that do the trick?

Yeah I guess this is a good idea.
Would you use something like: entity_metadata_wrapper() in the _workflow_rules_set_state function?

johnv’s picture

Yes. Dou you have a patch ready? :-)

mgadrat’s picture

Haha no but I could look into that later today ;)

mgadrat’s picture

Sorry, can't do today, It'll go to next week...

doxigo’s picture

I had to use workflow 7.x-2.3 instead of the latest version because of this issue, it would be really nice if we can get this thing fixed and have the patch applied to the latest recommended version.

johnv’s picture

Forget my comment #10. the patch in #9 is fine. I'll commit something shortly. This is a regression issue, as doxigo nicely points out. Thanks doxigo. It helped finding the root cause.

  • johnv committed ec553b4 on 7.x-2.x
    Issue #2304365 by mgadrat: Fixed error in Rules 'Set workflow value'...
johnv’s picture

Status: Active » Fixed

This is now fixed using #8. The problem was a change that was OK for Workflow Field, but broke Workflow Node.

rbrownell’s picture

Thank you johnv!

doxigo’s picture

Thank you john for fixing it

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

pianomansam’s picture

Version: 7.x-2.4 » 7.x-2.x-dev

This issue is still found in 7.x-2.4 and has only been committed to 7.x-2.x, so I'm updated the version information to reflect that. Otherwise, someone might repeat the mistake I just made in thinking that 7.x-2.4 doesn't have this bug when in fact it does.

johnv’s picture

Version: 7.x-2.x-dev » 7.x-2.4

Well, yes. It is hapenning in 2.4 and fixed in the next available version.

pianomansam’s picture

I realize that it's happening in 2.4. But the standard way of handling bug reports on Drupal.org is to advance the bug report to the latest release it is reported in. In this case, it is 2.x-dev