Motivation
The Paragraphs module represents a great boost in the content management capabilities of Drupal entities. While Paragraph bundles work great with Features, Paragraph entities do not currently have UUID support, and as such are not exportable through Features.
Proposed resolution
I propose we add Paragraphs to the list of "blessed" entities found in the uuid_get_core_entity_info()
function, in the uuid.entity.inc
file. This will allow for Paragraph items, after having UUID enabled by Features UUID, to have UUID's associated with the Paragraph item entities.
Remaining tasks
Reviews are greatly appreciated.
User interface changes
None
API changes
None
Additional Notes
This patch itself does not allow for Paragraphs to be exportable through features. The a separate patch is (at the time of this posting) necessary for Features UUID to be able to export individual Paragraphs instances.
Comment | File | Size | Author |
---|---|---|---|
#36 | 2018-08-08_15h11_16.png | 54.99 KB | drupalbabaji |
#36 | 2018-08-08_15h09_44.png | 28.42 KB | drupalbabaji |
#34 | paragraphs-add_uuid_support-with-pre-revert-hook-2471174-34.patch | 5.03 KB | frodri |
| |||
#30 | interdiff-2471174-27-29.txt | 2.25 KB | Manuel Garcia |
#29 | paragraphs-add_uuid_support-2471174-29.patch | 5.25 KB | ron_s |
|
Comments
Comment #1
mattcoker CreditAttribution: mattcoker commentedComment #2
mattcoker CreditAttribution: mattcoker commentedComment #3
mattcoker CreditAttribution: mattcoker commentedComment #4
skwashd CreditAttribution: skwashd at Dave Hall Consulting for Pfizer, Inc. commentedUUID only supports core (and D8 candidate) modules. Moving this to the paragraphs module queue.
Comment #5
mattcoker CreditAttribution: mattcoker commented@skwashd Sorry, I wasn't aware of the core/D8 candidate limitation. Is there documentation of how I could implement the UUID API to get this functionality in the Paragraphs module?
Comment #6
mattcoker CreditAttribution: mattcoker commentedI will be updating this issue with a new patch soon, as the above patch was intended for the UUID module.
Comment #7
MatthewHager CreditAttribution: MatthewHager at Poetic Systems for Camden commentedWe are using this patch with our platform and it works well. Also, paragraphs now has a d8 release. Please merge.
Comment #8
MatthewHager CreditAttribution: MatthewHager at Poetic Systems for Camden commentedPlacing this back in the UUID issue queue since this patch is for the UUID module.
Comment #9
skwashd CreditAttribution: skwashd at Dave Hall Consulting for Pfizer, Inc. commented@MatthewHager this patch needs to be rerolled and target the paragraphs module. It won't be accepted for UUID.
Comment #10
paulmartin84 CreditAttribution: paulmartin84 commentedDoes anybody know the best way to approach this? It seems to do this you would need to add a dependency of UUID to paragraphs, so that you can use uuid_schema_field_definition(); This is not ideal, I am going to create a paragraphs_uuid module as that seems to be only way we can alter the paragraphs table without having the main module rely on having the UUID module. Hopefully I can get this added as a submodule to paragraphs.
Comment #11
paulmartin84 CreditAttribution: paulmartin84 commentedHeres a new sub module that adds UUID support to paragraph entites
Comment #12
jeroen.b CreditAttribution: jeroen.b at .VDMi/ commentedI prefer adding this into the paragraphs with some module_exists in the functions.
Then we don't need another module, and we don't need a dependency on the UUID module.
Comment #13
paulmartin84 CreditAttribution: paulmartin84 commentedI could be wrong, but I don't think that will work as the schema can't be altered that way, If the user already has the paragraphs module installed and then installs UUID module there is no mechanism to add the uuid field needed for paragraphs
Comment #14
paulmartin84 CreditAttribution: paulmartin84 commented@skwashd can you explain why Field Collections has been added to UUID but Paragraphs can't? Also what is the correct way to do this, It seem that every module wanting to implement UUID will have to create a sub module if they don't want to depend on UUID,
Currently if Field Collection gets enabled after UUID how are the fields being added as it seems _uuid_install_uuid_fields is only being called on install of UUID.
Comment #15
paulmartin84 CreditAttribution: paulmartin84 commentedI can see that UUID is using hook_modules_installed() to enable the other core modules if they are enabled later. I believe the correct place for hook_modules_installed() should really be in the .module file and not the .install file
I am going to propose a change to UUID so that it uses hook_modules_installed() for Contrib modules that want UUID support, each module just needs a way to flag it wants UUID and then the UUID module can change the entity_info, alter the schema, and add the db fields using hook_modules_installed(), This would also in future allow for a simple UI that could switch on UUID for modules that define entities but don't have this flag set.
This solves a few of the current problems:
I will create a patch for these changes and create a issue for UUID shortly in the meantime would appreciate any feedback.
Comment #16
paulmartin84 CreditAttribution: paulmartin84 commentedAfter some searching I found https://www.drupal.org/project/entity_uuid This seems to be the missing link. Would be nice if this functionally came out of the box with UUID module. If not then at least not supporting field collections would be a good idea, I think it should be core or all entities but not a mix of core and only some Contrib.
Comment #17
paulmartin84 CreditAttribution: paulmartin84 commentedOkay after looking at the UUID latest dev support for field_collections has now been removed. Looking at https://www.drupal.org/node/2309103 for field collections I feel this is also the best way forward for paragraphs, It also adds support for the deploy module including support for nesting. Here is another patch that also creates a submodule for UUID but also works with deploy and nested paragraphs which is what I needed.
This requires a patch to the main UUID module https://www.drupal.org/node/2308983 which add a new hook_uuid_entities_pre_rebuild_alter
Comment #18
jeroen.b CreditAttribution: jeroen.b at .VDMi/ commented@paulmartin84, thanks! Very nice. I'll wait until that patch gets committed.
Comment #19
Chim CreditAttribution: Chim commentedWe've been using paragraphs uuid to generate example content with migrations.
IMO it's ready to be included as a paragraphs submodule.
Comment #20
dstorozhukMissing module dependency :
entity_dependency
in #17Comment #21
j3ll3nlHereby i want to mention the following sandbox-project because otherwise deploying to services endpoint won't work.
https://www.drupal.org/sandbox/tundrainteractive/2369177
Comment #22
heyyo CreditAttribution: heyyo commentedAny plan to make it work with the module Features ?
Comment #23
DamienMcKenna@heyyo: try using UUID Features and see if they're then exportable.
Comment #24
heyyo CreditAttribution: heyyo commented@damien: I tried but it seems uncomplete. I was able to create my feature, but it was containing only the first level of my nested paragraphs.
I have one content type with a paragraph field, which allows only paragraph bundles which are acting as containers: how many columns. And those paragraph bundles containers, contain each of them, a paragraph field which allow paragraph bundles which are the real content.
In the feature I just created, I had only the content of the first paragraph field of my content type.
Comment #25
DamienMcKenna@heyyo: That suggests that additional work is needed for nested paragraphs. There may also be problems with UUID Features, you might want to check its issue queue too. Lastly, have you examined the exported files to see if all paragraphs are exported, i.e. the problem would be during import, or if it fails there too?
Comment #26
heyyo CreditAttribution: heyyo commentedThe issue is in the export process, only part of the paragraphs are exported.
Comment #27
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedAddressing #20.
Comment #28
ron_s CreditAttribution: ron_s commented"dependencise" is misspelled in your last version of the patch, and will not work.
Comment #29
ron_s CreditAttribution: ron_s commentedUpdated patch to fix the misspelling in #27. Also made a change
entity_property_id_to_uuid
andentity_property_uuid_to_id
functions which now default to using an array for the$properties
parameter.Comment #30
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedArgh, sorry for the misspelling, and thanks for spotting it @ron_s
Here's the interdiff for #29.
Comment #31
miro_dietikerWhile i don‘t know if the 7.x maintainer will add such an integration at the current late 7.x stage, i know for sure there is no way in without tests.
It should be a use case that explains why we need uuids in real life cases.
Comment #32
ron_s CreditAttribution: ron_s commentedFair enough. I have no time to write any tests at the moment, but the use cases are straightforward:
1) Ability to include default/sample paragraphs that are attached to nodes using UUID Features.
2) Ability to support Paragraph Defaults (https://www.drupal.org/project/paragraphs_defaults) in Features.
Comment #33
Adirael CreditAttribution: Adirael commentedPlus supporting content staging using the Deploy module, that depends on UUIDs to be able to move content over from site to site.
Related: #2365347
Comment #34
frodri CreditAttribution: frodri commentedDeploy module feature reverts fail due to the empty $paragraphs variable on paragraphs_field_uuid_presave. The following patch fixes that issue by adding a pre_revert hook to the patch on #29.
Comment #35
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedComment #36
drupalbabaji CreditAttribution: drupalbabaji as a volunteer commentedTried #34 patch. I can see the paragraph field data in logs. But not able to insert it into paragraph field.
Comment #37
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commentedUpdating the status as "needs work" as shown in #36 the data is not getting imported to paragraph fields.
Comment #38
AnybodyYup I can exactly confirm #36. Paragraphs items are not fully exported / imported with the shown results. BTW the problem is identical with node_export.
Comment #39
RoloDMonkey CreditAttribution: RoloDMonkey at Third and Grove commentedI was never able to get the patches in this issue to work. But, I was able to get complex, deeply nested Paragraphs to work with the sandbox module: https://www.drupal.org/sandbox/tundrainteractive/2369177
At the time, I also needed this patch: https://www.drupal.org/project/uuid_features/issues/2471182
But since then, that has been committed to UUID Features and released as part of 7.x-1.0-rc2.