• Resolved muddg

    (@muddg)


    I get this error message in the widget dashboard
    Warning Strict sql mode in effect. Dynamic widgets might not work correctly. Please disable STRICT sql mode.

    I am running WP 3.8.1, mySQL 5.5 on Windows 2008 with PHP 5.3.13
    Latest version of Dynamic Widgets 1.5.7

    I do have a problem updating a PHP code widget being used in conjunctin with dynmaic widgets. When I make a change to the contents of the widget, it is not flowing through to the website.

    I cannot for the life of me see how to disable STRICT sql mode.
    I’ve spent a fair bit of time researching and I don’t even see this mentioned anywhere. Is this an actual SQL setting or a PHP.INI setting?

    Thanks

    https://ww.wp.xz.cn/plugins/dynamic-widgets/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter muddg

    (@muddg)

    I found the answer to my question.

    On a windows server under the ProgramData folder look for the MySQL Server folder (in my case it was MySQL/MySQL Server 5.5 and edit the my.ini file (with a text editor). Search for STRICT and replace this line
    sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

    with this line
    sql-mode=”NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION”

    Don’t make the mistake of looking for my.ini in the ProgramFiles folder. It is in the ProgramData folder.

    Plugin Contributor Qurl

    (@qurl)

    Great you found the answer yourself. I wouldn’t have exactly known where you would have to look, other then in my.ini.

    Thread Starter muddg

    (@muddg)

    The code I listed in my notes above has the wrong sort of quotes around it so don’t copy it. Use this line instead

    sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

    If you can’t disable strict mode (shared hosting) do this simple two actions:

    1. In datbaase table wp_dynamic_widgets define column name to allow be NULL

    2. in file dynwid_class.php (path: dynamic-widgets/classes/) about line 217 is method:
    public function addSingleOption

    just change SQL INSERT statement to this:

    $query = “INSERT INTO ” . $this->dbtable . “
    (widget_id, maintype, name, value)
    VALUES
    (‘” . esc_sql($widget_id) . “‘, ‘” . esc_sql($maintype) . “‘, NULL, ‘” . esc_sql($value) . “‘)”;

    Columns which must not have content, their must be allow to have NULL value, define that is really empty! Not only empty string.

    Plugin Contributor Qurl

    (@qurl)

    When this is the fix (I actually never looked very deep into it), then I’m happy to implement this in the repository.

    I don’t know where you INSERT or UPDATE sql data, but i test it on mysql 5.6 with strict mode defined. Before this change no data was written. That was all columns are defined as NOT NULL, and there is statement in INSERT where one column is not defined, so data can’t be inserted, because are invalid for schema.

    Change “name” column to be NULLable and everything will be fine.
    By documentation https://dev.mysql.com/doc/refman/5.5/en/sql-mode.html#sql-mode-strict is not necessary to change PHP code, only SQL schema, because if column in insert statement missing, NULL are defined by default.

    R.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Warning Strict sql mode in effect – How to disable’ is closed to new replies.