-
Notifications
You must be signed in to change notification settings - Fork 642
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 values changing between strings and boolean values in different environments #3695
Comments
Can you look for the read-only error in your staging server’s |
Sure! So when I first apply the project config I get this error in staging: Then I receive the "Changes to the project config are not possible while in read-only mode" error when I choose "Use project.yaml" And here's the stack trace:
|
Thanks! Just fixed this for the next release. You can patch your local install by changing your "require": {
"craftcms/cms": "dev-develop#6733f86f8a56f0dba61d84d2fa1124b3fad87aee as 3.1.3",
"...": "..."
} and then run |
You guys are so dang fast, thanks a ton! |
When migrating from Craft 3 to 3.1, the values in project,yaml were like that:
But if I save a section, field or anything in the control panel in local, the values change to that:
Why is there this inconsistency? Also, is there a way to regenerate all the project.yaml to have the same format everywhere in the file (boolean and int instead of strings)? |
It changes based on where the data is coming from. In the initial config generation it’s coming from the database, and if you’re using MySQL, then “boolean” values will be represented as If the data is coming from a POST request, then we tend to typecast the post data to actual booleans/numbers. We have considered normalizing DB data when querying it, but it would be a ton of effort and/or it would slow everything down, depending on how we implemented it. (Active Record classes do a decent job of auto-typecasting for example, but it does so by running additional queries to the DB to learn about the schema, and storing all that data, so it comes at a performance cost.) It’s only an issue for MySQL, whereas PostgreSQL always has the correct types, both because it does support a And there’s good news on the horizon for MySQL installs: PHP 7.4 is going to have typed property support, which means that we will be able to normalize the values right at the property level, e.g. public bool $required;
public int $sortOrder; Which means the values will be typecasted correctly right as they are assigned to objects, regardless of what the PDO layer gave us. |
Ok, thanks a lot for the explanation! |
@aaronbushnell head ups - I just edited @brandonkelly's comment above with the composer.json snippet to use Craft version "3.1.3" instead to "3.0.3", just FYI in case you already used the snippet. |
Ah, thanks @andris-sevcenko! |
Just merged in #4167 which properly typecasts all core integer and boolean values as they’re saved to the project config. Up to plugin developers to follow suit, but this should take care of most of the awkwardness. |
@brandonkelly Thanks for the update, but it seems that some values are still string instead of boolean or integer. For example, after running |
Yeah good point, this change won’t affect custom field settings, plugin settings, etc. |
Turns out the added complexity is not really worth it. The settings are stored as a json string, so it wouldn't suddenly change from |
This reverts commit 3bef91d.
I did a
So maybe the rebuild didn't do the sections or these values are not always typecasted. |
@smcyr Doh. Should be all better with the next release |
Description
I've updated a project to the latest version of Craft and enabled project config control. When I make changes locally I'm seeing values such as...
But when I apply this config to our staging environment these are changed to
Because this change occurs I'm unable to set
"allowAdminChanges" => false
as I receive an error saying changes to the project config are "read-only".Additional info
The text was updated successfully, but these errors were encountered: