-
-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate duplicate getLoggedInContactID() function #20321
Conversation
(Standard links)
|
@@ -2243,7 +2243,7 @@ protected function setContactID() { | |||
return (int) $tempID; | |||
} | |||
|
|||
$userID = $this->getLoggedInUserContactID(); | |||
$userID = CRM_Core_Session::getLoggedInContactID(); | |||
|
|||
if (!is_null($tempID) && $tempID === $userID) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only difference I can see is that we are changing from a function that returns FALSE to one that returns NULL. So this is_null check maybe needs to become is false (I'm struggling a bit to figure out what it achieves. I know that 0 and potentially '0' are valid / meaningful in this function but I'm not sure the meaning of FALSE - ie could $tempID ever be FALSE & what would that mean)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be if CRM_Core_Session::getLoggedInContactID
return int|null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eileenmcnaughton In this case $tempID is set by CRM_Utils_Request::retrieve and will be NULL if not found. It then may be set via ['select_contact_id'] but only if that is not empty (so not NULL). So the is_null
check never changes because $tempID is never set by getLoggedInContactID()
When we do the $tempID === $userID
we already checked that $tempID is not null (via !is_null()
) so we don't need to worry what the value of $userID
is - if it is NULL or FALSE it won't match because we know that $tempID
is not NULL and it cannot be set to FALSE in the function
@eileenmcnaughton @monishdeb Thanks - I've responded to questions |
@monishdeb Happy with this now? |
Yep and sorry for the delay. Tested again in local, looks good. Merging now. |
Thankyou :-) |
This replaces as per civicrm/civicrm-core#20321 Note the replacement function can return NULL. It seems like the code that retrieves the value already handles this.
Overview
CRM_Core_Form::getLoggedInUserContactID()
is doing virtually the same thing asCRM_Core_Session::getLoggedInContactD()
but is only used in 3 places. Deprecate it and use the function on the session class.Before
"Duplicate" function.
After
Use standard function
Technical Details
Only change here is that we explicitly return an int which the contact ID should always be..
Comments