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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mattcoker’s picture

mattcoker’s picture

Issue summary: View changes
mattcoker’s picture

skwashd’s picture

Title: Add Paragraphs module support » Add UUID module support
Project: Universally Unique IDentifier » Paragraph
Version: 7.x-1.x-dev »

UUID only supports core (and D8 candidate) modules. Moving this to the paragraphs module queue.

mattcoker’s picture

@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?

mattcoker’s picture

Project: Paragraph » Paragraphs
Version: » 7.x-1.0-beta6
Status: Active » Needs work

I will be updating this issue with a new patch soon, as the above patch was intended for the UUID module.

MatthewHager’s picture

Status: Needs work » Reviewed & tested by the community

We are using this patch with our platform and it works well. Also, paragraphs now has a d8 release. Please merge.

MatthewHager’s picture

Project: Paragraphs » Universally Unique IDentifier
Version: 7.x-1.0-beta6 » 7.x-1.x-dev

Placing this back in the UUID issue queue since this patch is for the UUID module.

skwashd’s picture

Project: Universally Unique IDentifier » Paragraphs
Status: Reviewed & tested by the community » Needs work

@MatthewHager this patch needs to be rerolled and target the paragraphs module. It won't be accepted for UUID.

paulmartin84’s picture

Does 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.

paulmartin84’s picture

Status: Needs work » Needs review
FileSize
2.6 KB

Heres a new sub module that adds UUID support to paragraph entites

jeroen.b’s picture

Status: Needs review » Needs work

I 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.

paulmartin84’s picture

I 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

paulmartin84’s picture

Status: Needs work » Needs review

@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.

paulmartin84’s picture

I 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:

  • Not needing a dependency to UUID
  • Enabling the UUID module after the Entity Defining module will still work
  • Easier for modules to add UUID support
  • Future support for enabling UUID on any entity

I will create a patch for these changes and create a issue for UUID shortly in the meantime would appreciate any feedback.

paulmartin84’s picture

After 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.

paulmartin84’s picture

Okay 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

jeroen.b’s picture

@paulmartin84, thanks! Very nice. I'll wait until that patch gets committed.

Chim’s picture

We've been using paragraphs uuid to generate example content with migrations.

IMO it's ready to be included as a paragraphs submodule.

dstorozhuk’s picture

Missing module dependency : entity_dependency in #17

j3ll3nl’s picture

Hereby i want to mention the following sandbox-project because otherwise deploying to services endpoint won't work.

https://www.drupal.org/sandbox/tundrainteractive/2369177

heyyo’s picture

Any plan to make it work with the module Features ?

DamienMcKenna’s picture

@heyyo: try using UUID Features and see if they're then exportable.

heyyo’s picture

@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.

DamienMcKenna’s picture

@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?

heyyo’s picture

The issue is in the export process, only part of the paragraphs are exported.

Manuel Garcia’s picture

Addressing #20.

ron_s’s picture

Status: Needs review » Needs work

"dependencise" is misspelled in your last version of the patch, and will not work.

ron_s’s picture

Updated patch to fix the misspelling in #27. Also made a change entity_property_id_to_uuid and entity_property_uuid_to_id functions which now default to using an array for the $properties parameter.

Manuel Garcia’s picture

FileSize
2.25 KB

Argh, sorry for the misspelling, and thanks for spotting it @ron_s
Here's the interdiff for #29.

miro_dietiker’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

While 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.

ron_s’s picture

Fair 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.

Adirael’s picture

Plus supporting content staging using the Deploy module, that depends on UUIDs to be able to move content over from site to site.

Related: #2365347

frodri’s picture

Deploy 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.

Manuel Garcia’s picture

Status: Needs work » Needs review
drupalbabaji’s picture

Tried #34 patch. I can see the paragraph field data in logs. But not able to insert it into paragraph field.paragraph issue

paragraph issue

shashikant_chauhan’s picture

Status: Needs review » Needs work

Updating the status as "needs work" as shown in #36 the data is not getting imported to paragraph fields.

Anybody’s picture

Yup I can exactly confirm #36. Paragraphs items are not fully exported / imported with the shown results. BTW the problem is identical with node_export.

RoloDMonkey’s picture

I 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.