Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Cron problems with the fatal error. I would need to know how to avoid.
"NOTICE: PHP message: PHP Fatal error: Call to a member function getTransitionsBySidTargetSid() on boolean in /var/www/drupal/sites/all/modules/workflow/includes/Entity/WorkflowTransition.php on line 207"
Comment | File | Size | Author |
---|---|---|---|
#7 | workflow-php_fatal_error_call-2499193-7-2.x.patch | 1.16 KB | kasperg |
#7 | workflow-php_fatal_error_call-2499193-7-2.5.patch | 1.29 KB | kasperg |
Comments
Comment #1
johnvIs this with a scheduled transition?
Do you use Workflow_node or Workflow_field?
Comment #2
renzomb CreditAttribution: renzomb commentedwell , first i used workflow_field , this breaks all, so i used the workflow node and that fixed this.
Comment #3
johnvHmm, would you be able to try it again with latest dev-version and workflow_field?
If not, please close the issue. I cannot reproduce it.
Comment #4
thomasmurphy CreditAttribution: thomasmurphy commentedI'm using workflow field and I got this error when attempting to make a change to content with a non-scheduled workflow field. I don't see anything related to cron with this error, though.
Comment #5
kasperg CreditAttribution: kasperg at Reload commentedI have experienced this error as well when doing a programmatic update of a node with a workflow field. In our situation it is caused by a a scheduled unpublication of the node using Scheduler.
Here
workflowfield_field_update()
is called with an empty$items
argument. As there is no sid present to transition to Workflow tries to determine the first state. If this happens during cron there is no user present and consequently no permissions to access the creation state and 0 is returned.This value is passed through the code until the WorkflowTransition class tries to get the workflow based on the new sid. null is returned and the fatal error occurs.
Comment #6
kasperg CreditAttribution: kasperg at Reload commentedThere seems to be multiple ways to go about fixing this. Here is one approach:
When getting a transition to a non-existing sate, 0 is used as the new state id. This causes a fatal error when the transition attempts to retrieve the corresponding workflow as sid 0 does not correspond to a workflow.
Use the old state id to retrieve the workflow instead. That should ensure that the workflow exists. Performing the transition will fail more elegantly later on.
Also log the state to watchdog instead of setting a message. That makes cron fail.
Comment #7
kasperg CreditAttribution: kasperg at Reload commentedI tested this in 7.x-2.x and the problem is fixed there.
Here are two patches:
$items
. According to the API this should unset the field but I do not think this makes sense for workflows. It does not seem to be supported in the code anyhow.Comment #8
johnv@kasperg, since the problem is solved, in the other issue, I am going to close this issue.
Your patch would be helpful for people who experience the problem, and do not want to dus the dev version.
Normally, you'd use dev version, or wait for 2.6.
Thanks.