Skip to content

Commit

Permalink
Fixed #15915
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Oct 22, 2024
1 parent 795f098 commit d46b5b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Fixed a bug where admin table header cells weren’t indicating when they were sorted. ([#15897](https://github.com/craftcms/cms/issues/15897))
- Fixed an error that occurred when creating a database backup, if the System Name contained any quote-like characters. ([#15933](https://github.com/craftcms/cms/issues/15933))
- Fixed a bug where buttons could bleed out of their containers. ([#15931](https://github.com/craftcms/cms/issues/15931), [#15946](https://github.com/craftcms/cms/pull/15946))
- Fixed a PHP error. ([#15915](https://github.com/craftcms/cms/issues/15915))
- Fixed an information disclosure vulnerability.

## 4.12.7 - 2024-10-15
Expand Down
10 changes: 6 additions & 4 deletions src/services/Elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
use craft\validators\HandleValidator;
use craft\validators\SlugValidator;
use DateTime;
use Illuminate\Support\Collection;
use Throwable;
use UnitEnum;
use yii\base\Behavior;
Expand Down Expand Up @@ -2452,7 +2453,7 @@ public function getRecentActivity(ElementInterface $element, ?int $excludeUserId
->indexBy('id')
->all();

$activity = [];
$activity = Collection::make();
/** @var ElementActivity[] $activityByUserId */
$activityByUserId = [];
$elements = [];
Expand All @@ -2468,7 +2469,7 @@ public function getRecentActivity(ElementInterface $element, ?int $excludeUserId
$newerRecord->type === ElementActivity::TYPE_VIEW &&
$result['type'] !== ElementActivity::TYPE_VIEW
) {
array_splice($activity, array_search($newerRecord, $activity), 1);
$activity = $activity->filter(fn(ElementActivity $record) => $record !== $newerRecord);
unset($activityByUserId[$result['userId']]);
} else {
continue;
Expand Down Expand Up @@ -2501,15 +2502,16 @@ public function getRecentActivity(ElementInterface $element, ?int $excludeUserId
$elements[$elementKey][$result['siteId']] = $resultElement;
}

$activity[] = $activityByUserId[$result['userId']] = new ElementActivity(
$record = $activityByUserId[$result['userId']] = new ElementActivity(
$users[$result['userId']],
$elements[$elementKey][$result['siteId']],
$result['type'],
DateTimeHelper::toDateTime($result['timestamp']),
);
$activity->push($record);
}

return $activity;
return $activity->values()->all();
}

/**
Expand Down

0 comments on commit d46b5b0

Please sign in to comment.