Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Birthdate for those with no birthdates set #5911

Closed
SychO9 opened this issue Jan 1, 2020 · 4 comments · Fixed by #5941
Closed

Birthdate for those with no birthdates set #5911

SychO9 opened this issue Jan 1, 2020 · 4 comments · Fixed by #5941

Comments

@SychO9
Copy link
Contributor

SychO9 commented Jan 1, 2020

Description

The default birthdate column value in the smf_members table is 1004-01-01, that means that the software by default determines that all who have not set their birth dates, their birth dates are the 1st of January

Source code in question

I believe these are the two spots of the source code that we should tweak (add conditions that the year value must be upper than 1004 perhaps?), unless we want to edit the column's default value.

Line 81 of Profile-View.php
https://github.com/SimpleMachines/SMF2.1/blob/6007069567bd78d1a72dd56dc61590a074258be4/Sources/Profile-View.php#L79-L82

And the query in the birthday scheduled task
https://github.com/SimpleMachines/SMF2.1/blob/6007069567bd78d1a72dd56dc61590a074258be4/Sources/tasks/Birthday-Notify.php#L31-L48

Additional information/references

https://www.simplemachines.org/community/index.php?topic=571106.0
https://www.simplemachines.org/community/index.php?topic=571108.0

@sbulen
Copy link
Contributor

sbulen commented Jan 1, 2020

Interesting. It's been like that for a while, part of supporting STRICT mode. I guess more folks are using this in production...

The year 1004 is tied to certain logic, iirc, so we likely need to check > 1004.

@sbulen
Copy link
Contributor

sbulen commented Jan 1, 2020

More history here, with links to other related prs:
#4681

@albertlast
Copy link
Collaborator

Allow null value and you got possibly to fix it right.
Specially from performance view is this the best.

live627 added a commit to live627/SMF2.1 that referenced this issue Jan 10, 2020
@sbulen sbulen added the Has fix label Jan 10, 2020
MissAllSunday pushed a commit to MissAllSunday/SMF2.1 that referenced this issue Feb 13, 2020
@sportfogadas
Copy link

This is also an issue in the Calendar if you have birthdays set to display. Interestingly, there was a year check there in 2.0, but removed in 2.1. I fixed it on my forum by copying it from the 2.0 code and changing year_one to '1004'. I don't have the code checked out so I can't submit a pull request, but here's the modified query.

The quick fix in Subs-Calendar.php, getBirthdayRange():

$result = $smcFunc['db_query']('birthday_array', '
SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate
FROM {db_prefix}members
WHERE YEAR(birthdate) != {string:year_one}
AND MONTH(birthdate) != {int:no_month}
AND DAYOFMONTH(birthdate) != {int:no_day}
AND YEAR(birthdate) <= {int:max_year}
AND (
DATE_FORMAT(birthdate, {string:year_low}) BETWEEN {date:low_date} AND {date:high_date}' . ($year_low == $year_high ? '' : '
OR DATE_FORMAT(birthdate, {string:year_high}) BETWEEN {date:low_date} AND {date:high_date}') . '
)
AND is_activated = {int:is_activated}',
array(
'is_activated' => 1,
'no_month' => 0,
'no_day' => 0,
'year_one' => '1004',
'year_low' => $year_low . '-%m-%d',
'year_high' => $year_high . '-%m-%d',
'low_date' => $low_date,
'high_date' => $high_date,
'max_year' => $year_high,
)
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants