craftcms / craftcms/cms

Bug happened when saving an Entries field, the selected entries are there twice.

Open
#7,104 18 comments 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

Description

A weird bug happened when saving an Entries field.

Steps to reproduce

On my Catalog section, under a Entries field, I select 2 entries (from a Product (structure section)). Save. And when the page reload, each Products are there 2 times. I was thinking about a UI issue, but if a query this specific entry I can see 4 ids (2 x 2).

To see it in action: https://recordit.co/FYxYyMGIUW

Notes:

  • I try with one, two and more Products, same issue. If I delete the dups and save back, they came back again.
  • I try with a fresh new Catalog, the same issue happened. But if I try with a fresh Products, the issue dont happen.

I then try to resave all the entries (craft cli), a ./craft utils/repair/section-structure product, the issue is still there.

Any way to get that fix? I got 400+ products create by the client, so start over isnt a solution.

Additional info
  • Craft version: 3.5.15
  • PHP version: 7.3.24
  • Database driver & version: MySQL 10.1.46

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

Start with the Catalog and Products reproduction steps, then inspect the Craft CLI entry point ./craft utils/repair/section-structure product and compare the saved entry IDs before and after reload. Done means selected Products persist once in a fresh Catalog and existing duplicated relationships can be repaired without recreating the 400+ products.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, php
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.