Hello, we have a small OJS 3.3.0-13 installation with mariadb/php7.4 backend that’s been pretty low-maintenance so far, but recently a user was unable to create an announcement. The error seems to come when the following SQL statement is executed (pulling this from php-fpm’s www-error log.
Message: SQLSTATE[HY000]: General error: 1364 Field 'setting_type' doesn't have a default value (SQL: INSERT INTO announcement_settings (announcement_id, locale, setting_name, setting_value) VALUES (54, en_US, description, <p>test</p>))
The definition of the announcement_settings table is
| Field | Type | Null | Key | Default | Extra |
+----------------------+--------------+------+-----+---------+-------+
| announcement_id | bigint(20) | NO | PRI | NULL | |
| locale | varchar(14) | NO | PRI | | |
| setting_name | varchar(255) | NO | PRI | NULL | |
| setting_value | text | YES | | NULL | |
| setting_type | varchar(6) | NO | | NULL | |
+----------------------+--------------+------+-----+---------+-------+
So it seems like the error message makes sense. setting_type doesn’t get set by the SQL, so a default value of NULL gets provided, except that NULL is specifically precluded so the operation fails.
Upgrading to 3.3.0-20 doesn’t change this. Without digging into the PHP code, the only fix I can think of is to change the table definition to either allow NULLs in the setting_type column or to alter the column to have a non-NULL default value (like ‘string’?)
Assuming I haven’t missed something obvious here (and I feel like I probably have), would either of those table alterations be safe to perform? I haven’t seen any issues on our test instance.