Skip to content

Errors when updating options (SQLSTATE[23000]: Integrity constraint violation) #18

Description

@pinoceniccola

It looks like there are errors when you try to save some options on the backend.

From what I can see, schema for option_value is TEXT NOT NULL but the query executed try to set value to NULL.

Steps to reproduce: In the backend, go to Settings -> Discussion, deselect any option and try to save.

Wordpress Debug Output:

WordPress database error: [
 
Queries made or created this session were

    Raw query: UPDATE `wp_options` SET `option_value` = NULL WHERE `option_name` = 'default_pingback_flag'
    Rewritten: UPDATE wp_options SET option_value = NULL WHERE option_name = 'default_pingback_flag'
    With Placeholders: UPDATE wp_options SET option_value = NULL WHERE option_name = :param_0
    Prepare: UPDATE wp_options SET option_value = NULL WHERE option_name = :param_0
    Executing: array ( 0 => 'default_pingback_flag', )

Error occurred at line 1723 in Function execute_query.
Error message was: Error while executing query! Error message was: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: wp_options.option_value

] 
UPDATE `wp_options` SET `option_value` = NULL WHERE `option_name` = 'default_pingback_flag' 

debug.txt:

Line 1723, Function: execute_query, Message: Error while executing query! Error message was: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: wp_posts.comment_status 
Line 1723, Function: execute_query, Message: Error while executing query! Error message was: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: wp_options.option_value 

WordPress version: 5.6.2
PHP version: 7.4

Note: When WP_DEBUG is set to false it just fails to update the options silently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions