Problem/Motivation
We should deprecate the content moderation entity revision converter, it's no longer needed.
Proposed resolution
- Deprecate the converter.
- Update it to convert usage of
load_pending_revisiontoload_latest_revisionso core understands it.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #34 | 2924812-34.patch | 13.89 KB | effulgentsia |
| #26 | 2924812-26.patch | 13.86 KB | sam152 |
| #26 | interdiff-2924812.txt | 3.47 KB | sam152 |
| #22 | 2924812-22.patch | 11.3 KB | sam152 |
| #22 | interdiff.txt | 2.89 KB | sam152 |
Comments
Comment #2
sam152 commentedComment #3
plach@Sam152 in #2865616-77: Add an option for EntityConverter to load the latest entity revision and fix all entity forms to use this option.:
Well, my goal was reducing disruption (https://www.drupal.org/core/d8-allowed-changes#beta :), given that
EntityRevisionConverteris itself an example of a param converter extending another one. OTOH this is not considered a best practice so removing it could be fine:Comment #4
sam152 commentedI don't think removing the class would have been too disruptive, but something I can see that could be is the fact the new converter uses
load_latest_revisionand CM usesload_pending_revisionin the param definition. Lets makeEntityRevisionConverterthe bridge for these things and deprecate the class andload_pending_revision.Comment #5
plachYep, that's exactly what I thought, sorry for not being clear.
Comment #6
sam152 commentedPerfect! Updating IS.
Comment #7
sam152 commentedApplies on top of the blocker. The deleted test cases all still pass, but given the code they are testing no longer exists, I thought it best to simply remove them.
Comment #9
plachIt seems #7 is only the actual patch, not the combined one.
Comment #10
plachThe parent issue is in, let's test the patch above again.
Comment #12
sam152 commentedHm, these fails don't show up for me locally. I'm using
./core/phpunit.xml.disttoo which does contain\Drupal\Tests\Listeners\DeprecationListener, so not sure why it's not showing up.Comment #13
sam152 commentedComment #15
sam152 commentedI'm finding it hard to get the deprecations to fail tests locally without altering code in the phpunit-bridge. Not sure what I'm doing wrong there.
As far as the deprecation fails, given the service will be loaded for our BC layer I think the deprecation error needs to be suppressed. To correctly notify users who are in danger of a BC break, we can trigger an error that we don't exclude, only when the load_pending_revision flag is set. This doesn't cover the use case of people extending the class or instantiating the service however, but I think using the flag is going to be a far more common use case. Param converters are not covered in the BC policy, as discussed.
Couldn't really test this patch locally, lets see what the bot says.
Comment #16
plachLooks great to me
Comment #17
xjmHm, not sure about adding this message to the suppressed deprecation messages. It makes sense to temporarily suppress the warning for something like
drupal_set_message(), but I'm not sure it does for something like this that has low usage. Still trying to follow the implications of #15.If we do add it to the message list I think there should be an inline comment above it, with the reasoning, and a link to any followup.
Comment #19
sam152 commentedAdding the follow-up issue sounds like a good idea. Here is my understanding of the deprecation fail:
ParamConverterManager.load_pending_revisionflag, essentially we are deprecating two things at once.load_pending_revisionto work, the service needs to remain tagged and be used during runtime.load_pending_revisionflag can be removed in one go.With all that in mind, I think the options are:
@internalfor good measure.Comment #20
timmillwoodI wonder if a "soft" deprecation could be an option. As @Sam152 mentioned, the classes are already marked @internal so we could remove them with no issues? Maybe we could add a message in the comments to say "It's advised to use the "paramconverter.entity" service instead, which now supports loading the latest revision."
Comment #22
sam152 commentedImplementing @timmillwood's suggestion from #20, I like it!
Remove @deprecated from the class, leaving it as @internal (maybe explicitly mark it as such) and then only trigger the deprecation when people use the flag on routes. Then core and users can fix any routes which use the deprecated feature it offers and anyone instantiating or extending the class directly will get more a more explicit signal that it is internal via a docblock.
Comment #23
wim leersThis could mention that
load_pending_revisionis the predecessor ofload_latest_revisions/and when/when/
👏
Comment #24
wim leersPer #2860097-100: Ensure that content translations can be moderated independently.2, this would make that issue slightly simpler.
And actually, I think this patch looks great. #23 are both super nits, really. So … RTBC :)
Comment #25
effulgentsia commentedThis patch looks great to me, and since content_moderation is still an experimental module (until #2897132: Mark Content Moderation module as stable lands), I'm happy to cherry pick this to 8.5.x as well, so setting the Version accordingly.
Just one question about the test coverage:
Is there a reason we're removing these tests entirely? Should we instead move them to
EntityConverterLatestRevisionTestor elsewhere?Comment #26
sam152 commentedShuffling the comment around a bit to hopefully be clearer.
testConvertNonRevisionableEntityType: while the flag doesn't have any utility when the entity isn't revisionable, as suggested I have added a test to prove nothing blows up when the latest_revision_flag is present.testConvertNoEditFormHandler: I've added a test case to what I believe is now the responsible party for making this work. When a route exists with_entity_formand no operation (like the original bug report and test case) we are proving theload_latest_revisionflag is still added to the route.EntityConverterdoesn't use or check this value for anything, so I don't believe we need additional testing beyond this.Comment #27
plachLooks good to me, the only concern I have is that the route defined in
EntityResolverManagerTest::testSetLatestRevisionFlag()is/foo/{entity_test}rather than/foo/{entity_test_rev}. Not sure that's relevant.Comment #28
wim leersI asked myself this very question, and first included it in #23. But then I realized that the "edit form" thing was a hardcoded assumption/restriction in the Content Moderation param converter because it was meant to be a param converter used only by/for Content Moderation. Now that that param converter has been generalized into something more broadly useful, there also is no more need for that restriction, because nothing should be using the Content Moderation param converter. Hence also the explicit deprecation error.
The only possible edge case that could regress here is that if you have a route that has an entity edit form, and does not have
load_pending_revisionset, then this paramconverter would have worked before (applies()would have returnedTRUE), and now you'd have to manually set theload_latest_revisionflag.It just seemed so far-fetched that I figured it was safe to go ahead. Now I'd like somebody to explicitly confirm that this edge case is not a problem.
Comment #29
sam152 commentedI added a test for the flag being added in #26. I don't think the path matters to the test case as per #27 but I would have to check when I'm back at my desk.
Comment #30
effulgentsia commentedOn quick inspection, #26 looks like adequate test coverage to me, but I haven't yet dug into the background of why these tests were needed to begin with, so I'm not yet 100% clear on whether the new tests address all of the same original concerns. @Sam152, @plach, @Wim Leers, @timmillwood: what do you all think?
Comment #31
timmillwoodI agree with #30 that the test coverage looks adequate, although it never feels right to delete test.
It also looks like #27 still needs addressing?
Comment #32
sam152 commentedRe: #27, lets change it to an arbitrary string to prove it doesn't actually have a bearing on the test.
Comment #33
effulgentsia commentedTicking credit boxes for reviewers.
Comment #34
effulgentsia commented#26 no longer applies. This is just a straight reroll.
Comment #37
effulgentsia commentedGiven that this was already RTBC in #24, and that more test coverage was added since then, I decided to commit this without awaiting resolution on #32, in order to allow #2860097: Ensure that content translations can be moderated independently to be simplified.
Marking this Fixed, but adding the Needs followup tag for #32. If an additional test is needed, please open a new issue for it. If it turns out not to be needed, please remove the tag.
Thanks!