When using a view that lists nodes and uses the 'Workbench moderation: current' filter, not all content is shown. After changing the status of a node from 'Published' to 'Draft', this node will no longer be listed by the view.

Steps to reproduce
- Create a view that lists nodes and apply the 'Workbench moderation: current' filter
- Create a node with state 'Published'
- The view shows the node we just created
- Edit the node and change the state to 'Draft'
- Notice the problem: the view will no longer show the node we just edited

Proposed resolution

When looking at the query the view uses I noticed that a join happens on the vid column of the node table. The vid of the node table contains the vid of the revision that is currently published. The 'Workbench moderation: current' uses the current revision, which is not the same as the vid in the node table. Proposed resolution is to do a join on the nid column instead of the vid column.

#25 1361210-25-current_views_filter_join_nid.patch1.12 KBgrasmash
PASSED: [[SimpleTest]]: [MySQL] 137 pass(es). View
#12 1361210-12-current_views_filter_join_nid.patch646 bytesBevan
PASSED: [[SimpleTest]]: [MySQL] 137 pass(es). View
#5 workbench-moderation-current-views-filter-join-nid-1361210-5.patch553 bytesc31ck
PASSED: [[SimpleTest]]: [MySQL] 137 pass(es). View
#1 workbench-moderation-current-views-filter-join-nid-1361210-1.patch778 bytesc31ck
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch workbench-moderation-current-views-filter-join-nid-1361210-1.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots. View
Members fund testing for the Drupal project. Drupal Association Learn more


c31ck’s picture

778 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch workbench-moderation-current-views-filter-join-nid-1361210-1.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots. View

Patch that applies the proposed resolution.

stevector’s picture

Status: Active » Needs review

Status: Needs review » Needs work
stevector’s picture

Thanks for the patch c31ck! It failed testing because it was not made relative to the workbench_moderation directory. Please follow these instructions.

Also it looks like you are mixing your contrib modules with your core modules.

Core modules live in drupalroot/modules/
Contrib modules usually live in drupalroot/sites/all/modules/ or drupalroot/sites/default/modules/

This issue might also be related to #1300616: Node views with duplicate results when using fields from "workbench_moderate_node_history"

c31ck’s picture

Status: Needs work » Needs review
553 bytes
PASSED: [[SimpleTest]]: [MySQL] 137 pass(es). View

Uploaded the wrong patch here, having another go at this. I'm using a separate repository for my sites/all, which makes it look like I'm mixing core and contrib modules, but don't worry I'm not :)

stevector’s picture

Thinking about this more, I'm not sure this is a clear cut bug. The {workbench_moderation_node_history}* table is more concerned with vids than nids. If you are filtering for "current revision" I do not think it is appropriate to bring up non-current versions.

This gets at the question at the messy divisions, or lack thereof, between nodes and node revisions. We've got similar problems with #1240850: Publishing/Unpublishing a revision changes the author of that revision. #1307256: Timestamp bug when saving a new draft

It seems like changing the joins as your patch does would bring up every node on the site, or at least every node of type subject to moderation. If that's the case, why use this filter at all?

*edited name of table

c31ck’s picture

I'll explain what I am trying to achieve, to clarify the issue. I want to create an admin view that lists all the content in my site and show its current state (Published or Draft or ...). I want every node on my site to show up only once. I use the 'Workbench moderation: state' field to show the state.

Let's assume my site contains only 1 node: I create the node with state 'Published' and then create a new draft of this node.

If I create a view that shows the state without the current revision filter:
2 results are shown: a result with the Published state and a result with the Draft state. This is not what I want, I only want to show the node with its current status.

If I create a view with the current revision filter:
No results are shown. I would expect 1 result: the node with the Draft state (which is what this bug report is about).

Am I missing something here? Is the current revision filter not intended for this?

stevector’s picture

Yes, ok. You should use {node_revision} as the base table. I recommend cloning and modifying the View that comes with Workbench Moderation. You can do this at admin/structure/views/view/workbench_moderation/clone

rogical’s picture

The 'admin/structure/views/view/workbench_moderation' view is not showing right for the content title.

When I changed the title/content in draft, the view still only gets the published.

Any way, I failed to retrieve draft content in views after tried many times.

stevector’s picture

Category: bug » support
Status: Needs review » Closed (works as designed)

Thanks Rogical, The title field is coming from {node} instead of {node_revision}

I've opened a separate issue to resolve that: #1363990: The fields on the View workbench_moderation should use node_revision fields

Rogical and c31ck, if you're overriding that View anyway, you don't need to wait for a patch, just put in the different field. Reopen this issue if you've got any other questions on this topic.

nickgs’s picture

Thanks stevector,

I was trying to achieve the same solution and cloning the workbench_moderation view as outlined in #8 put me on the correct path.

It seems to be working good.

Thanks again.


Bevan’s picture

Title: 'Workbench moderation: current' views filter does not list all content » Views: JOIN node on nid, node_revision on vid
Version: 7.x-1.1 » 7.x-1.x-dev
Category: support » bug
Status: Closed (works as designed) » Needs review
646 bytes
PASSED: [[SimpleTest]]: [MySQL] 137 pass(es). View

Revision-views are not as well supported by other modules that extend views. For example Date module's field API fields are not exposed to views with node_revision as their base table; #1605342: Fields such as the Date fields can not be added to node_revision views.

Thus it is not possible to build a view which displays:

  1. Node ID and/or title
  2. Node's published status
  3. Current revision's WB state
  4. A Field API Date field

without excluding nodes with a current revision vid that is different to it's published revision vid.

This could be fixed by patching all the modules which lack support for node_revisions.

However joining on nid instead of vid for the node table only does not break anything, does it? And in fact it makes things more flexible. The node_revision table still joins on vid for node_revision-based views. By joining on nid (for node views), more flexibility and options are made available.

Bevan’s picture

#1633534: Views relationship for revision allows such a view to get some fields from the current revision and other fields from the published revision.

zifiniti’s picture

I've implemented Bevan's patch and I must say, it seems like this is the way it should function. Joining on the node.vid doesn't seem right considering WBM has a different perspective on which revision is current.

Frederic wbase’s picture

Thanks for your patch Bevan, it works like a charm, and this was the desired behavior i was looking for.

@module maintainer, will this be commited?

iStryker’s picture

Status: Needs review » Closed (duplicate)

See #1782172: In views 3.5 Title etc are not showing anymore where I have implemented #12 as well as created a new relationship to the node. I'm marking this as a duplicate as this is required component to get workbench moderation working with Views 7.x-3.5.

wickwood’s picture

Title: Views: JOIN node on nid, node_revision on vid » 'Workbench moderation: current' views filter does not list all content
Status: Closed (duplicate) » Needs review

I'm reopening and retitling this issue because:

  1. The original title described the problem, not the solution.
  2. Views is currently in version 3.7 and this problem still exists
  3. The patch in #12 fixed the problem for me

I guess most of this is all debatable, but at least Bevan seems to have solved the problem for me.

Thanks Bevan!

Bevan’s picture

According to comment #16 #1782172: In views 3.5 Title etc are not showing anymore already includes my patch from comment #12. That was marked duplicate of #1781744: Draft and Needs review pages are broken and #1792144: "My Edits" View is broken, both of which were committed in January.

Are you using a version of Workbench and WorkBench moderation that include those commits?

wickwood’s picture

Hello Bevan,

I was using a checked-out version of 7.x-1.x-dev with SHA#dfe9e23e123e225cb2e8a5c8273c73556d1056ba dated 6/12/2013 (which is 10 commits after the commits for issue #1781744, but I don't see a commit for issue #1792144: "My Edits" View is broken) to which I applied a patch that I created to solve the Issue #1447886 Ability to limit what content type an Editor can see for "Unpublished Nodes".

So I it is possible that my patch for Issue #1447886 Ability to limit what content type an Editor can see for "Unpublished Nodes" broke this again, however applying the patch from #12 to SHA ID#6bdb20e6f88f0a4bd564309d680bc367e311a6e2 (which was the latest release when patch from #12 was created) and merging back in after merging in the latest 7.x-1.x-dev commit (SHA IDa90378de5b1aea2b095ff5613eea44f55947f514) fixed this issue for me.

All the patching and merging that I did applied cleanly without conflict, so could it also be possible that the patch from #12 also got taken out again somewhere along the way? I don't know and I'm not sure I know how to figure that out either.

Hope this all makes sense to you and others, and not just me!

All the Best,

P.S. I'm also using Workbench 7.x-1.2.

Bevan’s picture

Thanks for the detail. That should be enough for someone to work out if this was actually resolved or not.

wickwood’s picture

I hope so and I will also try to track down if I myself did something to inadvertently remove the fix.

ckng’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Patch #12 does not seems to be committed, it is still working.

vijaycs85’s picture

+1 to get it committed...

richsky’s picture

Hi there, I've been playing with this a lot and found no way to display own draft in 'My Draft', testing the query itself shows results, giving all permissions doesn't solve the problem either using 7.x-1.3 or 7.x-dev.
Am I missing something obvious here?
I ended up using a contextual filter using the revision user relation.

My installation was corrupted, query substitutions weren't working. It is all good, sorry for the noise.

grasmash’s picture

1.12 KB
PASSED: [[SimpleTest]]: [MySQL] 137 pass(es). View

Updating patch so that {node} and {node_revision} joins are now 'left' rather than 'inner'. This allows views to be created which 1) contain workbench fields, and 2) co-mingle content types moderated by workbench with content types not moderated by workbench.

I'm attaching this patch to this issue because it cannot be cleanly applied in a separate patch (modifying same lines). I'm torn about whether to move this back to 'Needs Review' since at least 1 patch (in #12) is RTBC. If anyone can test this new patch and give feedback, it would be appreciated.

jweowu’s picture

grasmash: That does seems like a separate issue, and it might complicate getting this one committed, so I think you should probably post it separately. You could mark it as a related issue.

Regarding the dependency, you can either incorporate this patch into your own (in which case you would post both the full combined patch, and also the interdiff between them that shows your own changes).

Or if you simply post your changes on their own with a .do-not-test filename suffix, the test bot will ignore it, so you won't get failed tests. You can indicate the dependency on this issue's patch in the description.

  • colan committed 9c9550e on 7.x-1.x authored by Bevan
    Issue #1361210 by c31ck, Bevan: Fix "Workbench moderation: current"...
colan’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed #12. @grasmash: Please open a separate ticket for that (unless there's one there already).

das-peter’s picture

Status: Patch (to be ported) » Fixed

Does not apply to the 2.x branch, it uses the State Machine / State Flow views integration.

tedbow’s picture

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

Since doesn't apply to 2.x branch then changing back to 1.x for those searching issues

Status: Fixed » Closed (fixed)

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