Skip to content

Conversation

smatyas
Copy link
Contributor

@smatyas smatyas commented Oct 3, 2024

This PR tries to solve the problem where the user reaches the mysql join table count limitation due to many translatable fields.

If we have too many, the following mysql error arises:

ERROR 1116 (HY000): Too many tables; MySQL can only use 61 tables in a join


Certainly, it is not a complete solution for the problem, meaning that we will still be unable to translate every field in one query, but I found it really useful in certain scenarios.

Using this optional hint, the user can be selective about the fields to translate, so it will limit the number of joins to those fields.

Without this, the user have to use different workarounds that makes this extension less useful.


usage example:

        $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, TranslationWalker::class);
        $query->setHint(TranslatableListener::HINT_FALLBACK, 1);
        $query->setHint(TranslatableListener::HINT_TRANSLATABLE_LOCALE, $locale);

        // Only these fields will be translated by the walker.
        $query->setHint(TranslationWalker::HINT_ONLY_FIELDS, [
            'entity.marketingTitle',
            'entity.marketingDescription',
            'event.name',
            'marketingCategory.name'
        ]);

Copy link

codecov bot commented Oct 3, 2024

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.82%. Comparing base (0632ab1) to head (05072ed).
⚠️ Report is 134 commits behind head on main.

Files with missing lines Patch % Lines
...ranslatable/Query/TreeWalker/TranslationWalker.php 40.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2874      +/-   ##
==========================================
+ Coverage   78.75%   78.82%   +0.07%     
==========================================
  Files         163      167       +4     
  Lines        8593     8643      +50     
==========================================
+ Hits         6767     6813      +46     
- Misses       1826     1830       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@phansys phansys added Bug A confirmed bug in Extensions that needs fixing. Needs Tests labels Jan 14, 2025
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Sep 28, 2025
@smatyas
Copy link
Contributor Author

smatyas commented Sep 28, 2025

We still use a custom walker to mitigate this limitation. Is there a chance to merge this any time? If so, we're willing to cover it with tests.

@github-actions github-actions bot removed the Stale label Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A confirmed bug in Extensions that needs fixing. Needs Tests Translatable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants