Skip to content

Commit

Permalink
fixed: disable system_log from tracking view count modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
jeabakker committed Jul 11, 2023
1 parent 7b50ba4 commit 469e9ac
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions views/default/entity_view_counter/extends/counter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
$session_id = $session->getId();

// log the user who is viewing
// if no logged in user, log by entity
// if no logged-in user, log by entity
$owner_guid = elgg_get_logged_in_user_guid() ?: $entity->guid;

$annotation_id = $entity->annotate(ENTITY_VIEW_COUNTER_ANNOTATION_NAME, $session_id, ACCESS_PUBLIC, $owner_guid);
$annotation_id = elgg_call(ELGG_DISABLE_SYSTEM_LOG, function() use ($entity, $session_id, $owner_guid) {
return $entity->annotate(ENTITY_VIEW_COUNTER_ANNOTATION_NAME, $session_id, ACCESS_PUBLIC, $owner_guid);
});
if (!$annotation_id) {
// someone prevented the creation of the annotation
return;
Expand All @@ -62,6 +64,6 @@
$current_count++;
}

elgg_call(ELGG_IGNORE_ACCESS, function () use ($entity, $current_count) {
elgg_call(ELGG_IGNORE_ACCESS | ELGG_DISABLE_SYSTEM_LOG, function () use ($entity, $current_count) {
$entity->entity_view_count = $current_count;
});

0 comments on commit 469e9ac

Please sign in to comment.