From 1ac47b480a3da45a336b2a97e829cebd8970dfbb Mon Sep 17 00:00:00 2001 From: Michael Eshom Date: Fri, 8 Dec 2023 22:22:38 -0500 Subject: [PATCH 1/5] Can't return something if it's never set... Signed-off-by: Michael Eshom --- Sources/PersonalMessage/Received.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/PersonalMessage/Received.php b/Sources/PersonalMessage/Received.php index 7f20c3b537..56cd5c6ddb 100644 --- a/Sources/PersonalMessage/Received.php +++ b/Sources/PersonalMessage/Received.php @@ -525,6 +525,7 @@ public static function getRecent(int $label = -1, string $sort = 'pmr.id_pm', bo } $joins = []; + self::$recent[$paramskey] = []; $where = [ 'pmr.id_member = {int:me}', From e503cebf588689d01fecb5f617da925adfd0679c Mon Sep 17 00:00:00 2001 From: Michael Eshom Date: Fri, 8 Dec 2023 22:43:47 -0500 Subject: [PATCH 2/5] Don't use $_GET['start'] without making sure it exists... Signed-off-by: Michael Eshom --- Sources/PersonalMessage/Search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/PersonalMessage/Search.php b/Sources/PersonalMessage/Search.php index 7db2d838aa..8a7f7785fe 100644 --- a/Sources/PersonalMessage/Search.php +++ b/Sources/PersonalMessage/Search.php @@ -321,7 +321,7 @@ public function performSearch(): void // Sort out the page index. Utils::$context['page_index'] = new PageIndex( Config::$scripturl . '?action=pm;sa=search2;params=' . $this->compressed_params, - $_GET['start'], + ((int) $_GET['start'] ?? 0), Utils::$context['num_results'], $this->per_page, false, From 141aeee0eaf13c5db8251322216a510b2d395207 Mon Sep 17 00:00:00 2001 From: Michael Eshom Date: Fri, 8 Dec 2023 22:54:54 -0500 Subject: [PATCH 3/5] SMF might be expecting an array of IDs even when we don't have any... Signed-off-by: Michael Eshom --- Sources/PersonalMessage/PM.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Sources/PersonalMessage/PM.php b/Sources/PersonalMessage/PM.php index 058ec72dc0..24873e6a85 100644 --- a/Sources/PersonalMessage/PM.php +++ b/Sources/PersonalMessage/PM.php @@ -531,9 +531,8 @@ public static function get($ids, array $query_customizations = []) $limit = $query_customizations['limit'] ?? count($ids); $params = $query_customizations['params'] ?? []; - if (!empty($ids)) { - $params['ids'] = array_filter(array_unique(array_map('intval', $ids))); - } + // There will never be an ID 0, but SMF doesn't like empty arrays when you tell it to expect an array of integers... + $params['ids'] = empty($ids) ? [0] : array_filter(array_unique(array_map('intval', $ids))); foreach(self::queryData($selects, $params, $joins, $where, $order, $group, $limit) as $row) { $id = (int) $row['id_pm']; From 7dfa37fa3a09b0335e36d1685ca42e7e3c601a4a Mon Sep 17 00:00:00 2001 From: Michael Eshom Date: Sat, 9 Dec 2023 19:39:32 -0500 Subject: [PATCH 4/5] Passing false as a second param to pm::load is unnecessary and causes an error Signed-off-by: Michael Eshom --- Sources/PersonalMessage/Popup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/PersonalMessage/Popup.php b/Sources/PersonalMessage/Popup.php index 22b10cbc04..a15e9a1f63 100644 --- a/Sources/PersonalMessage/Popup.php +++ b/Sources/PersonalMessage/Popup.php @@ -65,7 +65,7 @@ public function show(): void } // Now, actually fetch me some PMs. - foreach (PM::load($pms, false) as $pm) { + foreach (PM::load($pms) as $pm) { // Make sure we track the senders. We have some work to do for them. if (!empty($pm->member_from)) { $senders[] = $pm->member_from; From 51da0a41c1afc5d411ea57f0bdaeda918b1d50fd Mon Sep 17 00:00:00 2001 From: Jon Stovell Date: Sat, 23 Dec 2023 19:44:45 -0700 Subject: [PATCH 5/5] Apply suggestions from code review --- Sources/PersonalMessage/Received.php | 3 ++- Sources/PersonalMessage/Search.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/PersonalMessage/Received.php b/Sources/PersonalMessage/Received.php index 56cd5c6ddb..495e56b7a2 100644 --- a/Sources/PersonalMessage/Received.php +++ b/Sources/PersonalMessage/Received.php @@ -524,9 +524,10 @@ public static function getRecent(int $label = -1, string $sort = 'pmr.id_pm', bo return self::$recent[$paramskey]; } - $joins = []; self::$recent[$paramskey] = []; + $joins = []; + $where = [ 'pmr.id_member = {int:me}', 'pmr.deleted = 0', diff --git a/Sources/PersonalMessage/Search.php b/Sources/PersonalMessage/Search.php index 8a7f7785fe..3a3ddf7062 100644 --- a/Sources/PersonalMessage/Search.php +++ b/Sources/PersonalMessage/Search.php @@ -321,7 +321,7 @@ public function performSearch(): void // Sort out the page index. Utils::$context['page_index'] = new PageIndex( Config::$scripturl . '?action=pm;sa=search2;params=' . $this->compressed_params, - ((int) $_GET['start'] ?? 0), + (int) ($_GET['start'] ?? 0), Utils::$context['num_results'], $this->per_page, false,