craft-linkfield icon indicating copy to clipboard operation
craft-linkfield copied to clipboard

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

Open lenvanessen opened this issue 2 years ago • 11 comments

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

  • Create sites in Craft 4.1.2
  • Create a section
  • Create some neo blocks with a typed link field inside
  • Save an entry with some blocks
  • Add a new site to Craft
  • Propagate the page to that new site
  • Check the blocks, they're gone

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

lenvanessen avatar Aug 03 '22 08:08 lenvanessen

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.

maxstrebel avatar Aug 05 '22 09:08 maxstrebel

@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

lenvanessen avatar Aug 05 '22 09:08 lenvanessen

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.

maxstrebel avatar Aug 05 '22 10:08 maxstrebel

@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

lenvanessen avatar Aug 05 '22 10:08 lenvanessen

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

maxstrebel avatar Aug 05 '22 11:08 maxstrebel

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.

gaelpleeroy avatar Jan 03 '23 15:01 gaelpleeroy

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 avatar Jan 11 '23 17:01 gglnx

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 avatar Jan 11 '23 18:01 gglnx

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.

gglnx avatar Jan 11 '23 18:01 gglnx

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.

gateszies avatar Jan 25 '23 20:01 gateszies

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

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

ccchapman avatar Mar 09 '23 18:03 ccchapman