getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.27k stars 167 forks source link

[3.8.0-rc.2] $page->createChild throws "duplicate error" #4736

Closed sebastiangreger closed 1 year ago

sebastiangreger commented 1 year ago

Note: some obsolete descriptions erased; see thread below for more detailed investigation on when this error occurs

Description

Trying to add a new note using

page('notes')>createChild([
    'slug' => 'test',
    'template' => 'post',
    'draft' => true,
]);

I receive an error Post could not be created: A page draft with the URL appendix "test" already exists. The error does not occur with 3.7.x but occurs starting 3.8.0-rc.1 ~, but only if the content has already assigned UUIDs (it can only be replicated with a 3.7 starterkit after running Kirby\Uuid\Uuids::populate(); before populating the starterkit content with UUIDs it works without throwing that error).~

~## To reproduce~ ~1. Install a fresh 3.7 starterkit and upgrade the kirby folder to 3.8.0-rc.2~ ~2. Create site/template/sandbox.php~ ~3. Enter above code into the template and call the sandbox page – all works fine, new draft created~ ~4. Delete the newly created draft to reset the scenario~ ~5. Run Kirby\Uuid\Uuids::populate() once using that sandbox~ ~6. Enter above code back into the template again and call the sandbox page~ ~7. See error~

Your setup

3.8.0-rc.1 + 3.8.0-rc.2

Additional note

Typo in the release notes for 3.8-rc.1: Kirby\Uuids\Uuids::populate() should be Kirby\Uuid\Uuids::populate()

distantnative commented 1 year ago

@sebastiangreger after running Kirby\Uuid\Uuids::populate() is there anything suspicious in content/notes that explains the error?

sebastiangreger commented 1 year ago

@lukasbestle @distantnative I'm really sorry for any confusion caused, but now I can't even reproduce it myself anymore, following my own instructions above :roll_eyes: …need to find a quiet moment where I can focus properly.

Closing this ticket as a false alert for now, until I hopefully find less rushed time next week to track where that error in my more complex setup may originate from. I'll get back to you if I find any indication whether this really is a regression or just some custom code incompatible with 3.8.

doup commented 1 year ago

I'm getting this error when creating a draft from the panel. The file is created with just the UUID (the Title/Slug is not saved) and I get the following error:

image

Here the related blueprints if it's of any help: https://gist.github.com/doup/0331a72352553fe846908e074637ba7a

sebastiangreger commented 1 year ago

@doup That indeed sounds like the same error. I am still investigating what exactly is wrong with my site that causes this (as indeed it's fine with the Starterkit; I probably got confused with too many "Sandbox" tabs open yesterday).

My current lead is that it appears to have to do with the label field in the blueprint. On my site, I had something like label: {{ page.fieldname.value }} and once I replaced that with a plain label: Foo the error disappeared. This is wild speculation, but if your error is related, it might have to do with the translations in the label field? What happens if you replace those with plain labels without the translation markup?

sebastiangreger commented 1 year ago

The same error also appears when I set a help: {{ page.uuid }} attribute for a field. It works fine for existing pages, neatly displaying the UUID as a help text under the field, but when creating a new page using the "Add" dialog an empty page with only the Uuid field is created and the panel displays the error as in the screenshot above.

…as with the title field, using a static value (help: Bee Bop) works just fine.

distantnative commented 1 year ago

My suspicion for @doup is the blueprint query for permalink. I think both of your problems derive from blueprints that try to get uuids in one way or another. That would be fixed with the linked PR hopefully.

sebastiangreger commented 1 year ago

I think both of your problems derive from blueprints that try to get uuids in one way or another.

A quick test confirms: using rc.2, help: {{ page.uuid }} causes the error, but help: {{ page.title }} does not.

That would be fixed with the linked PR hopefully.

Affirmative – after the change it's all smooth sailing.

bastianallgeier commented 1 year ago