Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

project-config/rebuild removes entry types that don't have a field layout since 3.1.34 #4600

Closed
benface opened this issue Jul 17, 2019 · 8 comments

Comments

@benface
Copy link
Contributor

benface commented Jul 17, 2019

After updating to Craft CMS 3.1.34 (from 3.1.32.1), I ran ./craft project-config/rebuild since I saw in the release notes for 3.2 that "if you’ve ever run the project-config/rebuild command [and I have], it’s highly recommended that you run it again with Craft 3.1.34, before updating to Craft 3.2." I looked at the changes to project.yaml quickly and everything looked good, so I pushed to production, synced the changes, and... some sections ended up losing all their entries. I looked at the changes to project.yaml more carefully and it seems that the rebuild command removed all the entry types that didn't have a field layout, which in turn deleted entries belonging to that entry type. Here's an example:

Before running the rebuild command:

  7d79c3ca-57d0-4828-ac16-0798f5e81770:
    name: 'Categories'
    handle: categories
    type: structure
    enableVersioning: true
    propagateEntries: true
    siteSettings:
      368833f3-8d11-4631-ad8d-e8216490db66:
        enabledByDefault: true
        hasUrls: true
        uriFormat: 'blog/{slug}'
        template: blog/category
    structure:
      uid: e8726a0c-c27a-4c81-989d-d88e53e99647
      maxLevels: 1
    entryTypes:
      0255e490-97eb-4a5e-8432-6bb2c1484d64:
        name: Category
        handle: category
        hasTitleField: true
        titleLabel: Title
        titleFormat: ''
        sortOrder: 1

After running the rebuild command:

  7d79c3ca-57d0-4828-ac16-0798f5e81770:
    name: 'Categories'
    handle: categories
    type: structure
    enableVersioning: true
    propagateEntries: true
    structure:
      uid: e8726a0c-c27a-4c81-989d-d88e53e99647
      maxLevels: 1
    siteSettings:
      368833f3-8d11-4631-ad8d-e8216490db66:
        enabledByDefault: true
        hasUrls: true
        uriFormat: 'blog/{slug}'
        template: blog/category

Notice how the whole entryTypes node is missing. Thankfully I had a backup but I think this is a pretty serious bug.

Additional info

  • Craft version: 3.1.34
  • PHP version: 7.3.3
  • Database driver & version: MySQL 5.7.25
@brandonkelly
Copy link
Member

The rebuild command basically just rebuilds the whole project config based on what is actually in the database. Before Craft 3.1.34 there was a bug where the newly generated project config was being merged into the current one, rather than actually rebuilding it from scratch.

So what likely happened here is you had entry types on production that didn’t exist locally, and when you ran rebuild, those entry types were discarded.

If you have a database backup from production before applying the changes, import that locally, then run rebuild, and then production shouldn’t be affected.

@benface
Copy link
Contributor Author

benface commented Jul 17, 2019

@brandonkelly No, that's not it unfortunately. Those entry types exist in production. I just did what you said (imported the production DB locally and then ran rebuild) and the same thing happened.

@benface
Copy link
Contributor Author

benface commented Jul 17, 2019

Sorry, I mean the same entry types that exist in production exist locally. I haven't changed the content model in a while.

@brandonkelly
Copy link
Member

@benface Are you sure they exist with the same UIDs?

@benface
Copy link
Contributor Author

benface commented Jul 17, 2019

@brandonkelly Yes, 100% sure. :) I just sent a DB dump and my pre-rebuild project.yaml to [email protected].

@brandonkelly brandonkelly reopened this Jul 17, 2019
@martinleveille
Copy link

martinleveille commented Jul 23, 2019

Same here, every pages was tested on my local machine and after the staging deployment, 2 single section lost their entry type.

I will try to get more info on this.

EDIT: I confirm that the 2 single sections was the only 2 without fields in their field layout.

Before

  f037949e-2884-495a-a618-48109b5198a6:
    name: 'Page - Calendrier'
    handle: pageCalendrier
    type: single
    enableVersioning: false
    propagateEntries: true
    siteSettings:
      e3970f56-b6e8-421e-b350-f25c76f166dd:
        enabledByDefault: true
        hasUrls: true
        uriFormat: calendrier
        template: _pages/calendrier/index
    entryTypes:
      91fd2919-9de4-42a6-bb12-136013607deb:
        name: 'Page - Calendrier'
        handle: pageCalendrier
        hasTitleField: false
        titleLabel: null
        titleFormat: '{section.name|raw}'
        sortOrder: 1

After:

  f037949e-2884-495a-a618-48109b5198a6:
    name: 'Page - Calendrier'
    handle: pageCalendrier
    type: single
    enableVersioning: false
    siteSettings:
      e3970f56-b6e8-421e-b350-f25c76f166dd:
        enabledByDefault: true
        hasUrls: true
        uriFormat: calendrier
        template: _pages/calendrier/index
    propagationMethod: all

@brandonkelly
Copy link
Member

Craft 3.1.34.1 is out now with a fix for this, and that is the new breakpoint release for people updating from Craft 3.1.20 or later (when the project-config/rebuild command was added).

We will release Craft 3.2.6 tomorrow which will also include a fix for this for people already on 3.2.

To get the 3.2 fix early, change your craftcms/cms requirement in composer.json to:

"require": {
  "craftcms/cms": "dev-develop#925b844b0aed74a4ea056c9e9e6f8417b3bcd3f1 as 3.2.5.1",
  "...": "..."
}

Then run composer update.

@brandonkelly
Copy link
Member

3.2.6 is out with the fix as well, now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants