From 363b58be044204dc48bc0bd6d7b6c2bde9ea8353 Mon Sep 17 00:00:00 2001 From: Davide Giunchi Date: Tue, 20 Aug 2019 11:11:35 +0200 Subject: [PATCH] always set valid dates, to avoid errors on mysql server with strict mode enabled. ref: https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_allow_invalid_dates --- .../classes/wp-security-installer.php | 16 ++++++++-------- .../classes/wp-security-user-login.php | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/all-in-one-wp-security/classes/wp-security-installer.php b/all-in-one-wp-security/classes/wp-security-installer.php index ef561dd..a4f9492 100644 --- a/all-in-one-wp-security/classes/wp-security-installer.php +++ b/all-in-one-wp-security/classes/wp-security-installer.php @@ -69,8 +69,8 @@ static function create_db_tables() id bigint(20) NOT NULL AUTO_INCREMENT, user_id bigint(20) NOT NULL, user_login VARCHAR(150) NOT NULL, - lockdown_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - release_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + lockdown_date datetime NOT NULL DEFAULT '1000-10-10 10:00:00', + release_date datetime NOT NULL DEFAULT '1000-10-10 10:00:00', failed_login_ip varchar(100) NOT NULL DEFAULT '', lock_reason varchar(128) NOT NULL DEFAULT '', unlock_key varchar(128) NOT NULL DEFAULT '', @@ -82,7 +82,7 @@ static function create_db_tables() id bigint(20) NOT NULL AUTO_INCREMENT, user_id bigint(20) NOT NULL, user_login VARCHAR(150) NOT NULL, - failed_login_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + failed_login_date datetime NOT NULL DEFAULT '1000-10-00 10:00:00', login_attempt_ip varchar(100) NOT NULL DEFAULT '', PRIMARY KEY (id) )" . $charset_collate . ";"; @@ -92,8 +92,8 @@ static function create_db_tables() id bigint(20) NOT NULL AUTO_INCREMENT, user_id bigint(20) NOT NULL, user_login VARCHAR(150) NOT NULL, - login_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - logout_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + login_date datetime NOT NULL DEFAULT '1000-10-00 10:00:00', + logout_date datetime NOT NULL DEFAULT '1000-10-00 10:00:00', login_ip varchar(100) NOT NULL DEFAULT '', login_country varchar(150) NOT NULL DEFAULT '', browser_type varchar(150) NOT NULL DEFAULT '', @@ -103,7 +103,7 @@ static function create_db_tables() $gm_tbl_sql = "CREATE TABLE " . $aiowps_global_meta_tbl_name . " ( meta_id bigint(20) NOT NULL auto_increment, - date_time datetime NOT NULL default '0000-00-00 00:00:00', + date_time datetime NOT NULL default '1000-10-10 10:00:00', meta_key1 varchar(255) NOT NULL, meta_key2 varchar(255) NOT NULL, meta_key3 varchar(255) NOT NULL, @@ -123,7 +123,7 @@ static function create_db_tables() event_type VARCHAR(150) NOT NULL DEFAULT '', username VARCHAR(150), user_id bigint(20), - event_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + event_date datetime NOT NULL DEFAULT '1000-10-10 10:00:00', ip_or_host varchar(100), referer_info varchar(255), url varchar(255), @@ -138,7 +138,7 @@ static function create_db_tables() blocked_ip varchar(100) NOT NULL DEFAULT '', block_reason varchar(128) NOT NULL DEFAULT '', country_origin varchar(50) NOT NULL DEFAULT '', - blocked_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + blocked_date datetime NOT NULL DEFAULT '1000-10-10 10:00:00', unblock tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (id) )" . $charset_collate . ";"; diff --git a/all-in-one-wp-security/classes/wp-security-user-login.php b/all-in-one-wp-security/classes/wp-security-user-login.php index 3cc4252..8ce705e 100644 --- a/all-in-one-wp-security/classes/wp-security-user-login.php +++ b/all-in-one-wp-security/classes/wp-security-user-login.php @@ -506,7 +506,7 @@ function wp_logout_action_handler() $data = array('logout_date' => $logout_date_time); $where = array('user_id' => $user_id, 'login_ip' => $ip_addr, - 'logout_date' => '0000-00-00 00:00:00'); + 'logout_date' => '1000-10-10 10:00:00'); $result = $wpdb->update($login_activity_table, $data, $where); if ($result === FALSE) { @@ -604,4 +604,4 @@ function get_unlock_request_form() $unlock_request_form .= ''; return $unlock_request_form; } -} \ No newline at end of file +}