I'm using workflow on my site, and even though I don't have comments selected as using my workflows, when I go to view any given page using the default workflow I've created, the comments at the bottom all have workflow choices. See http://i.imgur.com/B6VxN.png for a screenshot.

Apologies if I'm misunderstanding features or I've missed another report on this.

Comments

julienjoye’s picture

StatusFileSize
new51.18 KB

Hi !

Same issue here.
I solved that problem by replacing in workflow.module this line (l.589) :
if (isset($form['#node'])) {
By this one :
if ($form_id == $form['#node']->type . '_node_form') {

Btw I replaced the comment line (l.599) :
// Abort if user does not want to display workflow form on node editing form.
By that :
// Abort if user does not want to display workflow form on comment form.

Regards.

julienjoye’s picture

Status: Active » Needs review
Vidus’s picture

Thanks! Good to know I wasn't the only one having the issue. And DOUBLE thanks for the fix.

drbartje’s picture

I am by no means a PHP expert but I think (regardless of this issue) the first 'if' in 'workflow_form_alter' that now reads:

if ((isset($form['#node']) && $form_id == 'comment_node_' . $form['#node']->type . '_form')
|| (isset($form['#node']->type) && isset($form['#node']) && $form['#node']->type . '_node_form' == $form_id)) {
 

should be re-written to something like:

if ((isset($form['#node'])) && (isset($form['#node']->type)) && (($form_id == 'comment_node_' . $form['#node']->type . '_form') || ($form_id == $form['#node']->type . '_node_form'))) {

The second 'if' is superfluous as the first one already checked if $form['#node'] is set (and therefore the 'else' part will never be triggered.

I don't think the solution proposed above is the right one. I've changed my installation as follows:

  if ((isset($form['#node'])) && (isset($form['#node']->type))) {
    $iscomment = ($form_id == 'comment_node_' . $form['#node']->type . '_form');
    $isnode =  ($form_id == $form['#node']->type . '_node_form');
  } else {
    return;
  }
  if ($isnode || $iscomment)  {
      $node = $form['#node'];
      // Abort if user does not want to display workflow form on node editing form.
      if ($isnode && (!in_array('node', variable_get('workflow_' . $form['#node']->type, array('node'))))) {
        return;
      }
      // Abort if user does not want to display workflow form on comment form.
      if ($iscomment && (!in_array('comment', variable_get('workflow_' . $form['#node']->type, array('node'))))) {
        return;
      }

drbartje’s picture

Looking at the definition of variable_get I think

if ($isnode && (!in_array('node', variable_get('workflow_' . $form['#node']->type, array('node'))))) {

may just need to be

if ($isnode && (!in_array('node', variable_get('workflow_' . $form['#node']->type)))) {

as I am not sure why you would provide a default value in this case.

ttkaminski’s picture

StatusFileSize
new6.21 KB

@DrBartje - I think you've got the right idea and I'm pretty sure your code works. I've rewritten it, and attached it as a patch. In my version, I removed isset($form['#node']->type) since if the node object exists, then it should have a type. If it doesn't then it's a bug somewhere else. My version also removes duplicate/redundant code, so as it make it more maintainable.

Frederic wbase’s picture

I've tested the patch from ttkaminski and it seems to work just fine!
Thanks for your work!

grts

fre

spgd01’s picture

Version: 7.x-1.0 » 7.x-1.x-dev

tested patch and it works so far

haggan’s picture

Works good for me also!

pumpkinkid’s picture

Works here as well!

gkom’s picture

Working well here too! Thank you

akalata’s picture

Status: Needs review » Reviewed & tested by the community

#7 RTBC?

nancydru’s picture

Is this still a problem in the current -dev release? Workflows are no longer tied to the comment form.

nancydru’s picture

Status: Reviewed & tested by the community » Closed (works as designed)

If someone checks back in and finds this still an issue, reopen it.

justanothermark’s picture

Status: Closed (works as designed) » Needs review
StatusFileSize
new1.91 KB

I was also having this problem in the latest dev version for D7 and have attached a patch to fix it.

The attached patch is simpler than the one in #7 so is less likely to affect other behaviour. It should also apply cleanly to latest dev version as the patch in #7 is now outdated due to other changes.

justanothermark’s picture

Same patch as #16 with unnecessary assignment removed.

nancydru’s picture

Mark, why is the terminal state check being deleted?

justanothermark’s picture

I'm not sure what you mean by 'terminal state check' but in the original code the if & the else were doing the same thing:

  • Load node.
  • Get variable 'workflow_' . $node->type.
  • Check whether 'node' or 'comment' was in the variable.

Load node is now done in the shorthand if just in case the node isn't in $form['#node'] (although I'm not sure when it wouldn't be).

Loading the variable was the same but was getting type from different places because of how the $node was loaded so these lines are now the same with a consistent $node before.

Checking for node/comment in the variable can be simplified because $form['#entity_type'] is already set to node/comment for us.

nancydru’s picture

There was a check to see if any states were available and skipping the form if not. That was to check if the node was at the last, or terminal, state.

justanothermark’s picture

Do you mean this bit of code:

// Stop if user has no new target state(s) to choose.
if (count($choices) < $min) {
  return;
}

This patch doesn't do anything with that code so it should still be there after the patch is applied.

nancydru’s picture

Status: Needs review » Fixed

Committed with attribution. Thanks for the patch.

Status: Fixed » Closed (fixed)

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