1
0
Fork 0

bug #511 - if birth year supplied but not a month or day, force a sane default. PHP datetime functions don't handle zero very well.

This commit is contained in:
friendica 2012-12-02 13:47:41 -08:00
parent ee0def3ef5
commit 79fb5509ed

View file

@ -42,6 +42,13 @@ function profiles_post(&$a) {
$day = intval($_POST['day']); $day = intval($_POST['day']);
if(($day > $mtab[$month]) || ($day < 0)) if(($day > $mtab[$month]) || ($day < 0))
$day = 0; $day = 0;
// It's OK to have an empty (0) year, but if you supplied a year you have to have a non-zero month and day
if($year && ! $month)
$month = 1;
if($year && ! $day)
$day = 1;
$dob = '0000-00-00'; $dob = '0000-00-00';
$dob = sprintf('%04d-%02d-%02d',$year,$month,$day); $dob = sprintf('%04d-%02d-%02d',$year,$month,$day);