Skip to content

Commit

Permalink
fixed: correctly get stale group information
Browse files Browse the repository at this point in the history
  • Loading branch information
jeabakker committed Apr 11, 2024
1 parent be5ead4 commit e7eefcf
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions classes/ColdTrick/GroupTools/StaleInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,16 @@ protected function getContentTimestamp(): int {
return 0;
}

$entities = elgg_get_entities([
'type' => 'object',
'subtypes' => $object_subtypes,
'limit' => 1,
'container_guid' => $this->group->guid,
'order_by' => new OrderByClause('time_updated', 'DESC'),
]);
$entities = elgg_call(ELGG_IGNORE_ACCESS, function() use ($object_subtypes) {
return elgg_get_entities([
'type' => 'object',
'subtypes' => $object_subtypes,
'limit' => 1,
'container_guid' => $this->group->guid,
'order_by' => new OrderByClause('time_updated', 'DESC'),
]);
});

if (empty($entities)) {
return 0;
}
Expand All @@ -121,19 +124,22 @@ protected function getContentTimestamp(): int {
protected function getCommentTimestamp(): int {
$guid = $this->group->guid;

$entities = elgg_get_entities([
'type' => 'object',
'subtype' => 'comment',
'limit' => 1,
'wheres' => [
function(QueryBuilder $qb, $main_alias) use ($guid) {
$ce = $qb->joinEntitiesTable($main_alias, 'container_guid');

return $qb->compare("{$ce}.container_guid", '=', $guid, ELGG_VALUE_INTEGER);
},
],
'order_by' => new OrderByClause('time_updated', 'DESC'),
]);
$entities = elgg_call(ELGG_IGNORE_ACCESS, function() use ($guid) {
return elgg_get_entities([
'type' => 'object',
'subtype' => 'comment',
'limit' => 1,
'wheres' => [
function(QueryBuilder $qb, $main_alias) use ($guid) {
$ce = $qb->joinEntitiesTable($main_alias, 'container_guid');

return $qb->compare("{$ce}.container_guid", '=', $guid, ELGG_VALUE_INTEGER);
},
],
'order_by' => new OrderByClause('time_updated', 'DESC'),
]);
});

if (empty($entities)) {
return 0;
}
Expand Down

0 comments on commit e7eefcf

Please sign in to comment.