cms
cms copied to clipboard
Project Config rebuild creates inconsistencies
I know this has been mentioned in a few issues, but I wanted to document a good couple of issues that would be great to resolve. Each time we rebuild the project config for projects, we find there are oodles of changes, which kind of freaks me out.
Most are harmless, but the constant level of change means that we can easily overlook potentially incorrect changes or bugs. If there are always harmless changes we get used to just committing everything blindly, which isn't great.
Below are some examples:
Type changes, including integers and booleans. See https://github.com/craftcms/cms/issues/6979
field: 2642eb7b-2a92-4acf-9bb7-68adaf91310f
name: Columns
-sortOrder: 25
+sortOrder: '25'
-required: '0'
+sortOrder: false
settings:
- default: ''
+ default: false
-titleFormat: ''
+titleFormat: null
Array changes, seems to expand serialised arrays sometimes
-childBlocks:
- - card
+childBlocks: '["card"]'
field: 2642eb7b-2a92-4acf-9bb7-68adaf91310f
fieldLayouts:
- -
+ 085c0254-f2ed-48f8-b8cc-915776480da8:
tabs:
-
elements:
-
fieldUid: e2dcbd9e-0478-40ec-886a-b7210d695a22
instructions: null
label: null
enableVersioning: true
handle: news
name: News
previewTargets:
-
- label: 'Primary entry page'
- urlFormat: '{url}'
+ __assoc__:
+ -
+ - label
+ - 'Primary entry page'
+ -
+ - urlFormat
+ - '{url}'
+ -
+ - refresh
+ - '1'
propagationMethod: all
siteSettings:
011ae8e8-6cf1-434b-a64f-bd430fc3354b:
enabledByDefault: true
hasUrls: true
template: news/_entry
uriFormat: 'news/{postDate.year}/{slug}'
User Photos asset volume's field layout keeps getting re-created each time I run rebuild, despite not touching it at all.
userPhotos--a35713a1-7237-49a1-ac3e-0fa1d1b5bded.yaml
fieldLayouts:
- f8017d72-d47a-4715-91de-93ef22515ee4:
+ ea9c4d86-95af-453d-bb31-6e7fe48f7953:
tabs:
-
elements:
-
autocapitalize: true
autocomplete: false
autocorrect: true
fieldLayouts:
- ea9c4d86-95af-453d-bb31-6e7fe48f7953:
+ b8889af8-68ce-444e-b4d5-1c6d1585d6c9:
tabs:
-
elements:
-
autocapitalize: true
autocomplete: false
autocorrect: true
This can be pretty consistently reproduced by saving a section or a field, which will trigger any of the above changes to the yaml files. Then, triggering a project config rebuild will trigger more changes - just feels like it's always changing!
There's probably more examples, and I'll add them as I come across them.
Additional info
- Craft version: 3.5.15.1
- PHP version: 7.2
- Database driver & version: MySQL 5.7.30
Yeah it still happens to a degree due to the fact that MySQL returns all data as strings. It happens a bit less in 3.5 than before due to changes in 2897e6353545997146d7612c2c74f8cba3ec535e, but still plenty of places where it’s still expected.
Will be resolved in Craft 4 when we add type declarations to all public properties – something we can’t do until Craft requires PHP 7.4+.
@brandonkelly As a plugin developer, I for one really appreciate those getConfig()
methods as well, and including them in plugins for consistency.
User Photos asset volume's field layout keeps getting re-created each time I run rebuild, despite not touching it at all.
fieldLayouts: - f8017d72-d47a-4715-91de-93ef22515ee4: + ea9c4d86-95af-453d-bb31-6e7fe48f7953: tabs: ...
I'm seeing this behavior as well (v3.3.3) — on ALL Volumes, not just User Photos.
Unlike some of the other wonky inconsistencies mentioned, this one seems like it could be separate from MySQL data-typing issues...? (Why would a Project Config rebuild cause Volumes' field layouts to get deleted/re-created?)
@michaelrog Yep, all volumes encounter this as well, but not any other element collections (sections, category groups, etc)
Right — What I'm suggesting is: YAML vars take inconsistent types because MySQL returns all data as strings
and Volumes' field layouts erroneously change UID on every Project Config rebuild
are two different issues. (The former may be resolved in Craft 4, but the latter probably doesn't need to wait.) @brandonkelly, should I spin that off as a new separate issue?
@michaelrog Sure