Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Found this today, caused a lot of problems because we had remove the Draft state and we kept getting a stubborn Draft state popping up all the time...
function workbench_moderation_state_none() {
return 'Draft';
}
Have updated this code to use the nodes default state (if it has one) and updated all references to pass either a node or a node_type.
Watch this space for the patch (need the issue number.)
Comment | File | Size | Author |
---|---|---|---|
#5 | workbench_moderation_hardcoded_draft_unpublished-1147646-5.patch | 5.64 KB | WorldFallz |
#1 | Fixing-hard-coded-draft-state-1147646.patch | 6.75 KB | CB |
Comments
Comment #1
CBPatch attached.
Comment #2
CBComment #3
stevectorThis seems to make sense. Can you update the patch to work with the latest dev branch? I'm getting an error when trying to apply it there. Also I don't think this patch needs to touch the .info file.
Comment #4
becw CreditAttribution: becw commentedThe patch I'm working on in #1160478: Machine names for states overlaps with this; I think both are important, though this issue is perhaps more immediate.
Comment #5
WorldFallz CreditAttribution: WorldFallz commentedI found this coming from #1185678: cannot transition from 'published' to another state and went ahead and updated this patch.
however, I disagree with the philosophy of always reverting back to the original state:
As mentioned in the other issue, there's a need for an 'obsolete' type of unpublished state that may make sense to put here. Maybe making the default unpublished state an option might fulfill this need?
Comment #6
CBJust saw the replies here. (Not getting drupal.org email notif's)
@WorldFallz - Not sure I understand. If a user has removed their 'Draft' status and a content type has a default state of 'Needs Review' then surely we can fall back to their original default value for that type when there is nothing else to pick?
I note that in the latest code, the function has remained unchanged and I'd love to see this resolved. Is there anything I can do to see this included in the next beta?
Comment #7
stevectorI understand the need to unpublish to a state other than Draft. I think that should follow the machine name patch. #1160478: Machine names for states
Cbiggins, please test that one if you have time.
Comment #8
becw CreditAttribution: becw commented@cbiggins, @stevector: there is a discussion and patch for unpublishing to states other than draft here: #1185678: cannot transition from 'published' to another state
The hard-coded draft state in
workbench_moderation_state_none()
is still a problem, though. This function should probably not ever be used directly--when looking for a default moderation state, workbench_moderation should first check for the default variable:... and then use
workbench_moderation_state_none()
to find the universal default. Luckily, I think this is mainly how it is used. Since 'draft' is deletable, maybe it should return the first moderation state according to the moderation state weights.Comment #9
hedley CreditAttribution: hedley commentedsubscribing
Comment #10
arski CreditAttribution: arski commentedthis is a bug really.. considering that you can freely remove the "draft" state from the selection.. and then you run into all sorts of troubles. If anything, it should be at the very least impossible to delete the draft state, then it could be called a task I suppose :x
Comment #11
khaled.zaidan CreditAttribution: khaled.zaidan commentedAny news on this?
6 months with no progress on this issue is very concerning :S
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous commentedAnother two weeks of no progress to this issue. I put it to major, it makes the module fail and is hard to debug.
I ran into this issue yesterday. It took some hours to figure out, because due to a bunch of Rules and Views the situation was quite complex and I didn't expect the cause in a stable Workbench Moderation module.
My usecase was a product review system without drafts. Drafts make it to complicated for end-users. So I removed the draft state (which is possible via config) and configured the content types to start with "needs review". This works fine when publishing the moderated nodes. After editing the same content, it dropped back to an undefined state and thus wasn't accessible from my moderation views anymore.
Solution is, to keep the "draft" state and rename it to "needs review". Then remove the original "needs review". This way, nodes will be reset to "needs review" (the internal draft state) during node updates.
Similar issue (duplicate?): #1408858: Default Moderation state of Published creates Drafts instead
Comment #13
ergophobe CreditAttribution: ergophobe commentedJust to add to Shnapoo's comment - you also need to edit
admin/structure/views/view/workbench_moderation/edit/needs_review_page
to get the Needs Review tab to show the content. And in point of fact, unless I'm misunderstanding the use case, you can get much the same effect just by showing both Drafts and Needs Review in the view.
Comment #14
thsutton CreditAttribution: thsutton commentedI just gave in and made the view change ergophobe describes in #13.
Is anyone still working on this? Would someone else pitching in be welcome? It would be great if there were some fix for this issue committed before another 31 months passes! :-)
Comment #15
thijsvdanker CreditAttribution: thijsvdanker commentedMy patch is not a total solution to this issue, but provides developers a way to at least override the hard coded 'draft' and 'published' states by passing it through variable_get.
Would appreciate it if this could be reviewed / committed while a better solution is in the making!
Comment #16
thijsvdanker CreditAttribution: thijsvdanker commentedOnly changed the patch name of #15 to reflect the project name correctly.
Comment #17
thomasmurphy CreditAttribution: thomasmurphy commentedIf deleting the draft state breaks the module, why does the module allow the draft state to be deleted? I deleted the draft state and made another to match the name of the default state for a client so that the machine name and the display/organisation names matched to prevent development problems down the line, and it has rendered the whole workbench module non-functional. Thanks for the patches, but shouldn't we fix the actual module so that it can't be broken so easily..?
Comment #18
ann b CreditAttribution: ann b commented#16 patch. The variable below doesn't exist. Did it exist 2 years ago when the patch was created? Or are we supposed to create it in the database outside of Drupal? What am I missing?
$state_none = variable_get('workbench_moderation_state_none', 'draft');
Hiding patch #15 and #16 for now.
*
#8 comment. There are several places in the .module file where workbench_moderation_state_none() is called directly. Agree that when looking for a default moderation state, workbench_moderation should first check for the default variable:
variable_get('workbench_moderation_default_state_' . $node->type, workbench_moderation_state_none())
*
#5 patch. This patch is 5 years old, but I do like the approach. The variable is checked in the workbench_moderation_state_none() function and returns either the default state for the node type or 'Draft'. The calls to the function would of course have to be changed though for the default state to be returned. Didn't try this because patch was created using an old release.
workbench_moderation_state_none($node = FALSE, $node_type = FALSE)
Comment #19
Jacqs CreditAttribution: Jacqs as a volunteer commentedJust 5 minutes ago.
Comment #20
ann b CreditAttribution: ann b commentedPer Drupal docs, the draft state is required. In that case, the hard-coded Draft status in the code is not a problem?
Comment #21
ann b CreditAttribution: ann b commented