From 5429a3bcb84590d8240141febf070305dbc0d5d0 Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Sun, 24 Jun 2018 21:08:46 +0300 Subject: [PATCH] Fix some bugs with MySQL strict mode Signed-off-by: Yuriy Pikhtarev --- .env.example | 12 ++++++++++++ admin/admin_cron.php | 4 ++-- install/sql/mysql.sql | 14 +++++++------- install/upgrade/changes.txt | 6 ++++++ library/config.php | 6 +++--- library/includes/datastore/build_stats.php | 2 +- library/includes/ucp/viewprofile.php | 4 ++-- viewtopic.php | 2 +- 8 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 000000000..dd55a2a6e --- /dev/null +++ b/.env.example @@ -0,0 +1,12 @@ +# Common params +APP_NAME=TorrentPier +APP_ENV=local +APP_DEBUG=false + +# Database credentials +DB_CONNECTION=mysql +DB_HOST=localhost +DB_PORT=3306 +DB_DATABASE=torrentpier +DB_USERNAME=root +DB_PASSWORD=secret diff --git a/admin/admin_cron.php b/admin/admin_cron.php index 9bf4d2acc..652ccfbf3 100644 --- a/admin/admin_cron.php +++ b/admin/admin_cron.php @@ -165,8 +165,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 ff5b7cf00..ffbe08e4b 100644 --- a/install/sql/mysql.sql +++ b/install/sql/mysql.sql @@ -569,8 +569,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 '', @@ -896,7 +896,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`), @@ -1297,7 +1297,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 '', @@ -1331,21 +1331,21 @@ INSERT INTO `bb_users` VALUES '0', '0', '0', '0', '0', '0', - '0000-00-00', + '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', - '0000-00-00', + '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', - '0000-00-00', + '1900-01-01', 'admin@torrentpier.com', '', '', '', '', '', '', '', '', '', '', '', '0', '0.00', 'default'); -- ---------------------------- diff --git a/install/upgrade/changes.txt b/install/upgrade/changes.txt index c9c8c9465..f6cbe4df2 100644 --- a/install/upgrade/changes.txt +++ b/install/upgrade/changes.txt @@ -32,3 +32,9 @@ ALTER TABLE `bb_banlist` CHANGE `ban_ip` `ban_ip` varchar(42) NOT NULL DEFAULT ' // 2.2.2 ALTER TABLE `bb_ranks` DROP `rank_min`; ALTER TABLE `bb_ranks` DROP `rank_special`; + +// 2.3.0 +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 ''; diff --git a/library/config.php b/library/config.php index 0324a018e..85e24f3fd 100644 --- a/library/config.php +++ b/library/config.php @@ -21,9 +21,9 @@ $bb_cfg = []; $bb_cfg['js_ver'] = $bb_cfg['css_ver'] = 1; // Version info -$bb_cfg['tp_version'] = '2.2.3'; -$bb_cfg['tp_release_date'] = '07-08-2017'; -$bb_cfg['tp_release_codename'] = 'Aurochs'; +$bb_cfg['tp_version'] = '2.3.0'; +$bb_cfg['tp_release_date'] = '26-06-2018'; +$bb_cfg['tp_release_codename'] = 'Bison'; // Database // Настройка баз данных ['db']['srv_name'] => (array) srv_cfg; diff --git a/library/includes/datastore/build_stats.php b/library/includes/datastore/build_stats.php index f831dc272..0753e5c6f 100644 --- a/library/includes/datastore/build_stats.php +++ b/library/includes/datastore/build_stats.php @@ -59,7 +59,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 . ") - 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 2200f56b9..15bfa28c1 100644 --- a/library/includes/ucp/viewprofile.php +++ b/library/includes/ucp/viewprofile.php @@ -98,8 +98,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 7ac4df45d..72f440472 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -571,7 +571,7 @@ $this_date = bb_date(TIMENOW, 'md', false); 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') + $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']);