From b1b2e9bd11e4b7933852cd21b10a4398cb035cbd Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 24 Apr 2024 22:43:32 -0400 Subject: [PATCH] Rework reports query in Moderation\Reports module class - References to non-existent fields removed - Added computed rules field - Patch originally submitted by @TheTomcat14 --- src/Module/Moderation/Reports.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Module/Moderation/Reports.php b/src/Module/Moderation/Reports.php index c9aa92df9c..02c665471f 100644 --- a/src/Module/Moderation/Reports.php +++ b/src/Module/Moderation/Reports.php @@ -56,9 +56,24 @@ class Reports extends BaseModeration $pager = new Pager($this->l10n, $this->args->getQueryString(), 10); - $query = $this->database->p("SELECT `report`.`id`, `report`.`cid`, `report`.`comment`, `report`.`forward`, `report`.`created`, `report`.`reporter-id`, - `report`.`category`, `report`.`rules`, `contact`.`micro`, `contact`.`name`, `contact`.`nick`, `contact`.`url`, `contact`.`addr` FROM report - INNER JOIN `contact` ON `contact`.`id` = `report`.`cid` ORDER BY `report`.`created` DESC LIMIT ?, ?", $pager->getStart(), $pager->getItemsPerPage()); + $query = $this->database->p( + "SELECT + `report`.`id`, `report`.`cid`, `report`.`comment`, `report`.`forward`, `report`.`created`, `report`.`reporter-id`, + `report`.`category-id`, + ( + SELECT GROUP_CONCAT(`report-rule`.`text` ORDER BY `report-rule`.`line-id` SEPARATOR \"\n\") + FROM `report-rule` + WHERE `report-rule`.`rid` = `report`.`id` + GROUP BY `report-rule`.`rid` + ) AS `rules`, + `contact`.`micro`, `contact`.`name`, `contact`.`nick`, `contact`.`url`, `contact`.`addr` +FROM report +INNER JOIN `contact` ON `contact`.`id` = `report`.`cid` +ORDER BY `report`.`created` DESC +LIMIT ?, ?", + $pager->getStart(), + $pager->getItemsPerPage(), + ); $reports = []; while ($report = $this->database->fetch($query)) {