Skip to content
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

CRM-21068 - getLastModified fails more gracefully now. #10863

Merged
merged 1 commit into from
Aug 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CRM/Core/BAO/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class CRM_Core_BAO_Log extends CRM_Core_DAO_Log {
* @param string $table
*
* @return array|null
*
*/
public static function &lastModified($id, $table = 'civicrm_contact') {

Expand All @@ -51,9 +52,11 @@ public static function &lastModified($id, $table = 'civicrm_contact') {
$log->entity_id = $id;
$log->orderBy('modified_date desc');
$log->limit(1);
$result = NULL;
$displayName = $result = $contactImage = NULL;
if ($log->find(TRUE)) {
list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($log->modified_id);
if ($log->modified_id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, I might want a short comment explaining why we check modified_id

list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($log->modified_id);
}
$result = array(
'id' => $log->modified_id,
'name' => $displayName,
Expand Down