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.
Problem/Motivation
Paragraphs Library items do not have a status field that makes them published/unpublished.
This is particularly useful in properly supporting content moderation module integration #2807371: META Support Content Moderation module.
Proposed resolution
-
Let
LibraryItem
inheritEditorialContentEntityBase
which provides publishing options. - Write an update function to update existing sites with this change
Comments
Comment #2
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedA starting point-patch.
Comment #3
johnchqueThis was made in the Paragraph entity time ago, there is also an update function for it, think it gonna be really similar. :)
Comment #4
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedAdding the missing parts.
I am getting confused with the access handler:
I would except that this snippet disallows access for unpublished library items entities except for users with
administer paragraphs library
permission. This works fine when I try to accessadmin/content/paragraphs/{paragraphs_library_item_id}
route directly.However, it does not work in case this library item is embedded.
Steps to reproduce:
Comment #5
BerdirThat's because we don't check the permissions in our preprocess function. We need to do that, including keeping cacheablity metadata.
We need tests that create an unpublished library, access as anon, make sure it doesn't show up, then publish it, then access again and making sure that it now shows up. To get that to pass, you will need to add the library as a cacheable dependency to the access result.
Comment #6
BerdirComment #7
BerdirComment #8
BerdirAdded the access check including tests.
Comment #10
BerdirAh, fun fail. The assertion was bogus and we forgot to update it properly. It was still testing the case when the paragraph library label was the link. But it actually also matched on the breadcrumb, but *only* the wrong, old label, because the breadcrumb cache wasn't invalidated. Now, because I added the cacheability metadata, it is.
Comment #11
miro_dietikerI was confused why this definition is not needed below and couldn't see from where these defaults would originate. However the resulting storage was consistent for updates and new installs.
Committed.
Comment #14
the_glitch CreditAttribution: the_glitch commentedSo which of these patches work?
Comment #15
harcher CreditAttribution: harcher commented...