From 79fb5509ed623d2f2f648d26afa5cae2ab092444 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 2 Dec 2012 13:47:41 -0800 Subject: [PATCH] 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. --- mod/profiles.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mod/profiles.php b/mod/profiles.php index e30c982182..d4a3db83e0 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -42,6 +42,13 @@ function profiles_post(&$a) { $day = intval($_POST['day']); if(($day > $mtab[$month]) || ($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 = sprintf('%04d-%02d-%02d',$year,$month,$day); -- 2.39.5