I am following the methodology outlined here: http://br0wn.net/blog/d8-responsive-paragraphs-materialize
I created my content paragraphs, and layout paragraphs. To demo this workflow, I added a paragraph field to Full Width Row paragraph, and called it Content (field_content). Then I assigned a Text Editor, FAQ, and Accordion paragraphs to it.
On the Basic Page content type, I added a paragraph field, Row. Row is assigned the layout paragraph types only (Full Width, 2 Column, 3 Column). So I add a Full Width, and my paragraph options appear. Text Editor, FAQ, or Accordion. Great.
Then I went back and created another paragraph field on the basic page content type, called it Full Width Row (field_n_row) just to trial something. I immediately decided it wasn't necessary, and delete the paragraph field.
After deleting the field, field content also seemed to vanish as well, along with its config and content. I can't even find a trace of it in the database, or the logs.
I was able to replicate what happened.
It seems like if you delete a paragraph type that a field is referencing, it will delete that field even if the field is referencing many other paragraph types.
This is problematic, because you can accidentally eradicate a field that should not be deleted because it holds other paragraph references.
Attached is a picture of me deleting a stub paragraph that was assigned to a field, and simply deleting this paragraph type also deletes the field. If I had a larger site, where the field_content field was used on multiple node types, would deleting a paragraph essentially wipe out any areas of my site also using a field that may have referenced that paragraph type (whether or not it ever had data)?
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | deleting_a_paragraph-2807411-20.patch | 5.69 KB | johnchque |
| #20 | deleting_a_paragraph-2807411-20-TEST-ONLY.patch | 2.93 KB | johnchque |
| #13 | no_change.patch | 360 bytes | jmuzz |
| #9 | err-deleting_content_types-2807411-9-test_only.patch | 2.92 KB | jmuzz |
| #9 | err-deleting_content_types-2807411-9.patch | 5.82 KB | jmuzz |
Comments
Comment #2
kevinquillen commentedComment #3
miro_dietikerYeah, it seems we enforced dependencies...
Since the deleted field is indicated, i'm not marking it critical. But i can see that this can lead to unexpected data loss and i doubt everyone really ready those pieces before confirming...
Instead we could decouple that dependency and simply remove the reference to the deleted paragraph type in the field configuration.
Still asking Berdir if this is well aligned with how Core decided to handle such a situation.
Comment #4
berdir#2468045: When deleting a content type field, users do not realize the related View also is deleted
paragraph can't do anything about this, it's not our field type. If anything, then this needs to be fixed in ERR so it updates the field. but that's always hard, if you remove the last allowed value, then you implicitly allow all, so what then? Maybe only delete if there are still some left.
Comment #5
jmuzz commentedI don't think deleting a content type should ever delete a reference field just because it can point to that type. With core ER fields the field is updated, and when the last target entity type gets removed the system logs a critical message stating that the field is no longer in a valid state. I have essentially copied that code and changed the message to be less alarming since it is a valid state for ERR.
Comment #6
miro_dietikerMakes sense to me to simply follow the ER case.
Is there some similar test coverage we can steal over there too? That's quite some code complexity that is hit a lot.
Comment #7
berdircan't we just let it inherit from the parent? I thought we have the same settings structure?
Comment #8
jmuzz commentedIt would probably work if it inherited from the parent however the message and code comments would contain incorrect information, and the logger would be posting for entity_reference instead of entity_reference_revisions:
Comment #9
jmuzz commentedI didn't find anything in entity reference that checks for unnecessary field and data deletion when removing a target entity bundle, but there is some tests about dealing with multiple bundles including deleting one in EntityReferenceAdminTest so it looks like the equivalent class in ERR is where this would go.
Comment #12
jmuzz commentedComment #13
jmuzz commentedComment #15
jmuzz commented#9 should work once #2817871: Tests are broken on head is fixed.
Comment #17
miro_dietikerComment #20
johnchqueRerolling patch. :).
Comment #22
stmh commentedWe have similar problems with a custom entity type with bundles, where deleting one entity type will delete the entity-revision-reference field from a content-type. Applying the patch seem to fix it on our end.
Comment #23
miro_dietikerAgain duplicated by #2925591: Deleting a nested paragraph type also deletes host paragraph field from Paragraphs.
Somehow this issue got lost..
Comment #25
miro_dietikerCommitted, looks good. :-)
Comment #27
kevinquillen commentedThis just happened to me again running Paragraphs 1.2 and ERR 1.3. Should there be a release to crush this issue?
Comment #28
mindfullsilence commentedLost data due to this issue 2 days before project deadline while deleting an unused paragraph. The reference field was set to "exclude" a couple paragraphs, therefore include all others. No content was entered on the site using the paragraph I deleted. The reference field was a "components" field that was setup to reference 6 or 7 different paragraphs. Rather than mark the paragraphs I wanted, I excluded the ones I didn't want. One of the paragraphs excluded was the one I deleted. The paragraph was excluded, meaning it was not displayed on any of the content types using the reference field, so absolutely no content data was entered using that paragraph. Deleting it caused my "components" field to be deleted. This resulted in the loss of all page data as the 'components' field was being used as a 'page-builder' for constructing page content. So all page content is lost. Paragraphs 1.2, Drupal 8.4.3