Fix some bugs with MySQL strict mode

Signed-off-by: Yuriy Pikhtarev <iglix@me.com>
This commit is contained in:
Yuriy Pikhtarev 2018-06-24 21:08:46 +03:00
commit 5429a3bcb8
No known key found for this signature in database
GPG key ID: 3A9B5A757B48ECC6
8 changed files with 34 additions and 16 deletions

12
.env.example Normal file
View file

@ -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

View file

@ -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' => '',

View file

@ -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');
-- ----------------------------

View file

@ -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 '';

View file

@ -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;

View file

@ -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

View file

@ -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'),

View file

@ -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']);