Cms: Project config likes to switch between data types.

Created on 21 Jun 2019  路  8Comments  路  Source: craftcms/cms

Description

Perhaps this happens when craft project-config/rebuild gets run, but we end up with huge diffs occasionally that are merely just type switching, for example:

required: '0'
sortOrder: '1'

Becomes:

required: false
sortOrder: 1

Steps to reproduce

  1. Make changes to an existing field in Craft.
  2. If that doesn't work, run: craft project-config/sync and then craft project-config/rebuild.

Additional info

  • Craft version: 3.1.31
  • PHP version: 7.x
enhancement project config

Most helpful comment

I just refactored how project config rebuilding works internally for Craft 3.5, and now all built-in system components use the same config generation methods that are used when saving the components normally. So you shouldn鈥檛 see any more type juggling going forward.

All 8 comments

We鈥檝e been improving typecasting in Craft so this sort of thing is more rare, but I will keep this open so we can note any future progress we make. The example you showed is a step in the right direction though; it鈥檚 whatever stored '0' and '1' to begin with that is the issue.

This issue is still happening, even with things like plain text fields on a fresh Craft install. It seems to occur on certain type of properties. Ones I found to be problematic regularly

  • searchable: goes from true to 1
  • uriFormat: goes from null to ''
  • required in fieldLayouts > tabs changes from 0 to false
  • sortOrder in fieldLayouts > tabs changes from '3' to 3

some examples:

- searchable: true
+ searchable: '1'
  fieldLayouts:
      f8eca5a5-12be-4be4-911f-cd70352174a1:
        tabs:
          -
            fields:
              0ac19cf2-7cff-402d-88f5-ee1c455fe85d:
-                required: '0'
-                sortOrder: '3'
+                required: false
+                sortOrder: 3

Additional info
Craft version: 3.4.23
PHP version: 7.4.2

Right, it鈥檚 still not fully solved, and won鈥檛 be until we can start taking advantage of typed properties in PHP 7.4. The issue is that all data comes back as strings from MySQL.

I just refactored how project config rebuilding works internally for Craft 3.5, and now all built-in system components use the same config generation methods that are used when saving the components normally. So you shouldn鈥檛 see any more type juggling going forward.

This is still an issue as of Craft 3.5. This is the result of a /craft project-config/rebuild command

image

Additional info
Craft version: 3.5.1
PHP version: 7.4

@jan-dh What file is that?

Had the issues in about 10 files. This is a basic starting setup though. Some examples:

- config/project/fields/intro--957980f8-81e5-40dc-a6b6-53a8007d820b.yaml
- config/project/sites/sitename--daab03ee-7bda-4b63-be9e-722444ab39f5.yaml
- config/project/superTableBlockTypes/ac263991-1837-4325-a1fa-379e35856a25.yaml
- config/project/fields/entryTypes/sitemap--5702ad47-2a0a-4519-8990-b848b7ec6c9c.yaml

As far as I can tell, atm in fields, sites, superTableBlockTypes, entryTypes.

Just searched the codebase and every place we are setting sortOrder or searchable on a config, we are properly typecasting them to integers/booleans. So suspect this is coming from a plugin. If you send your Composer files and a database backup into [email protected] we can look into it further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandonkelly picture brandonkelly  路  3Comments

leigeber picture leigeber  路  3Comments

RitterKnightCreative picture RitterKnightCreative  路  3Comments

angrybrad picture angrybrad  路  3Comments

timkelty picture timkelty  路  3Comments