Well.. I'm following the code here in order to explain it

Easiest case is to explain it is using scheduled transitions when executed by cron.

So let's say we have a scheduled transition and it's the proper time for it to be executed:

First of all, in hook_cron, scheduled transitions are set to be forced, but a $forced variable is not set in workflow_execute_transition.

      $scheduled_transition->force(TRUE);
      workflow_execute_transition($entity_type, $entity, $field_name, $scheduled_transition);

In workflow_execute_transition function if "force" is not set as variable it's considered false:
function workflow_execute_transition($entity_type, $entity, $field_name, $transition, $force = FALSE)

In workflow_execute_transition if force is set to TRUE, transition is set to true as well, but if not nothing happens (that's the first point where transitions force variable could have been taken into account)

  if ($force) {
    $transition->force($force);
  }
    $new_sid = $transition->execute($force = TRUE);

Now, following the code, I see the same pattern in "execute" function:

  public function execute($force = FALSE) {

....

    if ($force) {
      $this->force($force);
    }

But the rest of the execution considers "$force" as the transition force variable and completely ignores is transition is otherwise set to be forced.

Proposed Solution:
1.
Maybe in hook cron, the line should change from
workflow_execute_transition($entity_type, $entity, $field_name, $scheduled_transition);

to:
workflow_execute_transition($entity_type, $entity, $field_name, $scheduled_transition,TRUE);

(so the $force variable would pass as TRUE until execution).

2.
Another option (and possibly better in my opinion is than in execute function transition's force variable should be taken into account by adding this line after (possibly) setting the force variable in transition:
$force = $this->isForced();

3. Both the above.. Maybe because they could be 2 different cases where this might matter.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Zekvyrin created an issue. See original summary.

Zekvyrin’s picture

And here is a patch containing both the proposed solutions.

Zekvyrin’s picture

Status: Active » Needs review

  • johnv committed b610ddf on 7.x-2.x authored by Zekvyrin
    Issue #2805217 by Zekvyrin: Transition's "force" property is not taken...
johnv’s picture

Thanks. See also the other issue.

johnv’s picture

Version: 7.x-2.x-dev » 7.x-2.8
Status: Needs review » Fixed
johnv’s picture

Version: 7.x-2.8 » 8.x-1.x-dev
Status: Fixed » Patch (to be ported)

Let's check if this is needed in D8 version.

  • johnv committed 80baf35 on 8.x-1.x authored by Zekvyrin
    Issue #2805217 by Zekvyrin: Transition's "force" property is not taken...
johnv’s picture

Version: 8.x-1.x-dev » 7.x-2.8
Status: Patch (to be ported) » Fixed

OK, fixed over there, too.

Status: Fixed » Closed (fixed)

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