Bug #46939
closedBehaviour of getObjectCountByQuery and language
Added by Eike Starkmann over 11 years ago. Updated almost 6 years ago.
0%
Description
I got the problem, that my paginator does not respect the actual language of the site. The amount if item are always all items (sys_language_uid (0,-1))
The Problem is that the paginator calls count() on Tx_Extbase_Persistence_QueryResultInterface to get the amount of items.
So that all comes down to getObjectCountByQuery in Tx_Extbase_Persistence_Storage_Typo3DbBackend. The functions is always working on sys_language_uid (0,-1) if RespectSysLanguage is set.
I'm not sure if changing the function to respect the language would cause any site effects.
Files
t3_test_0.0.0_201409251034.zip (515 KB) t3_test_0.0.0_201409251034.zip | Test Extension with pagination | Rainer Becker, 2014-09-25 10:50 |
Updated by Rainer Becker over 11 years ago
I stumbled over this issue too (TYPO3 6.0). If not all records are translated and you use the paginatorWidget then item count doesn’t respect that there are untranslated objects. There are too many pagination links and there are not enough results to fill the page. Probably this is due to the fact that language and WS overlays right now can not be handled by the SQL query (asfaik the overlays are applied after the query execution; limit and offset are not applied to the final result but only to the initial query).
This is a major drawback because you first have to fetch all records, call toArray() and apply the pagination whereas the query should fetch only the items really needed... This will needless cost resources when you want to paginate hundreds or thousends of items.
Updated by Eike Starkmann over 11 years ago
That's exactly the way i solved this issue, by calling toArray() on all records and then count them since they are overplayed then. But this really cost lots of resources.
I think in 6.0 you can also change the query by setRespectSysLanguage and setSysLanguageUid. But in 1.3 setSysLanguageUid does not exist.
Updated by Rainer Becker over 11 years ago
How would setRespectSysLanguage and setSysLanguageUid help in this case? The found translated objects are the right ones but they are not counted correctly. Would be cool to have a solution for that.
Updated by Alexander Schnitzler over 11 years ago
- Category set to Extbase: Generic Persistence
Updated by Alexander Schnitzler over 11 years ago
- Status changed from New to Accepted
Updated by Andreas Wolf over 11 years ago
- Subject changed from Behavoir of getObjectCountByQuery and language to Behaviour of getObjectCountByQuery and language
Updated by Eike Starkmann over 11 years ago
Rainer Becker wrote:
How would setRespectSysLanguage and setSysLanguageUid help in this case? The found translated objects are the right ones but they are not counted correctly. Would be cool to have a solution for that.
Yes and no: The translated are not the right ones. At beginning the are just all object with (sys_language_uid (0,-1)) in $objects, but when you render them they get overlayed so that it seems you have the right objects.
If i understood it right, you can deactivate the "AND sys_language_uid IN (0,-1)" in the query by setting setRespectSysLanguage=FALSE. Then you get all data even the translated ones.
If you now set setSysLanguageUid to the language you need you only get data in your language and then you can count them.
Without having tested:
$query = $this->createQuery();
$query->getQuerySettings()->setRespectSysLanguage(FALSE);
$query->getQuerySettings()->setSysLanguageUid($sys_uid);
$objects=$query->execute();
$count=$objects->count();
So $count would be the amount of data with the sys_language_uid=$sys_uid.
Updated by Anja Leichsenring over 11 years ago
- Target version changed from Extbase 1.3 to Extbase 6.3
Updated by Felix Oertel over 11 years ago
- Priority changed from Should have to Must have
- Tags set to ecs13ws
Yep, common problem, that we can't resolve the enableFields in translated records. Even with all language settings set right, a widget would not be able to get the correct number, because the overlay (and thus elemination of the hidden/deletes) will only take place after fetching them from the DB.
We will definetly deal with this one at #ecs13ws.
Updated by Felix Oertel over 11 years ago
- Target version changed from Extbase 6.3 to Extbase 6.2
Updated by Alexander Opitz about 10 years ago
- Status changed from Accepted to Needs Feedback
Hi,
was this issue fixed or does it still exists?
Updated by Rainer Becker about 10 years ago
This issue still exists in TYPO3 6.2.5.
I attached a test extension with a frontend list plugin including a paginated list (5 items per page).
I created 7 records for langID = 0 and translated all of them to langID 1 except the fifth record.
For L=0 the list shows records 1-5 on page 1 (correct). For L=1 the list shows records 1-4 on page 1 which is wrong - record 6 should be shown here, too.
Updated by Alexander Opitz about 10 years ago
- Project changed from 534 to TYPO3 Core
- Category changed from Extbase: Generic Persistence to Extbase
- Status changed from Needs Feedback to New
- Target version changed from Extbase 6.2 to 7.0
- TYPO3 Version set to 6.2
- Is Regression set to No
Updated by Mathias Schreiber almost 10 years ago
- Target version changed from 7.0 to 7.1 (Cleanup)
Updated by Benni Mack over 9 years ago
- Target version changed from 7.1 (Cleanup) to 7.4 (Backend)
Updated by Susanne Moog over 9 years ago
- Target version changed from 7.4 (Backend) to 7.5
Updated by Tymoteusz Motylewski about 7 years ago
- Category changed from Extbase to Extbase + l10n
Updated by Tymoteusz Motylewski about 6 years ago
- Related to Bug #84707: Extbase wrongly counting translated objects added
Updated by Tymoteusz Motylewski about 6 years ago
- Status changed from New to Needs Feedback
Please check if the patch https://review.typo3.org/#/c/53974/ solves the issue for you, I'm pretty sure it does.
Updated by Riccardo De Contardi almost 6 years ago
- Status changed from Needs Feedback to Closed
No feedback since the last 90 days => closing this issue.
If you think that this is the wrong decision or experience the issue again and have more information about how to reproduce your problem, please reopen it or open a new issue with a reference to this one.
Thank you and best regards