diff --git a/CHANGELOG.md b/CHANGELOG.md index 2645001740b..897cd6b291e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/services/Elements.php b/src/services/Elements.php index 71179d82539..736b9a94e23 100644 --- a/src/services/Elements.php +++ b/src/services/Elements.php @@ -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; @@ -2452,7 +2453,7 @@ public function getRecentActivity(ElementInterface $element, ?int $excludeUserId ->indexBy('id') ->all(); - $activity = []; + $activity = Collection::make(); /** @var ElementActivity[] $activityByUserId */ $activityByUserId = []; $elements = []; @@ -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; @@ -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(); } /**