When running borrowers-force-messaging-defaults.pl the error message DBD::mysql::st execute failed: Incorrect DATE value: '0000-00-00' [for Statement "SELECT DISTINCT bo.borrowernumber, bo.categorycode FROM borrowers bo LEFT JOIN borrower_message_preferences mp USING (borrowernumber) is displayed. According to documentation this relates to MySql variable sql_mode and that the following behavior can occur if sql_mode contains NO_ZERO_IN_DATE and/or NO_ZERO_DATE. I can confirm this by executing set sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE'; SELECT * FROM borrowers WHERE borrowers.dateenrolled >= '0000-00-00' The select query will result in "Incorrect DATE value: '0000-00-00'" If I instead write set sql_mode='ALLOW_INVALID_DATES'; SELECT * FROM borrowers WHERE borrowers.dateenrolled >= '0000-00-00' the select query executes correctly and returns a collection of borrowers BUT borrowers-force-messaging-defaults.pl still produces the error. Things I've checked * restarting MySql service * restarting server * that <strict_sql_modes>0</strict_sql_modes> in koha-conf.xml is set to 0 * that /etc/mysql/mysql.conf.d/mysqld.cnf contains sql_mode = "ALLOW_INVALID_DATES" Is this a bug in Koha or is there some configuration that I'm missing?
It's a bug. Lowering severity a bit however.
Created attachment 114520 [details] [review] Bug 27276: Prevent borrowers-force-messaging-defaults.pl to crash MySQL 5.7 does not allow queries using 0000-00-00
Stefan, can you try this patch? (I haven't tested it yet!)
Created attachment 114768 [details] [review] Bug 27276: Prevent borrowers-force-messaging-defaults.pl to crash MySQL 5.7 does not allow queries using 0000-00-00 Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Created attachment 114780 [details] [review] Bug 27276: Prevent borrowers-force-messaging-defaults.pl to crash MySQL 5.7 does not allow queries using 0000-00-00 Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 114781 [details] [review] Bug 27276:: Fix syntax error Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Pushed to master for 21.05, thanks to everybody involved!
Pushed to 20.11.x for 20.11.01
Pushed to 20.05.x for 20.05.07
Backported: Pushed to 19.11.x branch for 19.11.14