From 52129c88971bf4c8749a6766121de65994b3032a Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Mon, 17 May 2021 11:42:10 +0100 Subject: [PATCH] Deprecated duplicate getLoggedInContactID function --- CRM/Core/Form.php | 6 ++++-- CRM/Core/Session.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 84dce6fa35..ca3be72142 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -2243,7 +2243,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { return (int) $tempID; } - $userID = $this->getLoggedInUserContactID(); + $userID = CRM_Core_Session::getLoggedInContactID(); if (!is_null($tempID) && $tempID === $userID) { CRM_Core_Resources::singleton()->addVars('coreForm', ['contact_id' => (int) $tempID]); @@ -2283,10 +2283,12 @@ class CRM_Core_Form extends HTML_QuickForm_Page { /** * Get the contact id of the logged in user. + * @deprecated * * @return int|false */ public function getLoggedInUserContactID() { + CRM_Core_Error::deprecatedFunctionWarning('CRM_Core_Session::getLoggedInContactID()'); // check if the user is logged in and has a contact ID $session = CRM_Core_Session::singleton(); return $session->get('userID') ? (int) $session->get('userID') : FALSE; @@ -2725,7 +2727,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { if (!$contactID) { return FALSE; } - if ($contactID === $this->getLoggedInUserContactID()) { + if ($contactID === CRM_Core_Session::getLoggedInContactID()) { return $contactID; } $userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this); diff --git a/CRM/Core/Session.php b/CRM/Core/Session.php index 698b25eb9d..dcbe3a7823 100644 --- a/CRM/Core/Session.php +++ b/CRM/Core/Session.php @@ -563,7 +563,7 @@ class CRM_Core_Session { if (!is_numeric($session->get('userID'))) { return NULL; } - return $session->get('userID'); + return (int) $session->get('userID'); } /** -- 2.25.1