[5.x]: "Save as a new draft" drops all nested entries (Matrix content) from the new draft
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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
- Open a published entry that has a Matrix field with a few nested entries.
- Create a draft of it, then save the draft.
- From that draft, choose "Save as a new draft" from the save menu.
- 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
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 712
- Avg merge
- 13h 5m
- Merged PRs (30d)
- 328
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from craftcms/cms
-
bug repo:cms
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
craftcms/cms#20248 · 1 comment ·
Maintainers usually reply within 1 day
-
bug repo:cms
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
craftcms/cms#20205 · 1 comment ·
Maintainers usually reply within 1 day
-
bug repo:cms
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
craftcms/cms#20203 · 1 comment ·
Maintainers usually reply within 1 day
-
[5.x]: Moving an asset with “Replace it” throws TypeError: volumeUid must be of type string, null givenPossibly taken @i-just claimed this 5 days ago. Openbug repo:cms
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
craftcms/cms#20128 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
bug repo:cms
Difficulty 3/5 1-2 days Newbie friendliness 65/100
craftcms/cms#20204 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
Recognise PHP_CodeSniffer (`phpcs`) as a linterPossibly taken @HarshRajSinghania claimed this today. Openenhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
MustacheCase/zanadir#507 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
jwage/phpamqplib-messenger#163 ·
-
Newsletter subscription page logs Undefined array key "nw_error" on every GETPossibly taken @Codencode claimed this today. Open
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
PrestaShop/ps_emailsubscription#145 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100