-
Notifications
You must be signed in to change notification settings - Fork 5
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
Ezp 16509 changing db default values #188
base: master
Are you sure you want to change the base?
Conversation
The 4th patch was needed to resolve a conflict. |
Fifth patch is to make the unit tests happy. |
As I understand it, the problem is that you cannot remove a default value for an Integer field type. I have experienced this problem. What is the more concrete editorial use case? The editor should be able to store a blank value? We need to force the editor to enter a value but the default of "0" means they can get away with not entering something? Is an alternative to override the edit template for that datatype? (Not ideal, but just want to understand the use case fully.) If we proceed with the patch, how do we check whether other field types using data_int3 are affected? |
I think you got it already. It makes a difference if the value is 0 or null (nothing entered by the editor). Quick example: |
How we check weather other fields type are affected We cannot guarantee it. The only things to improve the situation are:
The risk is limited to the editorial experience and won't affect already stored data - so that's a lot less risky. For example the ezstring datatype has a max char configuration. That's a potential feature that could break. |
only to trigger travis
it's so buggy
Test on CSM. Report back. Decide later if we'd like to merge it. |
Why this patch?
When editing a content class, you can define a default value for the datatype ezinteger. You cannot remove the default value: as soon as you save the class changes with a Null value for the ezinteger default value - the system will store the '0' number for the default value.
In other words, when editing content object for this class, you cannot have a null value for the ezinteger attribute. But it makes a difference if the attribute value is set and '0'. Or if the attribute value was not set and Null.
Background
The default value for ezinteger attributes are stored in the DB table ezcontentclass_attribute. It uses the data_int3 field.
The database table to store class attributes (not object attributes) allows null values for all data_int and data_float fields - Default column is set to 'Null':
The problem is the PHP wrapper class for this DB table:
48a01e5
It uses the default value '0' for those fields. So if you try to save a 'Null' value for data_int3, ezpublish will replace it with the value '0'.
3 commits
I divided the patch into 3 commits on purpose.
Risks
This patch is affecting all class attributes (not object attributes) - not only ezinteger. There is the risk that this patch introduces issue for other class attribute definitions (if they use the DB fields data_intX/data_floatX).