statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

Collection's folder.yaml file gets reset when using the importer. #2416

Open FumbleGrumble opened 5 years ago

FumbleGrumble commented 5 years ago

Describe the bug After using the importer to import data into a collection, the folder.yaml file for that collection resets to the following

order: date

If the collection is ordered by by alpha or number then going into the cp and navigating to Collections > Products will result in an error "There was a problem fetching your data..." Visiting the front end will result in the following error.

InvalidEntryTypeException in Entry.php line 201:
Entry date not present in a date-based entry: [collections/products/test-product.html]
...

To Reproduce

  1. Create a collection, any name, but I will be using "Products"
  2. Optional, set collection to sort by alpha or number
  3. Take note of the state of /site/content/collections/products/folder.yaml.
  4. Import something.
    {
    "collections": {
        "products": {
            "\/products\/test-product-import": {
                "order": "",
                "data": {
                    "title": "Test Product Import"
                }
            }
        }
    }
    }
  5. Visit /cp/collections/entries/products for an error "There was a problem fetching your data..."
  6. Observe that /site/content/collections/products/folder.yaml has been erased and replaced with order: date as its entire contents.

Expected behavior /site/content/collections/products/folder.yaml shouldn't get overwritten... and everything should work fine.

Environment details:

Additional context Problem has been observed across multiple sites in many versions of statamic v2.