-
Notifications
You must be signed in to change notification settings - Fork 14
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
IBX-6937: Changed maxFileSize value to float type for Image Field type #291
Conversation
dabd3c5
to
e144f58
Compare
e144f58
to
83fc044
Compare
Why is exact reason to change data type from int to type ? |
One of our client's requirements is to set max image size to 1.5 MB in DAM . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is failing for me when I reinstall the database, the failure is:
In MigrationExecutor.php line 68:
Executing migration "2023_01_05_13_00_create_customer_content_type.yml" failed. Exception: Unable to add field `image` to Content Type `customer`.
In ContentTypeCreateStepExecutor.php line 168:
Unable to add field `image` to Content Type `customer`
In ContentTypeService.php line 1303:
Content Type Field definitions did not validate
This migration contains the following fragment:
validatorConfiguration:
FileSizeValidator:
maxFileSize: 10
AlternativeTextValidator:
required: false
I dug a bit deeper and the validation error is:
array(1) {
[0]=>
object(Ibexa\Core\FieldType\ValidationError)#22454 (4) {
["singular":protected]=>
string(68) "Validator %validator% expects parameter %parameter% to be of %type%."
["plural":protected]=>
NULL
["values":protected]=>
array(3) {
["%validator%"]=>
string(17) "FileSizeValidator"
["%parameter%"]=>
string(11) "maxFileSize"
["%type%"]=>
string(5) "float"
}
["target":protected]=>
string(32) "[FileSizeValidator][maxFileSize]"
}
}
Is it possible that we have to change something in migrations as well?
83fc044
to
22d56db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All works well on MySQL.
On PostgreSQL it's not possible to specify decimal fractions other than 0.5 - for example entering 0.1
ends up with the following error:
[2023-11-27T19:03:43.588031+00:00] app.ERROR: An error has occurred while handling form submission: Database error {"exception":"[object] (Doctrine\\DBAL\\Exception\\DriverException(code: 0): An exception occurred while executing 'UPDATE ezcontentclass_attribute SET serialized_name_list = ?, serialized_description_list = ?, serialized_data_text = ?, identifier = ?, category = ?, placement = ?, data_type_string = ?, can_translate = ?, is_thumbnail = ?, is_required = ?, is_information_collector = ?, is_searchable = ?, data_float1 = ?, data_float2 = ?, data_float3 = ?, data_float4 = ?, data_int1 = ?, data_int2 = ?, data_int3 = ?, data_int4 = ?, data_text1 = ?, data_text2 = ?, data_text3 = ?, data_text4 = ?, data_text5 = ? WHERE (id = ?) AND (version = ?)' with params [\"a:1:{s:6:\\\"eng-GB\\\";s:14:\\\"New field type\\\";}\", \"a:1:{s:6:\\\"eng-GB\\\";N;}\", \"N;\", \"field_6564b6e80e9dc\", \"content\", 3, \"ezimage\", 1, false, 0, 0, 1, null, null, null, null, 102.4, 0, null, null, \"KB\", null, null, null, null, 243, 1]:\n\nSQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: \"102.4\" at /Users/mareknocon/Desktop/Sites/v4_4/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php:102)\n[previous exception] [object] (Doctrine\\DBAL\\Driver\\PDO\\Exception(code: 22P02): SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: \"102.4\" at /Users/mareknocon/Desktop/Sites/v4_4/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18)\n[previous exception] [object] (PDOException(code: 22P02): SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: \"102.4\" at /Users/mareknocon/Desktop/Sites/v4_4/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:117)"} []
invalid input syntax for integer: \"102.4\"
(102.4 = 0.1 * 1024)
It works with 0.5 because the result is an integer
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now!
v4.6
This PR changes max file size value from integer to float type for Image field type. Cleandata schema is also updated to store float value in dataFloat1 column instead of dataInt1. There is also added additional info to dataText1 column that contains proper size unit set as MB.
Checklist:
$ composer fix-cs
).@ibexa/engineering
).