craftcms / craftcms/cms

[5.x]: Nested, inline-editable Matrix field with "Min entries" set get recursively created on edit page pageload

Open
#14,355 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

What happened?
Description

If an inline-editable Matrix field, with "Min entries" set to 1 and only a single entry type selected, is added to its own entry type (i.e. the field is nested within itself), nested entries are recursively created when the edit page loads. It's also impossible to save the entry.

...I get that this is an odd thing to do – but I wanted to see what would happen if I did, and the results are interesting 🙂

Steps to reproduce
  1. Create a Matrix field. Set the "Min entries" setting to 1 and "View Mode" to "As inline-editable blocks". Create a new entry type for the Matrix field via the "Create" button, but don't add any fields to the entry type yet. Save the field.

  2. Edit the entry type that was just created; adding the same Matrix field to its field layout.

  3. Add the Matrix field to a section entry type's field layout (or, add the same entry type the Matrix field uses, to a section).

  4. Create an entry in that section, and observe that nested entries are created ad infinitum whenever the edit page is loaded. Most of the time only 2 or 3 nested entries are created, sometimes it actually keeps going, creating nested entries indefinitely in a loop (although I have trouble reliably reproducing that)

https://github.com/craftcms/cms/assets/298510/32fc0edb-5fc8-49e0-bca3-03a7467bd529

Expected behavior

I'm not sure!

Actual behavior

A number of nested entries get created every time the edit page is loaded.

Craft CMS version

5.0.0-beta.1

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue from the listed Matrix-field setup and follow the section entry edit page as nested entries are created on load. Determine the intended behavior for a self-nesting inline-editable field with Min entries set to 1; done should prevent recursive creation and allow the entry to be saved, subject to maintainer clarification.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.