-
Notifications
You must be signed in to change notification settings - Fork 5
Statamic doesn't produce the directory and index.md files properly when creating a new page while having a non-default locale active #2531
Description
Describe the bug
Primary locale: English (EN, en_US, English, /)
Secondary locale: Portuguese (PT, pt_BR, Portuguese, /pt/)
If I create a completely fresh new page while having Portuguese locale active, upon clicking Save Statamic will create the directory .../site/content/pages/__test-page (does not contain a sorting number). Additionally, index.md within said directory will be blank except for a single line for 'id'. All contents are populated onto pt.index.md instead - i.e. id, title, fieldset, etc. values.
From then onwards:
- If I attempt to do a subsequent Save while still on the Portuguese, I'll be prompted with a "There was a problem saving your data" error (error in logs is pasted at the bottom). Statamic at this point has created another directory for the page: .../site/content/pages/_6.test-page (has a sorting number this time).
- Switching back to English, the contents are completely blank including a missing title - which has to be specified manually before I can then Save.
- Only now can both my English and Portuguese edit forms be Saved. This affects the index.md files in the newer directory which has the sorting number.
- Statamic prompts warnings of duplicate IDs sourcing from the two directories that were created in the process.
- When I delete the page that is visible on the CP, it deletes the directory without the sorting number, leaving the "correct" one in place.
To Reproduce
Steps to reproduce the behavior:
- Create an additional secondary site locale via Statamic CP Settings.
- Go to 'Pages' on the Statamic CP.
- Switch active locale to the secondary locale.
- Click 'Create Page' - secondary locale will still be active on the creation form.
- Click 'Save' to produce the new page (index.md files are produced).
Expected behavior
When creating a new page whilst having a secondary locale active, it should produce the relevant directory/files to the same outcome it would produce if I were to instead create (with a Save) the page while on the default locale prior to switching to the secondary locale and modifying that.
Screenshots
imgur album of screenshots: https://imgur.com/a/UBe1eyc
Environment details (please complete the following information):
- Statamic Version 12.11.20 (also tested on a downgrade to 12.11.10)
- Fresh install from zip archive, including demo "Redwood" content
- OS: macOS Catalina 10.15.7 (local dev) -and- Ubuntu 20.04 LTS (remote server A) -and- Ubuntu 18.04 LTS (remote server B)
- Browser: Google Chrome on Mac, Version 86.0.4240.183. Other browsers untested.
- Web Server: Valet+ (local dev) -and- Apache (remote server A) -and- Nginx (remote server B)
- PHP Version: 7.2.33 (local dev)
- Addons installed: None
Additional context
- Error message produced in the logs when attempting to Save (see Description):
[2020-11-11 09:18:04] production.ERROR: Cannot add [pages/_test-page/index.md] to Stache repository [pagestructure]. File at [pages/_6.test-page/index.md] already exists in repository [pages] with an ID of [43f8915e-b350-4dc0-90ea-d853cab828b9].
[2020-11-11 09:18:04] production.ERROR: League\Flysystem\FileExistsException: File already exists at path: pages/_test-page/index.md in /Users/lucaslim/dev/statamic/statamic/vendor/league/flysystem/src/Filesystem.php:405
-
A different accompanying issue: If I switch active locales whilst on the Create Page form, Statamic appends 'fieldset: home' onto my index.md file(s).
-
When attempting the same procedure on creating a new Collection entry, it leaves the default locale copy of the entry with a slug as its title, but there are no issues with directory/file creation nor any errors when attempting to Save.