From f19136905ffe104e12484aba5bca5adeefa4b133 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 21 Sep 2019 05:14:49 -0400 Subject: [PATCH 1/3] Remove setting obsolete App->data['user'] in Module\Profile\Contacts --- src/Module/Profile/Contacts.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Module/Profile/Contacts.php b/src/Module/Profile/Contacts.php index 346622b2e5..7463d4043f 100644 --- a/src/Module/Profile/Contacts.php +++ b/src/Module/Profile/Contacts.php @@ -36,7 +36,6 @@ class Contacts extends BaseModule throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('User not found.')); } - $a->data['user'] = $user; $a->profile_uid = $user['uid']; Profile::load($a, $nickname); From 118e737a49b87d508252b8fc4104c18d503e4e68 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 21 Sep 2019 05:15:52 -0400 Subject: [PATCH 2/3] Remove dependency to App object in Temporal::getDateofBirthField --- mod/profiles.php | 2 +- src/Util/Temporal.php | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/mod/profiles.php b/mod/profiles.php index 58f23e4634..72bcac49fc 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -594,7 +594,7 @@ function profiles_content(App $a) { '$default' => (($is_default) ? '

' . L10n::t('This is your public profile.
It may be visible to anybody using the internet.') . '

' : ""), '$name' => ['name', L10n::t('Your Full Name:'), $r[0]['name']], '$pdesc' => ['pdesc', L10n::t('Title/Description:'), $r[0]['pdesc']], - '$dob' => Temporal::getDateofBirthField($r[0]['dob']), + '$dob' => Temporal::getDateofBirthField($r[0]['dob'], $a->user['timezone']), '$hide_friends' => $hide_friends, '$address' => ['address', L10n::t('Street Address:'), $r[0]['address']], '$locality' => ['locality', L10n::t('Locality/City:'), $r[0]['locality']], diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index ec71ab5e96..d08db24504 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -122,13 +122,12 @@ class Temporal * @brief Wrapper for date selector, tailored for use in birthday fields. * * @param string $dob Date of Birth + * @param string $timezone * @return string Formatted HTML - * @throws \Friendica\Network\HTTPException\InternalServerErrorException + * @throws \Exception */ - public static function getDateofBirthField($dob) + public static function getDateofBirthField($dob, $timezone = 'UTC') { - $a = \get_app(); - list($year, $month, $day) = sscanf($dob, '%4d-%2d-%2d'); if ($dob < '0000-01-01') { @@ -137,7 +136,7 @@ class Temporal $value = DateTimeFormat::utc(($year > 1000) ? $dob : '1000-' . $month . '-' . $day, 'Y-m-d'); } - $age = (intval($value) ? self::getAgeByTimezone($value, $a->user["timezone"], $a->user["timezone"]) : ""); + $age = (intval($value) ? self::getAgeByTimezone($value, $timezone, $timezone) : ""); $tpl = Renderer::getMarkupTemplate("field_input.tpl"); $o = Renderer::replaceMacros($tpl, From f51b275b178be01969105c4ee6e449c9008a3a08 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 21 Sep 2019 10:52:55 -0400 Subject: [PATCH 3/3] Add parameter type hints in Temporal::getDateofBirthField --- src/Util/Temporal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index d08db24504..6a331104ee 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -126,7 +126,7 @@ class Temporal * @return string Formatted HTML * @throws \Exception */ - public static function getDateofBirthField($dob, $timezone = 'UTC') + public static function getDateofBirthField(string $dob, string $timezone = 'UTC') { list($year, $month, $day) = sscanf($dob, '%4d-%2d-%2d');