Exception Updating Block With MariaDB 10.2.2
Permalink Browser Info Environment
Since upgrading our server to MariaDB 10.2.2 we have seen SQL Exceptions raised when editing the block. MaraiDB is rather fussy in its default configuration, and complains when incorrect data is pushed into various fields. We get exceptions like this:
'UPDATE btD3RandomImage SET bID = ?, fsID = ?, max_width = ?, max_height = ?, do_crop = ? WHERE bID = ?'
with params ["9286", "27", "1000", "667", false, "9286"]:
SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column `totalsto_c5`.`btD3RandomImage`.`do_crop` at row 1
This is because MariaDB has an sql_mode that includes STRICT_TRANS_TABLES, which prohibits boolean false from being saved into an integer field.
The fix I have added to the block controller save() method simply replaces:
with
'UPDATE btD3RandomImage SET bID = ?, fsID = ?, max_width = ?, max_height = ?, do_crop = ? WHERE bID = ?'
with params ["9286", "27", "1000", "667", false, "9286"]:
SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column `totalsto_c5`.`btD3RandomImage`.`do_crop` at row 1
This is because MariaDB has an sql_mode that includes STRICT_TRANS_TABLES, which prohibits boolean false from being saved into an integer field.
The fix I have added to the block controller save() method simply replaces:
$args['do_crop'] = ($args['do_crop']) ? true : false;
with
$args['do_crop'] = ($args['do_crop']) ? 1 : 0;
Type: | Pre-Sale |
---|---|
Status: | Resolved |