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.