[5.x]: "Save as a new draft" drops all nested entries (Matrix content) from the new draft

Aperta
#20,226 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
php
Ambito
backend

Direzione di ricerca

Start by tracing the “Save as a new draft” flow through elements/duplicate and compare it with Drafts::createDraft() and NestedElementManager::maintainNestedElements(). Reproduce the steps with a Matrix field and check whether the new draft receives nested entries and elements_owners rows; done means those entries are preserved.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug repo:cms
What happened?
Description

When you use "Save as a new draft" from an explicitly created draft, the new draft keeps the title and other plain fields, but every Matrix field comes up empty. The original draft and the canonical entry aren't affected.

We've reproduced this on three unrelated sites, none of which have custom code that touches drafts, duplication, or nested element ownership:

  • 5.11.5.1
  • 5.11.2 (a draft with 11 Matrix blocks produced a new draft with 0)
  • 5.10.4.1

The new draft gets no elements_owners rows. It looks like NestedElementManager::maintainNestedElements() skips nested elements for drafts and expects Drafts::createDraft() to copy them, but "Save as a new draft" goes through elements/duplicate instead, so nothing copies them.

On an entry with a Neo field (Neo 5.5.13), the same action returns a 500 instead: "The source element must be canonical."

Steps to reproduce
  1. Open a published entry that has a Matrix field with a few nested entries.
  2. Create a draft of it, then save the draft.
  3. From that draft, choose "Save as a new draft" from the save menu.
  4. Look at the Matrix field on the new draft.
Expected behavior

The new draft contains the same nested entries as the draft it was created from.

Actual behavior

The new draft's Matrix field is empty. The title and non-nested fields carry over.

Craft CMS version

5.11.5.1 (also reproduced on 5.11.2 and 5.10.4.1)

PHP version

8.4.10

Operating system and version

Linux (DDEV)

Database type and version

MySQL 8.0.40

Image driver and version

Imagick 3.8.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

These are from the 5.11.5.1 site, which is the one the environment details above describe.

  • Amazon S3 2.3.2
  • Amazon SES 3.1.0
  • CKEditor 4.11.4
  • Feed Me 6.11.0
  • Google Maps 5.2.3
  • Icon Picker 3.1.6
  • Imager X 5.2.1
  • Imager X AWS Serverless Transformer 3.0.2
  • JWT Authorization 5.0.1
  • Password Policy 5.1.3
  • RESTful API 5.0.0
  • Retour 5.0.14
  • Scout 6.0.0
  • SEOmatic 5.1.22
  • Sprig 3.7.3
  • Table Maker 5.0.7
  • Typogrify 5.0.3
  • Video Picker 2.1.6
  • Vite 5.0.2
Lingua principale
PHP
Stelle
3.6k
Fork
712
Merge medio
13h 5m
PR unite (30g)
328

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di craftcms/cms

Tutte le issue di craftcms/cms

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.