From 0633ce986da27bffeef1ba16eeb288368065e624 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 21 Mar 2023 14:00:34 -0700 Subject: [PATCH] Fixed #12944 --- CHANGELOG.md | 1 + src/controllers/UsersController.php | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27c2056999c..be9027170c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fixed a bug where relation data was getting deleted when running garbage collection on PostgreSQL. ([#9905](https://github.com/craftcms/cms/issues/9905)) - Fixed a bug where Lightswitch fields’ “OFF Label” and “ON Label” settings weren’t getting translated. ([#12942](https://github.com/craftcms/cms/issues/12942)) +- Fixed a bug where `craft\events\DefineUserContentSummaryEvent::$userId` was never set for `craft\controllers\EVENT_DEFINE_CONTENT_SUMMARY` events. ([#12944](https://github.com/craftcms/cms/issues/12944)) - Updated svg-sanitizer to 0.16. ([#12943](https://github.com/craftcms/cms/issues/12943)) ## 3.8.4 - 2023-03-20 diff --git a/src/controllers/UsersController.php b/src/controllers/UsersController.php index 81d4eeca3f1..47252b8758a 100644 --- a/src/controllers/UsersController.php +++ b/src/controllers/UsersController.php @@ -1603,9 +1603,17 @@ public function actionUserContentSummary(): Response { $this->requirePostRequest(); - $userIds = $this->request->getRequiredBodyParam('userId'); + $userId = $this->request->getRequiredBodyParam('userId'); + + if (is_array($userId)) { + $userId = array_map(function($id) { + return (int)$id; + }, $userId); + } else { + $userId = (int)$userId; + } - if ($userIds !== (string)Craft::$app->getUser()->getIdentity()->id) { + if ($userId !== (int)Craft::$app->getUser()->getIdentity()->id) { $this->requirePermission('deleteUsers'); } @@ -1614,7 +1622,7 @@ public function actionUserContentSummary(): Response foreach (Craft::$app->getSections()->getAllSections() as $section) { $entryCount = Entry::find() ->sectionId($section->id) - ->authorId($userIds) + ->authorId($userId) ->site('*') ->unique() ->anyStatus() @@ -1630,6 +1638,7 @@ public function actionUserContentSummary(): Response // Fire a 'defineUserContentSummary' event $event = new DefineUserContentSummaryEvent([ + 'userId' => $userId, 'contentSummary' => $summary, ]); $this->trigger(self::EVENT_DEFINE_CONTENT_SUMMARY, $event);