There are some incomplete sections of the state machine views integration. That is currently blocking a fix to a workbench moderation view #1966908: Fix broken view

This patch allows for joins to the node table through {state_flow_history} and it makes the handler state_flow_entity_handler_field_available_events functional again. (It's a handler that just prints links for available events) That handler still has @todos in it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stevector’s picture

stevector’s picture

Status: Active » Needs review
stevector’s picture

The previous patch didn't apply cleanly because of the ordering of some lines in the state_flow_entity.info file.

robeano’s picture

The patch in comment #3 does not apply cleaning to the .info file as well.

Steps to reproduce

* drush dl state_machine-7.x-3.x
* cd state_machine/
* patch -p1 < views-integration--state-machine-1966920-2.patch
Results when applying the patch:

patching file modules/state_flow/includes/views/state_flow.views.inc
patching file modules/state_flow_entity/includes/views/state_flow_entity.views.inc
patching file modules/state_flow_entity/includes/views/state_flow_entity_handler_field_available_events.inc
patching file modules/state_flow_entity/includes/views/state_flow_handler_available_events.inc
patching file modules/state_flow_entity/state_flow_entity.info
Hunk #1 FAILED at 15.
1 out of 1 hunk FAILED -- saving rejects to file modules/state_flow_entity/state_flow_entity.info.rej

.rej file looks like this:

--- modules/state_flow_entity/state_flow_entity.info
+++ modules/state_flow_entity/state_flow_entity.info
@@ -15,9 +15,11 @@
 //files[] = tests/state_flow.test
 
 ; Views Handlers
+
 files[] = includes/views/state_flow_entity_handler_field_link.inc
 files[] = includes/views/state_flow_entity_handler_field_state.inc
 files[] = includes/views/state_flow_entity_handler_field_state_flow_states.inc
 files[] = includes/views/state_flow_entity_handler_field_events.inc
 files[] = includes/views/state_flow_entity_handler_field_events_form.inc
-files[] = includes/views/state_flow_entity_handler_area_events_form.inc+files[] = includes/views/state_flow_entity_handler_area_events_form.inc
+files[] = includes/views/state_flow_entity_handler_field_available_events.inc

I applied the changes from the patch manually.

Test Results

* Created some Drafts
* View My Drafts tab

The links for changing state look great!

Unfortunately, I'm getting an error when viewing this tab:

Strict warning: Only variables should be passed by reference in state_flow_entity_handler_field_available_events->render() (line 29 of /stor/sandboxes/barre/wbm/www/sites/all/modules/state_machine/modules/state_flow_entity/includes/views/state_flow_entity_handler_field_available_events.inc).

* Moved some Drafts to Needs Review state
* View Needs Review tab

No revisions are displayed. Two errors are displayed and the State filter is highlighted in red:

Notice: Undefined index: #contextual_links in contextual_pre_render_links() (line 140 of /stor/sandboxes/barre/wbm/www/modules/contextual/contextual.module).
Warning: Invalid argument supplied for foreach() in contextual_pre_render_links() (line 140 of /stor/sandboxes/barre/wbm/www/modules/contextual/contextual.module).

I made sure to clear cache. Does this patch rely on another one?

stevector’s picture

Try git apply instead of patch -p1 <

This patch should fix that pass-by-reference error.

The State Filter highlighted in red is likely because you don't have a Needs Review state on your test site. That's part of the default setup of Workbench Workflows that show up on admin/reports/status

I'm not sure where the contextual_pre_render_links error is coming from.

robeano’s picture

Status: Needs review » Reviewed & tested by the community

The patch views-integration--state-machine-1966920-5.patch applies cleanly when I checkout from git and use git apply for the patch.

The contextual_pre_render errors went away after clearing the cache with the latest patch. PASSED!

Sure enough, when I added a Needs Review state to the workflow, the error on Needs Review went away. PASSED!

Code Review: In general, the code looks fine. If you really wanted to, you could add a docblock for the class in the plugin:

class state_flow_entity_handler_field_available_events extends views_handler_field {

in state_machine/modules/state_flow_entity/includes/views/state_flow_entity_handler_field_available_events.inc

It's fine if you commit it as is.

stevector’s picture

Status: Reviewed & tested by the community » Fixed
stevector’s picture

Status: Fixed » Needs review
FileSize
1.61 KB

I'm getting duplicate records in the workbench moderation view. See http://drupal.org/node/1966908#comment-7310210

Here's a fix that allow the joins to be set more explicitly.

robeano’s picture

Status: Needs review » Reviewed & tested by the community

Works for me. I saw the duplicates in My Drafts for example. I applied the patch and cleared the cache, but I still saw the dupes. I updated the node which had multiple records in My Drafts, then the duplicates went away. PASSED! This patch looks good and should be committed.

stevector’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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