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

Revisions don't seem to work with paragraphs #31

Closed laryn closed 4 years ago

laryn commented 5 years ago

Haven't done any further testing yet but I see this when trying to save a revision on a node that has paragraphs field:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY': INSERT INTO {paragraphs_item_revision} (revision_id, item_id) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => 1 ) in backdrop_write_record() (line 8086 of /path/core/includes/common.inc).

EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY' in ParagraphsItemController->save() (line 55 of /path/modules/paragraphs/ParagraphsItemController.inc).

EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY' in NodeStorageController->save() (line 320 of /path/core/modules/node/node.entity.inc).

sternhagel commented 4 years ago

I can confirm this issue. I'm seeing similar error messages when trying to save a revision of a node with paragraphs on it:

EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '6' for key 'PRIMARY' in NodeStorageController->save() (line 487 of [...]/core/modules/node/node.entity.inc). EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '6' for key 'PRIMARY' in ParagraphsItemController->save() (line 55 of [...]/modules/paragraphs/ParagraphsItemController.inc).

laryn commented 4 years ago

Likely related to:

Which is waiting on a decision about core. It seems as though there is some interest in moving entity revision functions into core, though PR needs work:

laryn commented 4 years ago

Cross post:


I made a new branch for testing, which adds a dependency on Entity Plus (although it requires this PR on Entity Plus: https://github.com/backdrop-contrib/entity_plus/pull/16/files). Revisions with Paragraph fields are working for me using this branch. Anybody care to test?

https://github.com/backdrop-contrib/paragraphs/compare/entityplus

If Entity Revision functions get into core we may not need to keep the Entity Plus dependency, but will need to test obviously.

sternhagel commented 4 years ago

@laryn Tested this issue as well with entityplus branch and PR on "Entity Plus" module - works perfectly!

sternhagel commented 4 years ago

After more testing I got the following PHP notice after reverting a node to any revision - it's not coming from Paragraphs module directly, but it's probably related:

Notice: Undefined property: ParagraphsItemEntity::$original in file_field_update() (line 267 of [...]/core/modules/file/file.field.inc).

laryn commented 4 years ago

@sternhagel I broke that last one out into a separate issue since it seems to happen more broadly on save/updating an entity that has a Paragraphs file field attached.

bradbulger commented 4 years ago

I tried using the entityplus branch. That gave me fatal errors until I also patched entity_plus for some unfixed bugs. Having done that, I was able to save a new revision of the node.

What are the obstacles to getting these modules fixed? Do tests need to be written? Do we need to resolve the issue of entity_plus vs core?

laryn commented 4 years ago

Did you use the PR I linked for entity plus? I think @docwilmot was open to making me a maintainer in entity plus, at which point I will merge that PR and be clear to make a new release here.

If you didn't use the PR on entity plus, did you have additional changes or patches to add?

bradbulger commented 4 years ago

I ended up using the PR and then read more carefully your note telling us to do that, d'oh. So I think I was on the configuration you were aiming at - the entityplus branch of paragraphs + the entity_plus pull request 16. The errors on saving a node with "new revisions by default" enabled went away. I didn't try anything more extensive than that.

bradbulger commented 4 years ago

Running the entityplus branch with the 1.0.4 release of entity_plus, I am able to add and remove paragraphs and save the node with revisions enabled, without error. Using the diff module I'm able to see differences in the paragraphs for the node between revisions.

jackaponte commented 4 years ago

Any chance of a new release sometime soon? This particular bug is biting me lately! If not I'll try to create a patch for myself soon. :)

laryn commented 4 years ago

@jackaponte Here's a pre-release: https://github.com/backdrop-contrib/paragraphs/releases/tag/1.x-1.1.0-beta

jackaponte commented 4 years ago

@jackaponte Here's a pre-release: https://github.com/backdrop-contrib/paragraphs/releases/tag/1.x-1.1.0-beta

Awesome, thanks so much @laryn!