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

Comments
Comment #2
jhedstromComment #3
jhedstromClarification, 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 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
jhedstromAh, 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
jhedstromNow 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 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
handkerchiefAre there any news on that? I have the same problem WITH the relationship to Moderation state. Drupal 8.3.3
Comment #9
brynj commentedAs handkerchief says, same issue here too - I have the relationship, but still a broken handler (Drupal 8.3.5).
Comment #11
timmillwoodI wonder if this will be fixed by #2862041: Provide useful Views filters for Content Moderation State fields.
Comment #12
amateescu commented@timmillwood, sadly.. nope :)
Comment #13
timmillwoodNo, 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 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 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 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 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
dpiThe 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
dpiComment #20
catchThe patch looks reasonable but this should have some automated test coverage.
Comment #21
mstef commentedWorks for me too. Thanks.
Comment #22
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 commentedComment #24
sam152 commentedTest looks good to me!
Comment #27
manuel garcia commentedunrelated test failures... retesting #23
Comment #29
sam152 commentedComment #30
larowlannit: these should be one per line for phpcs sake
Comment #31
sam152 commentedInterdiff:
Comment #33
larowlanfixed on commit
Comment #34
kkus 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 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
henry tran 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 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 commented@sam152 I think you answered your own question when you used the words "should" and "where possible"
Comment #40
sam152 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
dpiReverting to committed version