Skip to content

Commit

Permalink
Fix recently edited resources (sub)query (#16460)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtripault authored Oct 3, 2023
1 parent eae6e62 commit 7ecadc5
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,21 @@ public function prepareQueryBeforeCount(xPDOQuery $c)
{
$user = $this->getProperty('user');
$q = $this->modx->newQuery($this->classKey, ['classKey:IN' => $this->classKeys]);
$q->select('MAX(id), item');
$q->select('MAX(id)');
if (!empty($user)) {
$q->where(['user' => $user]);
$c->where(['user' => $user]);
}
$q->groupby('item');
$q->limit($this->getProperty('limit', 10));
if ($q->prepare() && $q->stmt->execute()) {
if ($ids = $q->stmt->fetchAll(PDO::FETCH_COLUMN)) {
$c->where(['id:IN' => $ids]);
} else {
$c->where(['id' => -1]);
}
}

$sql = '-1';
if ($q->prepare()) {
$sql = $q->toSQL();
}
$c->select($this->modx->getSelectColumns(modManagerLog::class, 'modManagerLog'));
$c->where(<<<SQL
id in ({$sql})
SQL
);

return $c;
}
Expand Down

0 comments on commit 7ecadc5

Please sign in to comment.