Hi

When adding a state and clicking "Save Changes" I get the following error for each state:

Strict warning: Only variables should be passed by reference in workflow_get_workflow_states_by_sid() (line 1334 of /sites/all/modules/workflow/workflow.module).

Not sure what the full impact of this error is.

Comments

nancydru’s picture

What version of PHP are you using? I do not see this on 5.3.13.

robin.prieschl’s picture

I am using PHP 5.4.4.

I have just noticed that when I add a transition, the error goes away.

nancydru’s picture

I'll see if I can try 5.4. There are many modules, including core, that have issues with 5.4.

robin.prieschl’s picture

You are right, I have changed to PHP 5.3.14 and the error no longer appears.

Seems to only affect 5.4.

nancydru’s picture

Hmm, $sids[$sid] = array_shift(workflow_get_workflow_states($options)); looks to me like a variable is being passed. Or is it complaining that the $options array was passed into the function? If that's the case, try putting an & on it and see if the issue goes away.

function workflow_get_workflow_states_by_sid($sid, &$options = array()) {
robin.prieschl’s picture

I have made the change. Unfortunately the error still comes up when I save changes.

Is anyone else having the same problem, or am I alone on this one.

nancydru’s picture

There probably aren't that many people on 7.x-1.1 yet, others may still experience it. Are you using PHP's STRICT error level?

robin.prieschl’s picture

PHP's STRICT was not enabled.

Enabling it yielded no difference.

I think for now I will run PHP 5.3.14.

phiscock’s picture

I'm getting this error as well running PHP 5.3.9

santimt’s picture

I had the same warning under PHP 5.4.13.
I fixed it with the following PHP change:

Change the line 1334 of workflow.module file to

$arrayVar = workflow_get_workflow_states($options);
$sids[$sid] = array_shift($arrayVar);

That is create a variable with the function return value, and use that variable instead of the function as the parameter of array_shift.
Reason of the warning http://stackoverflow.com/questions/2354609/strict-standards-only-variabl...

It's just a warning in the STRICT logging mode.

andypost’s picture

Status: Active » Needs review
StatusFileSize
new495 bytes

We have this pattern all over core. So simple to fix

andypost’s picture

StatusFileSize
new554 bytes

A bit more clean-up

nancydru’s picture

Status: Needs review » Fixed

Committed with attribution. Thanks, Andy.

crbassett’s picture

I'm on Workflow 1.1 and PHP 5.4.6 and I'm still getting this error. Do I need to update to the dev version?

nancydru’s picture

Yes. Once a release is published, it can no longer be changed. That's why we show -dev releases. I'm hoping to create a 7.x-1.2 release soon.

Status: Fixed » Closed (fixed)

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

a.milkovsky’s picture

Andrey, thx for the #11, I made the same fix.