From 2d108e5557d2bd67a57ba9cbf54624b2bbdd7d63 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 Aug 2025 19:30:33 +0000 Subject: [PATCH 1/4] Initial plan From d4ea5ec73ec6e9e856f39c66d1b576c888e14dc9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 Aug 2025 19:48:24 +0000 Subject: [PATCH 2/4] Fix tag search pagination issue by coordinating pagination logic Co-authored-by: thorsten <45284+thorsten@users.noreply.github.com> --- phpmyfaq/search.php | 8 +++++++- phpmyfaq/src/phpMyFAQ/Faq.php | 9 +++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/phpmyfaq/search.php b/phpmyfaq/search.php index ff8db668f1..da48fc35c4 100755 --- a/phpmyfaq/search.php +++ b/phpmyfaq/search.php @@ -152,8 +152,14 @@ } } - $searchResults = $faq->renderFaqsByFaqIds($recordIds); $numOfResults = count($recordIds); + + // Apply pagination to record IDs for tag search + $confPerPage = $faqConfig->get('records.numberOfRecordsPerPage'); + $first = ($page - 1) * $confPerPage; + $paginatedRecordIds = array_slice($recordIds, $first, $confPerPage); + + $searchResults = $faq->renderFaqsByFaqIds($paginatedRecordIds, 'fd.id', 'ASC', false); } } else { $searchResults = []; diff --git a/phpmyfaq/src/phpMyFAQ/Faq.php b/phpmyfaq/src/phpMyFAQ/Faq.php index 53e1a99ead..2dddf887bb 100755 --- a/phpmyfaq/src/phpMyFAQ/Faq.php +++ b/phpmyfaq/src/phpMyFAQ/Faq.php @@ -460,10 +460,11 @@ public function renderFaqsByCategoryId(int $categoryId, string $orderBy = 'id', * @param int[] $faqIds Array of record ids * @param string $orderBy Order by * @param string $sortBy Sort by + * @param bool $usePagination Whether to use internal pagination * @throws CommonMarkException * @todo this method needs to be refactored, parts of it should be moved to a Twig template */ - public function renderFaqsByFaqIds(array $faqIds, string $orderBy = 'fd.id', string $sortBy = 'ASC'): array + public function renderFaqsByFaqIds(array $faqIds, string $orderBy = 'fd.id', string $sortBy = 'ASC', bool $usePagination = true): array { $records = implode(', ', $faqIds); $page = Filter::filterInput(INPUT_GET, 'seite', FILTER_VALIDATE_INT, 1); @@ -533,7 +534,7 @@ public function renderFaqsByFaqIds(array $faqIds, string $orderBy = 'fd.id', str $num = $this->configuration->getDb()->numRows($result); $numberPerPage = $this->configuration->get('records.numberOfRecordsPerPage'); - $first = $page == 1 ? 0 : ($page * $numberPerPage) - $numberPerPage; + $first = $usePagination && $page > 1 ? ($page * $numberPerPage) - $numberPerPage : 0; $searchResults = []; if ($num > 0) { @@ -541,9 +542,9 @@ public function renderFaqsByFaqIds(array $faqIds, string $orderBy = 'fd.id', str $displayedCounter = 0; $lastFaqId = 0; $faqHelper = new FaqHelper($this->configuration); - while (($row = $this->configuration->getDb()->fetchObject($result)) && $displayedCounter < $numberPerPage) { + while (($row = $this->configuration->getDb()->fetchObject($result)) && (!$usePagination || $displayedCounter < $numberPerPage)) { ++$counter; - if ($counter <= $first) { + if ($usePagination && $counter <= $first) { continue; } From a2495c80bb4a1288b850956a417192a050539f26 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 15:57:23 +0000 Subject: [PATCH 3/4] Fix line length violations: break long method signature and while condition Co-authored-by: thorsten <45284+thorsten@users.noreply.github.com> --- phpmyfaq/src/phpMyFAQ/Faq.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpmyfaq/src/phpMyFAQ/Faq.php b/phpmyfaq/src/phpMyFAQ/Faq.php index 2dddf887bb..4db8a95744 100755 --- a/phpmyfaq/src/phpMyFAQ/Faq.php +++ b/phpmyfaq/src/phpMyFAQ/Faq.php @@ -464,7 +464,12 @@ public function renderFaqsByCategoryId(int $categoryId, string $orderBy = 'id', * @throws CommonMarkException * @todo this method needs to be refactored, parts of it should be moved to a Twig template */ - public function renderFaqsByFaqIds(array $faqIds, string $orderBy = 'fd.id', string $sortBy = 'ASC', bool $usePagination = true): array + public function renderFaqsByFaqIds( + array $faqIds, + string $orderBy = 'fd.id', + string $sortBy = 'ASC', + bool $usePagination = true + ): array { $records = implode(', ', $faqIds); $page = Filter::filterInput(INPUT_GET, 'seite', FILTER_VALIDATE_INT, 1); @@ -542,7 +547,10 @@ public function renderFaqsByFaqIds(array $faqIds, string $orderBy = 'fd.id', str $displayedCounter = 0; $lastFaqId = 0; $faqHelper = new FaqHelper($this->configuration); - while (($row = $this->configuration->getDb()->fetchObject($result)) && (!$usePagination || $displayedCounter < $numberPerPage)) { + while ( + ($row = $this->configuration->getDb()->fetchObject($result)) && + (!$usePagination || $displayedCounter < $numberPerPage) + ) { ++$counter; if ($usePagination && $counter <= $first) { continue; From 28e1c12ff8cbec8db74247a107e41f36aa72f838 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 16:09:09 +0000 Subject: [PATCH 4/4] Fix function declaration formatting: move opening brace to same line as closing parenthesis Co-authored-by: thorsten <45284+thorsten@users.noreply.github.com> --- phpmyfaq/src/phpMyFAQ/Faq.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpmyfaq/src/phpMyFAQ/Faq.php b/phpmyfaq/src/phpMyFAQ/Faq.php index 4db8a95744..fe6cf5f411 100755 --- a/phpmyfaq/src/phpMyFAQ/Faq.php +++ b/phpmyfaq/src/phpMyFAQ/Faq.php @@ -469,8 +469,7 @@ public function renderFaqsByFaqIds( string $orderBy = 'fd.id', string $sortBy = 'ASC', bool $usePagination = true - ): array - { + ): array { $records = implode(', ', $faqIds); $page = Filter::filterInput(INPUT_GET, 'seite', FILTER_VALIDATE_INT, 1);