Skip to content

Commit 50108b9

Browse files
authored
Merge pull request #7201 from live627/cal
Users without valid birthdates were falsely selected
2 parents facf347 + 299cdf7 commit 50108b9

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

Sources/Subs-Calendar.php

+9-19
Original file line numberDiff line numberDiff line change
@@ -36,52 +36,42 @@ function getBirthdayRange($low_date, $high_date)
3636
if ($smcFunc['db_title'] !== POSTGRE_TITLE)
3737
{
3838
// Collect all of the birthdays for this month. I know, it's a painful query.
39-
$result = $smcFunc['db_query']('birthday_array', '
39+
$result = $smcFunc['db_query']('', '
4040
SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate
4141
FROM {db_prefix}members
42-
WHERE MONTH(birthdate) != {int:no_month}
43-
AND DAYOFMONTH(birthdate) != {int:no_day}
44-
AND YEAR(birthdate) <= {int:max_year}
42+
WHERE birthdate != {date:no_birthdate}
4543
AND (
4644
DATE_FORMAT(birthdate, {string:year_low}) BETWEEN {date:low_date} AND {date:high_date}' . ($year_low == $year_high ? '' : '
4745
OR DATE_FORMAT(birthdate, {string:year_high}) BETWEEN {date:low_date} AND {date:high_date}') . '
4846
)
4947
AND is_activated = {int:is_activated}',
5048
array(
5149
'is_activated' => 1,
52-
'no_month' => 0,
53-
'no_day' => 0,
50+
'no_birthdate' => '1004-01-01',
5451
'year_low' => $year_low . '-%m-%d',
5552
'year_high' => $year_high . '-%m-%d',
5653
'low_date' => $low_date,
5754
'high_date' => $high_date,
58-
'max_year' => $year_high,
5955
)
6056
);
6157
}
6258
else
6359
{
64-
$result = $smcFunc['db_query']('birthday_array', '
60+
$result = $smcFunc['db_query']('', '
6561
SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate
6662
FROM {db_prefix}members
67-
WHERE YEAR(birthdate) != {string:year_one}
68-
AND MONTH(birthdate) != {int:no_month}
69-
AND DAYOFMONTH(birthdate) != {int:no_day}
63+
WHERE birthdate != {date:no_birthdate}
7064
AND (
7165
indexable_month_day(birthdate) BETWEEN indexable_month_day({date:year_low_low_date}) AND indexable_month_day({date:year_low_high_date})' . ($year_low == $year_high ? '' : '
72-
OR indexable_month_day(birthdate) BETWEEN indexable_month_day({date:year_high_low_date}) AND indexable_month_day({date:year_high_high_date})') . '
66+
OR indexable_month_day(birthdate) BETWEEN indexable_month_day({date:year_high_low_date}) AND indexable_month_day({date:year_high_high_date})') . '
7367
)
7468
AND is_activated = {int:is_activated}',
7569
array(
7670
'is_activated' => 1,
77-
'no_month' => 0,
78-
'no_day' => 0,
79-
'year_one' => '1004',
80-
'year_low' => $year_low . '-%m-%d',
81-
'year_high' => $year_high . '-%m-%d',
71+
'no_birthdate' => '1004-01-01',
8272
'year_low_low_date' => $low_date,
83-
'year_low_high_date' => ($year_low == $year_high ? $high_date : $year_low . '-12-31'),
84-
'year_high_low_date' => ($year_low == $year_high ? $low_date : $year_high . '-01-01'),
73+
'year_low_high_date' => $year_low == $year_high ? $high_date : $year_low . '-12-31',
74+
'year_high_low_date' => $year_low == $year_high ? $low_date : $year_high . '-01-01',
8575
'year_high_high_date' => $high_date,
8676
)
8777
);

0 commit comments

Comments
 (0)