backdrop-contrib / paragraphs

Paragraphs module to control your content flow
https://backdropcms.org/project/paragraphs
GNU General Public License v2.0
5 stars 11 forks source link

Issue #149 - Addition of paragraph type clone function #150

Closed yorkshire-pudding closed 1 year ago

yorkshire-pudding commented 1 year ago

Fixes #149

laryn commented 1 year ago

@yorkshire-pudding It's a bit strange, but when I begin testing on a vanilla install, if I create a Paragraphs type with very little info and no fields, and then clone it, I get this status message that looks incomplete:

Screenshot 2022-12-19 at 08-29-02 Paragraphs types Paragraphs Sandbox

And in the watchdog:

Notice: Undefined index: source_name in paragraphs_type_clone_finished() (line 392 of /app/web/modules/paragraphs/paragraphs.type_clone.inc). Notice: Undefined index: target_name in paragraphs_type_clone_finished() (line 393 of /app/web/modules/paragraphs/paragraphs.type_clone.inc). Notice: Undefined index: field_count in paragraphs_type_clone_finished() (line 394 of /app/web/modules/paragraphs/paragraphs.type_clone.inc).

This happens if I clone any Paragraphs type immediately after creating it. I guess it's a cache issue somewhere along the way?

argiepiano commented 1 year ago

This happens if I clone any Paragraphs type immediately after creating it. I guess it's a cache issue somewhere along the way?

This happens when the paragraph to be cloned has no fields attached to it. It's harmless, but can be prevented in the code.

yorkshire-pudding commented 1 year ago

Thanks @laryn - I've made changes as suggested.

yorkshire-pudding commented 1 year ago

Now handles clone without fields.

argiepiano commented 1 year ago

Great, @yorkshire-pudding! My only minor suggestion is to use $form_state['redirect'] instead of backdrop_goto (you'll need an else statement too to set the batch). I read somewhere that redirect is the recommended way, as the form processor finishes doing its thing when you use it, instead of backdrop_goto but I may be wrong...

laryn commented 1 year ago

@yorkshire-pudding I think we're looking good! The suggestion from @argiepiano sounds right, so once that's complete given his review and my own I think we're set to merge.

yorkshire-pudding commented 1 year ago

Thanks @laryn and @argiepiano - that change is done.