Advanced editor - upload failing - incorrect integer value
I'm finally getting around to experimenting with the advanced editor which is really neat, but I'm running into a problem with the upload feature. Specifically when I upload a file (image, text file or anything else) I get an exception occurring:
PHP Fatal error: Incorrect integer value: '' for column 'ThumbWidth' at row 1|Gdn_Database|Query|insert GDN_Media
Which is correct - the code defaults a default as ''
for ThumbWidth but the Media
table is: ThumbWidth smallint(5) unsigned DEFAULT NULL,
.
So if there is no thumbnail it should presumably be setting a null
value rather than empty string.
I'm sure others use this feature, so I'll have done something wrong, but I can't figure out what. Does anyone have any ideas?
Thanks,
Allan
Best Answer
-
River MVP
probably due to strict mode. you need to disable strict mode in your sql.ini
remove this STRICT_TRANS_TABLES
I suspect you would need to change ThumbWidth and ThumbHeight to 0 to allow strict mode to work since
@allanj said:
I'm finally getting around to experimenting with the advanced editor which is really neat, but I'm running into a problem with the upload feature. Specifically when I upload a file (image, text file or anything else) I get an exception occurring:PHP Fatal error: Incorrect integer value: '' for column 'ThumbWidth' at row 1|Gdn_Database|Query|insert GDN_Media
Which is correct - the code defaults a default as
''
for ThumbWidth but theMedia
table is:ThumbWidth smallint(5) unsigned DEFAULT NULL,
.probably should be
// Not all files will be images.
$thumbHeight = 0;
$thumbWidth = 0;So if there is no thumbnail it should presumably be setting a
null
value rather than empty string.I'm sure others use this feature, so I'll have done something wrong, but I can't figure out what. Does anyone have any ideas?
Thanks,
Allanprobably due to strict mode. you need to disable strict mode in your sql.ini
remove this STRICT_TRANS_TABLES, if you don't modify the plugin.If you modify the plugin I suspect you would need to change ThumbWidth and ThumbHeight to 0 to allow strict mode to work, my impression - an empty string inserted into a MySQL integer data type or column will cause the error.
Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.
7
Answers
probably due to strict mode. you need to disable strict mode in your sql.ini
remove this STRICT_TRANS_TABLES
I suspect you would need to change ThumbWidth and ThumbHeight to 0 to allow strict mode to work since
probably should be
// Not all files will be images.
$thumbHeight = 0;
$thumbWidth = 0;
probably due to strict mode. you need to disable strict mode in your sql.ini
remove this STRICT_TRANS_TABLES, if you don't modify the plugin.
If you modify the plugin I suspect you would need to change ThumbWidth and ThumbHeight to 0 to allow strict mode to work, my impression - an empty string inserted into a MySQL integer data type or column will cause the error.
Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.
Thanks. I've sent a pull request. Set the defaults to be 0, but they should really be
null
.