From d71e8565355eec4b5d885a9ef66d7ceb703a2cd8 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 21 Nov 2018 23:53:45 -0500 Subject: [PATCH] Replace remaining occurrences of "0001-01-01" with DBA::NULL_DATE --- mod/hovercard.php | 2 +- mod/profiles.php | 2 +- src/Model/Contact.php | 6 +++--- src/Model/GContact.php | 2 +- src/Model/Profile.php | 4 ++-- src/Protocol/DFRN.php | 7 +++---- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/mod/hovercard.php b/mod/hovercard.php index f5ad3ef021..6160642762 100644 --- a/mod/hovercard.php +++ b/mod/hovercard.php @@ -107,7 +107,7 @@ function hovercard_content() 'about' => $contact['about'], 'network' => Strings::formatNetworkName($contact['network'], $contact['url']), 'tags' => $contact['keywords'], - 'bd' => $contact['birthday'] <= '0001-01-01' ? '' : $contact['birthday'], + 'bd' => $contact['birthday'] <= DBA::NULL_DATE ? '' : $contact['birthday'], 'account_type' => Contact::getAccountType($contact), 'actions' => $actions, ]; diff --git a/mod/profiles.php b/mod/profiles.php index 459a1c5e75..fe3b362317 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -216,7 +216,7 @@ function profiles_post(App $a) { } else { $ignore_year = false; } - if (!in_array($dob, ['0000-00-00', '0001-01-01'])) { + if (!in_array($dob, ['0000-00-00', DBA::NULL_DATE])) { if (strpos($dob, '0000-') === 0 || strpos($dob, '0001-') === 0) { $ignore_year = true; $dob = substr($dob, 5); diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 1c90d0c815..f43a14e626 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -740,7 +740,7 @@ class Contact extends BaseObject // "bd" always contains the upcoming birthday of a contact. // "birthday" might contain the birthday including the year of birth. - if ($profile["birthday"] > '0001-01-01') { + if ($profile["birthday"] > DBA::NULL_DATE) { $bd_timestamp = strtotime($profile["birthday"]); $month = date("m", $bd_timestamp); $day = date("d", $bd_timestamp); @@ -757,7 +757,7 @@ class Contact extends BaseObject $profile["bd"] = ( ++$current_year) . "-" . $month . "-" . $day; } } else { - $profile["bd"] = '0001-01-01'; + $profile["bd"] = DBA::NULL_DATE; } } else { $profile = $default; @@ -794,7 +794,7 @@ class Contact extends BaseObject $profile["location"] = ""; $profile["about"] = ""; $profile["gender"] = ""; - $profile["birthday"] = '0001-01-01'; + $profile["birthday"] = DBA::NULL_DATE; } $cache[$url][$uid] = $profile; diff --git a/src/Model/GContact.php b/src/Model/GContact.php index 1fed1fc3ef..3acffb059d 100644 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@ -864,7 +864,7 @@ class GContact 'location' => $contact['location'], 'about' => $contact['about']]; // Don't update the birthday field if not set or invalid - if (empty($contact['birthday']) || ($contact['birthday'] < '0001-01-01')) { + if (empty($contact['birthday']) || ($contact['birthday'] <= DBA::NULL_DATE)) { unset($fields['bd']); } diff --git a/src/Model/Profile.php b/src/Model/Profile.php index c45bcdb84b..df4c8d3c6d 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -749,7 +749,7 @@ class Profile $profile['gender'] = [L10n::t('Gender:'), $a->profile['gender']]; } - if (($a->profile['dob']) && ($a->profile['dob'] > '0001-01-01')) { + if (!empty($a->profile['dob']) && $a->profile['dob'] > DBA::NULL_DATE) { $year_bd_format = L10n::t('j F, Y'); $short_bd_format = L10n::t('j F'); @@ -763,7 +763,7 @@ class Profile } if (!empty($a->profile['dob']) - && $a->profile['dob'] > '0001-01-01' + && $a->profile['dob'] > DBA::NULL_DATE && $age = Temporal::getAgeByTimezone($a->profile['dob'], $a->profile['timezone'], '') ) { $profile['age'] = [L10n::t('Age:'), $age]; diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index ff50811838..7c03a21839 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -16,7 +16,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Addon; use Friendica\Core\Config; -use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; @@ -690,7 +689,7 @@ class DFRN XML::addElement($doc, $author, "poco:displayName", $profile["name"]); XML::addElement($doc, $author, "poco:updated", $namdate); - if (trim($profile["dob"]) > '0001-01-01') { + if (trim($profile["dob"]) > DBA::NULL_DATE) { XML::addElement($doc, $author, "poco:birthday", "0000-".date("m-d", strtotime($profile["dob"]))); } @@ -1722,9 +1721,9 @@ class DFRN // "poco:birthday" is the birthday in the format "yyyy-mm-dd" $value = XML::getFirstNodeValue($xpath, $element . "/poco:birthday/text()", $context); - if (!in_array($value, ["", "0000-00-00", "0001-01-01"])) { + if (!in_array($value, ["", "0000-00-00", DBA::NULL_DATE])) { $bdyear = date("Y"); - $value = str_replace("0000", $bdyear, $value); + $value = str_replace(["0000", "0001"], $bdyear, $value); if (strtotime($value) < time()) { $value = str_replace($bdyear, $bdyear + 1, $value);