Shantanu Desai
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: WordPress database error: [Column ‘option_value’ cannot be null]Hi @wpfed!
Is the _Attempt to notify any blogs linked to from the article_(
default_pingback_flag
) options under Settings -> Discussion -> Default Article Settings unchecked on your site?Also, is strict mode is enabled for your database(STRICT_TRANS_TABLES)?
You can check this by running the following from your MySQL prompt:
select @@sql_mode;
If an option is unchecked, it is set to
null
by default here:
https://github.com/WordPress/WordPress/blob/e6ccdf161fd1e2c9d836081d148f1fbb16767574/wp-admin/options.php#L215But the wp_options table does not allow NULL as a value for options_value:
https://github.com/WordPress/WordPress/blob/1c2ff54037c1457cd079b20dbe987406b90f9645/wp-admin/includes/schema.php#L141This can cause the
Column xyz cannot be null
error if strict mode is enabled in your database. You could try disabling it and see if the error persists.If you are not using strict mode, then whenever you insert an “incorrect” value into a column, such as a NULL into a NOT NULL column or a too-large numeric value into a numeric column, MySQL sets the column to the “best possible value” instead of producing an error
https://dev.mysql.com/doc/refman/5.7/en/constraint-invalid-data.html
In this case, since
options_value
is of typelongtext
that default value would be an empty string – ”.FWIW, I don’t think the default value should be set to null if an option is unchecked. I think the default value should be an empty string
''
, since that’s what MySQL defaults to when strict mode is disabled.