I am attempting to create a block of nodes with a specific workflow state. When adding a workflow state filter in views, the workflow state always shows as unknown even if one or more states have been selected. A screenshot of the filter section of my view is attached which shows the (in Unknown) in the filter. Unfortunately, the view will not save in this state. Interestingly enough the query seems to be picking up the selection:

SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created
FROM 
{node} node
LEFT JOIN {workflow_node} workflow_node ON node.nid = workflow_node.nid
WHERE (( (node.status = '1') AND (node.type IN  ('referral')) AND (workflow_node.sid =  '6') ))
ORDER BY node_created DESC
LIMIT 5 OFFSET 0
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joel_osc’s picture

Issue summary: View changes

fixed grammar...ugh.

Bastlynn’s picture

Status: Active » Closed (cannot reproduce)

Unfortunately I wasn't able to replicate this one. I did put in some fixes in the dev branch for filtering the available states by active/inactive state that may have been contributing to how your setup got to this point.

You may need to clear cache to get Views to pickup the Workflow related features.

Otherwise I'm going to close it - but if you can show me how to replicate this, then I'll be glad to take a second look.

joel_osc’s picture

Status: Closed (cannot reproduce) » Active

I have figured out that you need to have two workflows created to reproduce this problem. So the easiest steps would be:

1. Add a workflow called 'workflow-1'
- add state test1
2. Add a workflow called 'workflow-2'
- add state test2
3. Enable workflow-1 on Basic Page
4. Create a view of content type Basic Page
- add filter workflow current state = test1

...and that should do it. If you delete 'workflow-2' the problem goes away. Another funny thing is that if you go to add back 'workflow-2' you get an error that it already exists.

Let me know if this helps. Cheers and thanks for the awesome module.

dylanhuang’s picture

workflow-7.x-1.x-dev:
The issue cause by "workflow_views_handler_filter_sid.inc" this file:
if (count($workflows) > 1) {
$states = array('' => t('No state'));
foreach ($workflows as $wid => $name) {
foreach (workflow_get_workflow_states_by_wid($wid, $options) as $state) {
$states[$name][$state->sid] = check_plain($state->state);
}
}
}
else {
foreach (workflow_get_workflow_states($options) as $state) {
$states[$state->sid] = check_plain($state->state);
}
}

Only change $states[$name][$state->sid] = check_plain($state->state) to
$states[$name][$state->sid] = check_plain($name . ': ' .$state->state) this issue can be fixed.

Because in the "views-7.x-3.0" module, file "views_handler_filter_in_operator.inc" function "admin_summary" line 300 to line 309
foreach ($this->value as $value) {
if (!isset($this->value_options[$value])) {
unset($this->value[$value]);
}
}
// Choose different kind of ouput for 0, a single and multiple values.
if (count($this->value) == 0) {
$values = t('Unknown');
}

The workflow get_value_options() function's return is not a pure array, so the below statement will unset the states which have been selected.
if (!isset($this->value_options[$value])) {
unset($this->value[$value]);
}

dylanhuang’s picture

Sorry,
Only change $states[$name][$state->sid] = check_plain($state->state) to
$states[$state->sid] = check_plain($name . ': ' .$state->state) this issue can be fixed.

joel_osc’s picture

The fix in #4 works perfectly. Thank-you.

dozymoe’s picture

Status: Active » Needs review
FileSize
767 bytes

Another +1 for the fix at #4.

And the patch with no other changes made, except the fix in #4.

Changing the status to need review??

Bastlynn’s picture

Status: Needs review » Closed (fixed)

Looks good to me. If someone comes up with a follow up patch to preserve the pretty select drop down I'll gladly take it, but I'd rather an ugly display than having a mystery "Unknown" in the configuration display.

Patch applied to the 7.x branch.

Bastlynn’s picture

Issue summary: View changes

removed strong from code section