craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.22k stars 626 forks source link

[4.x]: Two entries referencing each other within a matrix field with validate related entries crashes CMS on save #14033

Closed TGriffiths88 closed 9 months ago

TGriffiths88 commented 9 months ago

What happened?

Description

We have a client site that has an entry field within a matrix field in a Neo content builder which enables users to reference another entry. We have two entries that were referencing each other via this field. As soon as you try and save the entry it crashes Craft with a permanent loading state. The only way to access the entries is to set them to disabled via the CLI.

We then trialled it outside of Neo, and outside of a matrix field to see what was causing the issue. A simple entry field on the entry works fine. But when used within a Matrix field it crashes. Removing the Validate related entries setting prevents this behaviour.

Steps to reproduce

  1. Create a channel
  2. Create a matrix field that has an entry field within a block. Ensure to turn on entry validation.
  3. Create two entries and relate each to the other via the matrix field created above.
  4. When you try and save the second entry, you should find it crashes the CMS.

Expected behaviour

It should be able to save the entry and then open the entry once saved.

Actual behaviour

Attempting to save with this reference setup causes the CMS to crash, and trying to open entries with this relationship causes the CMS to crash.

Craft CMS version

Craft Pro 4.5.12

PHP version

8.1.21

Operating system and version

No response

Database type and version

MySQL 8.0.33

Image driver and version

Imagick 3.7.0

Installed plugins and versions

{
        "besteadfast/craft-preparse-field": "2.0.2",
        "born05/craft-assetusage": "^3.2",
        "craftcms/aws-s3": "2.0.3",
        "craftcms/cms": "4.5.12",
        "craftcms/postmark": "3.0.0",
        "craftcms/redactor": "3.0.4",
        "dodecastudio/craft-blurhash": "2.0.5",
        "doublesecretagency/craft-inventory": "3.1.1",
        "nystudio107/craft-retour": "4.1.14",
        "nystudio107/craft-seomatic": "4.0.37",
        "presseddigital/linkit": "4.0.4.1",
        "putyourlightson/craft-dashboard-begone": "2.0.0",
        "spicyweb/craft-neo": "3.9.11",
        "vaersaagod/dospaces": "2.0.0",
        "verbb/tablemaker": "4.0.7",
        "vlucas/phpdotenv": "^3.4.0"
    }
Zae commented 9 months ago

I believe I might be hitting the same bug, but I was not referencing entries to each other but linking an entry to itself from within an neo field.

4.5.9 works fine, but somewhere in 4.5.10 or 4.5.11 it breaks. Don't know which version exactly because I can't run either version because of the psr3 issue.

brandonkelly commented 9 months ago

Craft 4.5.13 is out with a fix for this. Thanks for reporting!