Closed (fixed)
Project:
Drupal core
Version:
8.5.x-dev
Component:
content_moderation.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
9 Mar 2017 at 22:04 UTC
Updated:
8 May 2018 at 02:49 UTC
Jump to comment: Most recent, Most recent file

Learn more
Comments
Comment #2
jhedstrom CreditAttribution: jhedstrom at Phase2 for Workday, Inc. commentedComment #3
jhedstrom CreditAttribution: jhedstrom at Phase2 for Workday, Inc. commentedClarification, this appears to only be an issue for the 'Moderation state' fields that are available on a content view without a relationship to the
content_moderation_stateentity/table:And I can't quite figure out where those are being added to the views data...
Comment #4
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedFixing this is a follow up to #2845151: ContentModerationStateFormatter pretends it's for the moderated entity, but it is for the content moderation state entity.
This gets exposed in \Drupal\content_moderation\ViewsData::getViewsData. The views data array has an issue, no field plugin is set:
\Drupal\views\Plugin\views\field\EntityField doesn't work because the field is computed. We have two ways of fixing this:
I have made a start on the latter in #2852067: Add support for rendering computed fields to the "field" views field handler.
Comment #5
jhedstrom CreditAttribution: jhedstrom at Phase2 for Workday, Inc. commentedAh, so we have a computed moderation state field, and then the one that can be manually added via a relationship. The latter would allow for filtering, etc via moderation state, while the computed one would be immediately available to a view without adding that relationship.
Comment #6
jhedstrom CreditAttribution: jhedstrom at Phase2 for Workday, Inc. commentedNow that #2845151: ContentModerationStateFormatter pretends it's for the moderated entity, but it is for the content moderation state entity is in, I'd hoped the non-computed moderation state field would display the label rather than the machine name, but it isn't, so I opened #2860907: Moderation state field isn't using the state label in Views.
Comment #7
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedIf #2852067: Add support for rendering computed fields to the "field" views field handler gets in, it will be trivial to add the computed handler to the computed field to show the pretty name.
Comment #8
handkerchief CreditAttribution: handkerchief commentedAre there any news on that? I have the same problem WITH the relationship to Moderation state. Drupal 8.3.3
Comment #9
brynj CreditAttribution: brynj commentedAs handkerchief says, same issue here too - I have the relationship, but still a broken handler (Drupal 8.3.5).
Comment #11
timmillwood CreditAttribution: timmillwood at Appnovation for Pfizer, Inc. commentedI wonder if this will be fixed by #2862041: Provide useful Views filters for Content Moderation State fields.
Comment #12
amateescu CreditAttribution: amateescu for Pfizer, Inc. commented@timmillwood, sadly.. nope :)
Comment #13
timmillwood CreditAttribution: timmillwood at Appnovation for Pfizer, Inc. commentedNo, but a combination of #2852067: Add support for rendering computed fields to the "field" views field handler and #2902187: Provide a way for users to moderate content will.
Comment #14
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedHere is the fix for displaying the field, in case anyone needs it for 8.4.x. It might make sense to get this in ahead of #2902187: Provide a way for users to moderate content, because since this is now supported by the default handler, this could be classed as a bugfix, whereas that is a feature that'll only land in 8.5.
Comment #15
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedI have this patch applied on an upgraded 8.4 site. I'd still love to get this backported as a bugfix.
Comment #16
k4v CreditAttribution: k4v commentedI tried the patch on Drupal 8.4.2, but I still get the error "missing handler". How could I port this back, do you have some advice? Thank you :).
Comment #17
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThis patch works when adding the "moderation state" field that is attached to the moderated entity, not the state field on the content_moderation_state relationship. Make sure caches are cleared after applying the patch.
Comment #18
dpi CreditAttribution: dpi at PreviousNext commentedThe content moderation state field is still completely broken in 8.4, as soon as you add the field it says the field is broken/missing handler. This really should be backported to 8.4.x.
Comment #19
dpi CreditAttribution: dpi at PreviousNext commentedComment #20
catch CreditAttribution: catch at Third and Grove commentedThe patch looks reasonable but this should have some automated test coverage.
Comment #21
mstef CreditAttribution: mstef commentedWorks for me too. Thanks.
Comment #22
mstef CreditAttribution: mstef commentedThis may be useful to others but here's a patch that applies against 8.4.x after applying the related #2862041: Provide useful Views filters for Content Moderation State fields patch.
Comment #23
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedComment #24
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedTest looks good to me!
Comment #27
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedunrelated test failures... retesting #23
Comment #29
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #30
larowlan CreditAttribution: larowlan at PreviousNext commentednit: these should be one per line for phpcs sake
Comment #31
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedInterdiff:
Comment #33
larowlan CreditAttribution: larowlan at PreviousNext commentedfixed on commit
Comment #34
kkus CreditAttribution: kkus as a volunteer commentedI think there is a small bug in this code.
The moderation state that we display should not be the latest default state but rather the latest state. For example, in the default editorial workflow with draft, published, and archived states, published and archived are default states while draft is not.
Lets say an editor creates a new article and saves it as draft. The moderation state field will say draft.
Next, they publish the article. The moderation state field will say published.
Later, if they create a new draft and save it the moderation state field will still say published. I think this is incorrect behavior. I think if a draft exists that is newer than the latest published state, the field should say draft.
Thoughts? https://youtu.be/9wPQRDo_fHY
Comment #35
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThe behavior in #34 is by design. If you want to display information from the latest revision of an entity, you need to add a relationship to it (not sure if that exists in core yet) or create a view of revisions and use the "Is latest revision" filter to only show one latest revision per entity.
Comment #37
tvhung CreditAttribution: tvhung at Deloitte Digital commentedI've rerolled this patch apply for latest 8.4.x.
It also include this issue https://www.drupal.org/node/2862041
Comment #38
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedHey @tvhung, any reason this needs to be rerolled for 8.4? The 8.4 branch is current unsupported, so sites should upgrade to 8.5 where possible.
Comment #39
chOP CreditAttribution: chOP at Deloitte Digital commented@sam152 I think you answered your own question when you used the words "should" and "where possible"
Comment #40
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commented@chOP, that doesn't explain why. If the blocker to upgrading to 8.5 is related to content_moderation in some way (which could kinda be correlated by the need to reroll patches for a beta version of the module), that's helpful to know about because it could affect others.
Comment #41
dpi CreditAttribution: dpi at PreviousNext commentedReverting to committed version