sebastian-lenz / craft-linkfield

Link field for Craft 3
MIT License
122 stars 66 forks source link

Compatiblity issue with Neo, all blocks get randomly deleted if one or more contain a typed link field #233

Open lenvanessen opened 2 years ago

lenvanessen commented 2 years ago

Hi There,

We're encountering an issue with this plug-in when it's used inside a Neo field. As soon as you propagate an entry to a new site, all the pageparts dissapear. Possibly, this also occurs when combing with a Matrix field, as the share some of the same structure, but I haven't gotten a change to test this. At first, we thought this was a Neo problem, so we created a ticket there: https://github.com/spicywebau/craft-neo/issues/631

But it turns out it's caused by the Link Field plug-in, and not Neo. I verified this by removing converting all link fields to regular text fields, and the problem went away. The author has summed up some hypothesis in his conclusion on the ticket, but hopefully you can dig-into it further and resolve the issue.

Our section is set to "Let each entry decide what site to propagate to"

Steps to reproduce

I can provide a composer.json, db and screenshare if it helps.

maxstrebel commented 2 years ago

I can confirm, that Link Fields in a NEO Block are "incorrectly detected as being modified" as Thomas notes in the initial post. When I add a new block to NEO, all Typed Link Fields which are on their default state and set to "No Link" get marked as modified, though they're not.

image

This happens to all Typed Link fields on the page, not only ones in a newly created block.

lenvanessen commented 2 years ago

@maxstrebel do the blocks also disappear on your site? I'm fine with the change detection being a bit off, but the content that goes missing is a real issue for us

maxstrebel commented 2 years ago

I'm currently trying to reproduce it reliably. We have mutex lock problems and had reports from users with scrambled block nesting, missing blocks, crashes in the backend etc. - but I had no luck reproducing it reliably.

That said: I'm actively working on reproducing it.

lenvanessen commented 2 years ago

@maxstrebel if you want, I got the perfect database and installation to reproduce it 100% of the time;) If your intent is to create a pr and help fix this problem in the plug-in, i'd be happy to assist you there

maxstrebel commented 2 years ago

I'm on the hunt for another bug right now. So I'm afraid I can't help, yet.

gaelpleeroy commented 1 year ago

I have the same issue of blocks getting deleted, but when switching the Entry Type of an entry (when you have multiple Entry Types, try in a Structure for example). Even on a one site installation. Is there anything we can do? I'm considering removing the plugin in the meanwhile.

gglnx commented 1 year ago

I have the same issue with a Matrix field. If a block with a link field which allows (No Link) is present and no link is selected, all others blocks will be deleted while propagation into other sites.

gglnx commented 1 year ago

The problem is that Craft registers fields that report that they are empty (via isValueEmpty) by setInitialDeltaValue with null. Before saving an entry Craft compares this initial value with the existing fields on the page and detects a difference (because the link fields contains inputs and selects for type, the settings for every link type, etc.) and modifiedDeltaNames gets filled:

SCR-20230111-qio

(This is the submitted entry right after hitting Strg+S on a entry without changing anything.)

This triggers the Matrix field to re-save the blocks (because the field is marked as dirty) but somewho clashes this with the propagation of the blocks to other sites. I don't if this is a bug too.

gglnx commented 1 year ago

As I see it a quick fix would be that the link fields always returns false from isValueEmpty(). I don't think that a validation from Craft if the field is empty is really needed.

gateszies commented 1 year ago

We're seeing a related bug with blocks being scrambled or deleted when the current version of an entry is merged into a pre-existing draft. We originally thought this was a bug with the Neo plugin but it appears to be because of the Typed Link Field.

We've also seen the same issue @maxstrebel mentioned with Typed Link Fields in their default state being flagged as Modified when no content has been changed.

ccchapman commented 1 year ago

We are experiencing Neo blocks disappear and also using Typed Link fields.

@sebastian-lenz Can you advise if this issue is being investigated?