[wp-trac] [WordPress Trac] #45078: null is being set on a NOT NULL options_value column in the options table.
WordPress Trac
noreply at wordpress.org
Thu Oct 11 07:01:48 UTC 2018
#45078: null is being set on a NOT NULL options_value column in the options table.
--------------------------+-----------------------------
Reporter: wpshades | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Database | Version: trunk
Severity: normal | Keywords: has-patch
Focuses: |
--------------------------+-----------------------------
The {{{options}}} table doesn't allow a NULL value in the
{{{options_value}}} column.
https://core.trac.wordpress.org/browser/trunk/src/wp-
admin/includes/schema.php#L144
But, if an option is unchecked, it is set to null by default here:
https://core.trac.wordpress.org/browser/trunk/src/wp-
admin/options.php#L275
This throws a {{{Column ‘option_value’ cannot be null}}} error if strict
mode({{{STRICT_TRANS_TABLES}}}) is enabled in the database.
If strict mode isn't enabled, MySQL converts the null value to a default
value, in this case, an empty string, before adding it to the
{{{options}}} table.
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
The proposed fix changes the default value from null to an empty
string(following MySQL). This will prevent the error being thrown when
strict mode is enabled and otherwise won't alter the values inserted into
the {{{option_value}}} column.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45078>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list