Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 19, 2025

After updating to phpMyFAQ 4.0.10, tag search functionality was broken - searches would show no results on any page, including the first page in some cases. The issue was caused by conflicting pagination logic between the search controller and the FAQ rendering method.

Root Cause

The renderFaqsByFaqIds method in Faq.php implements its own internal pagination logic that skips records based on the current page number. However, the tag search in search.php was also setting up pagination independently, creating a mismatch:

  1. Tag search gets all matching FAQ IDs (e.g., 15 records)
  2. Calls renderFaqsByFaqIds with all IDs
  3. renderFaqsByFaqIds applies its own pagination, skipping records for page 2+
  4. Search controller expects different results than what's actually rendered
  5. Result: No results shown on subsequent pages

Solution

This PR coordinates the two pagination systems by:

  1. Adding an optional $usePagination parameter to renderFaqsByFaqIds (defaults to true for backward compatibility)
  2. Implementing pagination at the search level for tag searches by slicing the record IDs array before rendering
  3. Disabling internal pagination for tag searches to prevent conflicts

Example

Before the fix, with 15 tag search results and 10 records per page:

  • Page 1: Shows records 1-10 ✅
  • Page 2: Shows no results ❌ (internal pagination skips first 10, but only 5 remain)

After the fix:

  • Page 1: Shows records 1-10 ✅
  • Page 2: Shows records 11-15 ✅
  • Page 3: Shows no results ✅ (as expected)

Changes

  • search.php: Added proper pagination logic for tag searches (7 lines added, 1 removed)
  • Faq.php: Added optional pagination control parameter (5 lines added, 4 modified)

The changes are minimal and maintain full backward compatibility with existing code.

Fixes #3579.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/2tvenom/CBOREncode/zipball/42aedccb861d01fc0554782348cc08f8ebf22332
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/Bacon/BaconQrCode/zipball/f9cc1f52b5a463062251d666761178dbdb6b544f
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/DASPRiD/Enum/zipball/8dfd07c6d2cf31c8da90c53b83c026c7696dda90
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/nqPerO /usr/bin/composer install --no-dev (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/Seldaek/monolog/zipball/10d85740180ecba7896c87e06a166e0c95a0e3b6
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/bovigo/vfsStream/zipball/fe695ec993e0a55c3abdda10a9364eb31c6f1bf0
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/a23a2bf4f31d3518f3ecb38660c95715dfead60f
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/doctrine/deprecations/zipball/459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/doctrine/lexer/zipball/31ad66abc0fc9e1a1f2d9bc6a42668d2fbbcd6dd
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/elastic/elastic-transport-php/zipball/1d476af5dc0b74530d59b67d5dd96ee39768d5a4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/elastic/elasticsearch-php/zipball/1771284cb43a7b653634d418b6f5f0ec84ff8a6d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/endroid/qr-code/zipball/21e888e8597440b2205e2e5c484b6c8e556bcd1a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/ezimuel/guzzlestreams/zipball/903161be81e9f497cc42fb7db982404a4e6441b0
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/ezimuel/ringphp/zipball/bc983599ec7add50c00e420e867c403c8ed16ae7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/guzzle/guzzle/zipball/7b2f29fe81dc4da0ca0ea7d42107a0845946ea77
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/guzzle/promises/zipball/7c69f28996b0a6920945dd20b3857e499d9ca96c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/guzzle/psr7/zipball/c2270caaabe631b3b44c85f99e5a04bbb8060d16
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/nette/schema/zipball/da801d52f0354f70a638673c4a0f04e16529431d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/nette/utils/zipball/c930ca4e3cf4f17dcfb03037703679d2396d2ede
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/opensearch-project/opensearch-php/zipball/97e942dfac44d40d3db5b3c4a8656fe0d1e22294
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/opentelemetry-php/api/zipball/b3a9286f9c1c8247c83493c5b1fa475cd0cec7f7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/opentelemetry-php/context/zipball/438f71812242db3f196fb4c717c6f92cbc819be6
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/paragonie/constant_time_encoding/zipball/df1e7fde177501eee2037dd159cf04f5f301a512
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/nqPerO /usr/bin/composer install --no-dev (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/php-http/discovery/zipball/82fe4c73ef3363caed49ff8dd1539ba06044910d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/php-http/httplug/zipball/5cad731844891a4c282f3f3e1b582c46839d22f4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/php-http/promise/zipball/fc85b1fba37c169a69a07ef0d5a8075770cc1f83
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94f8051919d1b0369a6bcc7931d679a511c03fe9
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/679e3ce485b99e84c775d28e2e96fade9a7fb50a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/phpseclib/phpseclib/zipball/56483a7de62a6c2a6635e42e93b8a9e25d4f0ec6
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/phpstan/phpdoc-parser/zipball/b9e61a61e39e02dd90944e9115241c7f7e76bfd8
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/reactphp/promise/zipball/8a164643313c71354582dc850b42b33fa12a4b63
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/4bfa827c969c98be1e527abd576533293c634f6a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/0b01998a7d5b1f122911a66bebcb8d46f0c82d8c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/e549163b9760b8f71f191651d22acf32d56d6d4d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/3e6ccf7657d4f0a59200564b08cead899313b53c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/symfony/http-client-contracts/zipball/75d7043853a42837e68111812f4d964b01e5101c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/symfony/http-client/zipball/1c064a0c67749923483216b081066642751cc2c7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-php82/zipball/5d2ed36f7734637dacc025f179698031951b1692
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/symfony/service-contracts/zipball/f021b05a130d35510bd6b25fe9053c2a8a15d5d4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/symfony/yaml/zipball/b8d7d868da9eb0919e99c8830431ea087d6aae30
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/thephpleague/commonmark/zipball/10732241927d3971d28e7ea7b5712721fa2296ca
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/thephpleague/config/zipball/754b3604fb2984c71f4af4a9cbe7b57f346ec1f3
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/thephpleague/uri-interfaces/zipball/08cfc6c4f3d811584fb09c37e2849e6a7f9b0742
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)
  • https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/s1HTMO /usr/bin/composer install --dev --no-interaction (http block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Contributor Author

Copilot AI commented Aug 19, 2025

@thorsten 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Co-authored-by: thorsten <45284+thorsten@users.noreply.github.com>
@thorsten thorsten marked this pull request as ready for review August 19, 2025 19:50
Copilot AI changed the title [WIP] After updating to 4.0.10 tag search shows no results Fix tag search pagination issue causing no results on subsequent pages Aug 19, 2025
Copilot AI requested a review from thorsten August 19, 2025 19:50
* @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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line exceeds 120 characters; contains 139 characters, please fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit a2495c8. Broke the long method signature into multiple lines to stay within the 120 character limit.

$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)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line exceeds 120 characters; contains 141 characters, please fix that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit a2495c8. Broke the long while condition into multiple lines to stay within the 120 character limit.

@coderabbitai
Copy link

coderabbitai bot commented Aug 19, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Join our Discord community for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@thorsten
Copy link
Owner

@copilot please fix the open issues

…dition

Co-authored-by: thorsten <45284+thorsten@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 20, 2025

@copilot please fix the open issues

Fixed both line length violations in commit a2495c8. The method signature and while loop condition have been broken into multiple lines to comply with the 120 character limit.

Copilot AI requested a review from thorsten August 20, 2025 15:58
string $orderBy = 'fd.id',
string $sortBy = 'ASC',
bool $usePagination = true
): array
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line, please fixt that @copilot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 28e1c12. The closing parenthesis and opening brace are now on the same line as required by PSR-12 standards.

…as closing parenthesis

Co-authored-by: thorsten <45284+thorsten@users.noreply.github.com>
Copilot AI requested a review from thorsten August 20, 2025 16:10
@thorsten thorsten merged commit e64e749 into main Aug 21, 2025
9 checks passed
@thorsten thorsten deleted the copilot/fix-3579 branch November 7, 2025 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

After updating to 4.0.10 tag search shows no results

2 participants