verbb / super-table

Super-charge your Craft workflow using Super Table.
MIT License
317 stars 47 forks source link

Duplicate of content #450

Open vviacheslavv opened 2 years ago

vviacheslavv commented 2 years ago

Description Hello. For frontpage entry type we use super table field type(contains plain text and entries) and in some cases (i can't reproduce it at any time, but it appear from time to time) after publish of entry attribute got 2-3 rows of duplicates. Settings for this attribute has limitation to 1 row max and enabled checkbox "Static". Is there a chance that you may suppose possible reason of such issue ? Thanks

Additional context

bjornbjorn commented 2 years ago

Hi, we're also experiencing this after updating to CraftCMS 3.7.33 and Super Table 2.7.1

vviacheslavv commented 2 years ago

Strange, but after upgrade to 2.7.1 version this issue has disappeared for me.

Kethatril commented 2 years ago

I started seeing this issue after updating to CraftCMS 3.7.34 and Super Table 2.7.1 without multi-site (and it continued happening after updating to CraftCMS 3.7.46 and Super Table 2.7.2)

I have seen it on 25 different pages now and 24 of them on the same section type. It happens on 2 different static Super Tables on the same page and I think on all of them it has been both fields that have duplicated. I do have one draft that has 3 of each field while the published entry only has 2. Because of that my guess is it might be happening on draft creation or when updates to the entry are merged into an existing draft. However I have yet to reproduce the issue locally.

I've also seen this happen with Craft Neo, so it might be a CraftCMS issue. I haven't seen it happen with matrix fields yet though.

vviacheslavv commented 2 years ago

Confirm. A Week ago we have got duplicates again. For the same "single" type . Entry has two drafts, one from april and another one from january(if this is important). Plugin version: 2.7.1 Craft version: Pro 3.7.25.1

Kethatril commented 2 years ago

This has occurred to us on a different site as well now. Both a static super table and all the matrix blocks on a page were duplicated.

I'm thinking it might be a core CraftCMS issue as I've seen it on Super Table, Neo and Matrix fields now all on a variety of sites.

clieee commented 2 years ago

I've encountered this issue as late as today. Super Table field set as static appeared with duplicate. Do we know anything more about this?

stevehurst commented 1 year ago

We're also experiencing this issue. It appears to be pulling old versions of the Super Table content from old drafts and revisions. It's happening intermittently, hard to reliably reproduce.

MoritzLost commented 1 year ago

We're also seeing this issue. Updating an older entry with a super table field inside a matrix field caused the 3 super table blocks inside the matrix block to be duplicated, so there are now 6 super table blocks. Interestingly, the blocks were duplicated in place, so the duplicates are next to each other. Same as everyone, I can't reliably reproduce it.

engram-design commented 1 year ago

This should be fixed in 3.0.2, but let me know if there's still issues.

stevehurst commented 1 year ago

@engram-design we're not able to update to Craft 4 yet—waiting on 3-4 plugins. We really need a fix for this on the 2.x branch.

This bug is causing critical content issues on our websites. Fields are duplicated and matrix fields are moved automatically when the user loads an entry. If they don't discard changes and save with the mixed up and duplicated content, we're unable to revert fully or fix static Super Table fields that have duplicated.

mattbloomfield commented 1 year ago

We also cannot upgrade to Craft 4.x due to other plugins - any chance we'd see a fix in the 2.x branch?

stevehurst commented 1 year ago

@engram-design has this been fixed in version 2.7.4, released end of December? Not seeing anything in the change log about this particular issue.

https://github.com/verbb/super-table/releases/tag/2.7.4

maxstrebel commented 1 year ago

We cannot reproduce this reliably yet, but unfortunately we experience the same problem on Version 3.0.7 & Craft CMS 4.3.6.1

EDIT: Authors also reported this behavior on a Matrix Field. Maybe there's an edge cases which can cause relations to double? I'm still working on a way to reproduce reliably.

(Authors edit in a slideout -> save -> all rows duplicate)

engram-design commented 1 year ago

@stevehurst Not yet, the changes aren't 1-for-1 going back to Craft 3, but I'll do my best to address it.

MoritzLost commented 1 year ago

@engram-design We're still seeing this issue on Super Table 3.0.7 (Craft 4.3.6.1). We can't reliably reproduce it, it only sometimes happens in production, seemingly randomly. Some content is saved, then all Super Table blocks are duplicated. Any idea why this might still be happening?

gbowne-quickbase commented 1 year ago

If we set min rows = 1 and max rows = 1 instead of static, will this fix it? When it's static we don't get the option to [x] out the extra row and can only recreate the component

MoritzLost commented 1 year ago

Just got a client report about this issue again. An entry with a matrix block with a super table field inside it. Last saved in April, then a couple of days ago. The revision from April had three super table blocks inside the matrix block, the revision from three days ago had six, each of the original elements was duplicated once. The new blocks got new IDs and were visible in the backend as well, so it wasn't just a frontend issue.

@engram-design Any ideas as to what might be causing this, or how we could help debug / reproduce the issue? I'm completely stuck as it occurs seemingly randomly, and only rarely.

yannkost commented 4 months ago

I can't tell why it's happening, but I figured out a query that can help to identify such rows.

Select elements.id, so.ownerId  from elements 
    left join supertableblocks s2 on s2.id  = elements.id
    left join stc_navsetting sn on sn.id = elements.id
    left join supertableblocktypes s  on s.id  = s2.typeId 
    left join supertableblocks_owners so on so.blockId  = s2.id
    where type = 'verbb\\supertable\\elements\\SuperTableBlockElement' and 
    elements.archived=FALSE AND elements.dateDeleted IS NULL AND elements.draftId IS NULL AND elements.revisionId IS NULL
    and s.id = ${SUPERTABLEBLOCKTYPE} order by so.ownerId  ASC, elements.id ASC

Now if we know that ${SUPERTABLEBLOCKTYPE} should be static, only 1 element should be attached to it. Now this query shows where two different elements have the same owner, there is a duplicate.

image

joshmcoffman commented 4 months ago

I've seen this with a supertable field and matrix on Craft 4.8.1 when creating a Draft entry for the first time.

This seems to happen if you have autosave drafts on and you hit save while autosave is still processing. We have a bunch of matrix fields and we also have Workflow and some custom events. It's more of an issue when we are creating drafts for the first time with a step 1 workflow user, as the autosave takes longer.

Solutions:

  1. Don't hit save until any autosave completes what it is doing and you get the green check.
  2. Disable autosaveDrafts. Deprecated in Craft 4, but currently we disable it in config. If you are using Fluent config, then before returning it disable it since the ENV override no longer works: $config->autosaveDrafts = false;
  3. Add some code to prevent saving if autosave is running.

Not sure where the fix would be (plugins, craft, etc) at this point, but #3 seems ideal to me as someone could have a network condition on autosave drafts or slower events.

johnwbaxter commented 3 months ago

If anyone wants a simple way of sorting this on an actual entry in the CMS, you can just go to the super table field in question, fire up the entry edit form in your browser, open the browser inspector and remove the extra supertable node instances and then hit save on the entry. Next time you edit it, you'll only see the one field.