From 012ae17fd3d22f69e2d7ff65f33f6dd6e098cd42 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sat, 1 Apr 2023 14:29:01 +0700 Subject: [PATCH] Fix some bugs with MySQL strict mode (#111) --- admin/admin_cron.php | 4 ++-- install/sql/mysql.sql | 14 +++++++------- install/upgrade/changes.txt | 4 ++++ library/includes/datastore/build_stats.php | 2 +- library/includes/ucp/viewprofile.php | 4 ++-- viewtopic.php | 2 +- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/admin/admin_cron.php b/admin/admin_cron.php index 7999137c..4ba48d91 100644 --- a/admin/admin_cron.php +++ b/admin/admin_cron.php @@ -170,8 +170,8 @@ switch ($mode) 'CRON_SCRIPT' => '', 'RUN_TIME' => '', 'RUN_ORDER' => 255, - 'LAST_RUN' => '0000-00-00 00:00:00', - 'NEXT_RUN' => '0000-00-00 00:00:00', + 'LAST_RUN' => '1900-01-01 00:00:00', + 'NEXT_RUN' => '1900-01-01 00:00:00', 'RUN_INTERVAL' => '', 'LOG_ENABLED' => 0, 'LOG_FILE' => '', diff --git a/install/sql/mysql.sql b/install/sql/mysql.sql index 12c6d031..b51c26a3 100644 --- a/install/sql/mysql.sql +++ b/install/sql/mysql.sql @@ -544,8 +544,8 @@ CREATE TABLE IF NOT EXISTS `bb_cron` ( `run_day` enum('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28') DEFAULT NULL, `run_time` time DEFAULT '04:00:00', `run_order` tinyint(4) unsigned NOT NULL DEFAULT '0', - `last_run` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `next_run` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `last_run` datetime NOT NULL DEFAULT '1900-01-01 00:00:00', + `next_run` datetime NOT NULL DEFAULT '1900-01-01 00:00:00', `run_interval` time DEFAULT NULL DEFAULT '0', `log_enabled` tinyint(1) NOT NULL DEFAULT '0', `log_file` char(120) NOT NULL DEFAULT '', @@ -811,7 +811,7 @@ CREATE TABLE IF NOT EXISTS `bb_posts` ( `post_edit_count` smallint(5) unsigned NOT NULL DEFAULT '0', `post_attachment` tinyint(1) NOT NULL DEFAULT '0', `user_post` tinyint(1) NOT NULL DEFAULT '1', - `mc_comment` text NOT NULL, + `mc_comment` text NOT NULL DEFAULT '', `mc_type` tinyint(1) NOT NULL DEFAULT '0', `mc_user_id` mediumint(8) NOT NULL DEFAULT '0', PRIMARY KEY (`post_id`), @@ -1172,7 +1172,7 @@ CREATE TABLE IF NOT EXISTS `bb_users` ( `user_rank` int(11) NOT NULL DEFAULT '0', `avatar_ext_id` tinyint(4) NOT NULL DEFAULT '0', `user_gender` tinyint(1) NOT NULL DEFAULT '0', - `user_birthday` date NOT NULL DEFAULT '0000-00-00', + `user_birthday` date NOT NULL DEFAULT '1900-01-01', `user_email` varchar(255) NOT NULL DEFAULT '', `user_skype` varchar(32) NOT NULL DEFAULT '', `user_twitter` varchar(15) NOT NULL DEFAULT '', @@ -1197,9 +1197,9 @@ CREATE TABLE IF NOT EXISTS `bb_users` ( -- ---------------------------- -- Records of bb_users -- ---------------------------- -INSERT INTO `bb_users` VALUES ('-1', '0', 'Guest', 'd41d8cd98f00b204e9800998ecf8427e', '0', '0', '0', UNIX_TIMESTAMP(), '0', '0', '0', '', 'ru', '0', '0', '0', '0', '0', '0', '0', '0000-00-00', '', '', '', '', '', '', '', '', '', '', '', '', '0', '0.00', 'default'); -INSERT INTO `bb_users` VALUES ('-746', '0', 'bot', 'd41d8cd98f00b204e9800998ecf8427e', '0', '0', '0', UNIX_TIMESTAMP(), '0', '0', '0', '', 'ru', '0', '0', '0', '144', '0', '0', '0', '0000-00-00', 'bot@torrentpier.com', '', '', '', '', '', '', '', '', '', '', '', '0', '0.00', 'default'); -INSERT INTO `bb_users` VALUES ('2', '1', 'admin', 'c3284d0f94606de1fd2af172aba15bf3', '0', '0', '0', UNIX_TIMESTAMP(), '0', '1', '1', '', 'ru', '0', '0', '0', '304', '1', '0', '0', '0000-00-00', 'admin@torrentpier.com', '', '', '', '', '', '', '', '', '', '', '', '0', '0.00', 'default'); +INSERT INTO `bb_users` VALUES ('-1', '0', 'Guest', 'd41d8cd98f00b204e9800998ecf8427e', '0', '0', '0', UNIX_TIMESTAMP(), '0', '0', '0', '', 'ru', '0', '0', '0', '0', '0', '0', '0', '1900-01-01', '', '', '', '', '', '', '', '', '', '', '', '', '0', '0.00', 'default'); +INSERT INTO `bb_users` VALUES ('-746', '0', 'bot', 'd41d8cd98f00b204e9800998ecf8427e', '0', '0', '0', UNIX_TIMESTAMP(), '0', '0', '0', '', 'ru', '0', '0', '0', '144', '0', '0', '0', '1900-01-01', 'bot@torrentpier.com', '', '', '', '', '', '', '', '', '', '', '', '0', '0.00', 'default'); +INSERT INTO `bb_users` VALUES ('2', '1', 'admin', 'c3284d0f94606de1fd2af172aba15bf3', '0', '0', '0', UNIX_TIMESTAMP(), '0', '1', '1', '', 'ru', '0', '0', '0', '304', '1', '0', '0', '1900-01-01', 'admin@torrentpier.com', '', '', '', '', '', '', '', '', '', '', '', '0', '0.00', 'default'); -- ---------------------------- -- Table structure for `bb_user_group` diff --git a/install/upgrade/changes.txt b/install/upgrade/changes.txt index 1b6b0390..b2e1a56f 100644 --- a/install/upgrade/changes.txt +++ b/install/upgrade/changes.txt @@ -56,6 +56,10 @@ INSERT INTO `bb_cron` VALUES ('', '1', 'Accrual seedbonus', 'tr_seed_bonus.php', // 2.1.5 (LTS 2023.03) UPDATE `bb_config` SET `config_value` = 'http://whatismyipaddress.com/ip/' WHERE `config_name` = 'whois_info'; +ALTER TABLE `bb_cron` CHANGE `last_run` `last_run` DATETIME NOT NULL DEFAULT '1900-01-01 00:00:00'; +ALTER TABLE `bb_cron` CHANGE `next_run` `next_run` DATETIME NOT NULL DEFAULT '1900-01-01 00:00:00'; +ALTER TABLE `bb_users` CHANGE `user_birthday` `user_birthday` DATE NOT NULL DEFAULT '1900-01-01'; +ALTER TABLE `bb_posts` CHANGE `mc_comment` `mc_comment` TEXT NOT NULL DEFAULT ''; ALTER TABLE `bb_users` CHANGE `user_sig` `user_sig` TEXT NOT NULL DEFAULT ''; ALTER TABLE `bb_groups` CHANGE `group_signature` `group_signature` TEXT NOT NULL DEFAULT ''; ALTER TABLE `bb_groups` CHANGE `group_description` `group_description` TEXT NOT NULL DEFAULT ''; \ No newline at end of file diff --git a/library/includes/datastore/build_stats.php b/library/includes/datastore/build_stats.php index 68aeaf4d..c5f5ef45 100644 --- a/library/includes/datastore/build_stats.php +++ b/library/includes/datastore/build_stats.php @@ -53,7 +53,7 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) $sql = DB()->fetch_rowset("SELECT user_id, username, user_rank , user_birthday FROM ". BB_USERS ." WHERE user_id NOT IN(". EXCLUDED_USERS_CSV .") - AND user_birthday != '0000-00-00' + AND user_birthday != '1900-01-01' AND user_birthday IS NOT NULL AND user_active = 1 ORDER BY user_level DESC, username diff --git a/library/includes/ucp/viewprofile.php b/library/includes/ucp/viewprofile.php index 62febcae..02279b17 100644 --- a/library/includes/ucp/viewprofile.php +++ b/library/includes/ucp/viewprofile.php @@ -104,8 +104,8 @@ $template->assign_vars(array( 'TWITTER' => $profiledata['user_twitter'], 'USER_POINTS' => $profiledata['user_points'], 'GENDER' => ($bb_cfg['gender']) ? $lang['GENDER_SELECT'][$profiledata['user_gender']] : '', - 'BIRTHDAY' => ($bb_cfg['birthday_enabled'] && !empty($profiledata['user_birthday']) && $profiledata['user_birthday'] != '0000-00-00') ? $profiledata['user_birthday'] : '', - 'AGE' => ($bb_cfg['birthday_enabled'] && !empty($profiledata['user_birthday']) && $profiledata['user_birthday'] != '0000-00-00') ? birthday_age($profiledata['user_birthday']) : '', + 'BIRTHDAY' => ($bb_cfg['birthday_enabled'] && !empty($profiledata['user_birthday']) && $profiledata['user_birthday'] != '1900-01-01') ? $profiledata['user_birthday'] : '', + 'AGE' => ($bb_cfg['birthday_enabled'] && !empty($profiledata['user_birthday']) && $profiledata['user_birthday'] != '1900-01-01') ? birthday_age($profiledata['user_birthday']) : '', 'L_VIEWING_PROFILE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']), 'L_MY_PROFILE' => sprintf($lang['VIEWING_MY_PROFILE'], 'profile.php?mode=editprofile'), diff --git a/viewtopic.php b/viewtopic.php index 1b2bbf34..124df448 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -651,7 +651,7 @@ for($i = 0; $i < $total_posts; $i++) { $poster_id = $postrow[$i]['user_id']; $poster = ($poster_id == GUEST_UID) ? $lang['GUEST'] : $postrow[$i]['username']; - $poster_birthday = ($poster_id != GUEST_UID && !empty($postrow[$i]['user_birthday']) && $postrow[$i]['user_birthday'] != '0000-00-00') ? date('md', strtotime($postrow[$i]['user_birthday'])) : ''; + $poster_birthday = ($poster_id != GUEST_UID && !empty($postrow[$i]['user_birthday']) && $postrow[$i]['user_birthday'] != '1900-01-01') ? date('md', strtotime($postrow[$i]['user_birthday'])) : ''; $post_date = bb_date($postrow[$i]['post_time'], $bb_cfg['post_date_format']); $max_post_time = max($max_post_time, $postrow[$i]['post_time']); $poster_posts = ($poster_id != GUEST_UID) ? $postrow[$i]['user_posts'] : '';