#86276Counting LazyObjectStorages doesn't return the expected result
Description
I’m having trouble with the counting of `ObjectStorages` and just wanted to report an obscure behaviour I encountered.
Iterating over records in Fluid works as expected, but counting them is not possible as you can see in the attached screenshot. The Debugger and every manually invoked “counting” (in fluid, or in the controller code) of the `members`-property returns 18 which is the correct count of members including the translations.
But I’m only interested in the “real” count, as you can see, there are only 6 objects in the members’ `LazyObjectStorage` and the corresponding list is only rendering 6 items in the default language.
This problem is LazyObjectStorage specific, removing the `@lazy` annotations does return an ObjectStorage with the same members but the correct count.
The TCA annotation looks like the following, although I think Extbase doesn’t really respect that at that point:
'members' => [
'exclude' => 1,
'l10n_mode' => 'exclude',
'label' => 'LLL:EXT:cmb_members/Resources/Private/Language/locallang_db.xlf:tx_cmbmembers_domain_model_orgunit.members',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_cmbmembers_domain_model_member',
'foreign_field' => 'status',
'foreign_table_where' => 'AND tx_cmbmembers_domain_model_member.sys_language_uid === 0',
],
],Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Files 1
History 7
-
Christian Richter commented 09/16/18, 17:05
-
Tymoteusz Motylewski commented 09/19/18, 11:59
Hi Christian
Thanks for your report.
Every fix for extbase query and persistence requires to have a functional tests in order to be merged.Are you able to provide an functional test showing the issue (e.g. based on blog_example fixture extension from extbase)? I can guide you through the process if neede.
If not, then can you provide a minimal code example showing the wrong behavior and what you would expect?
This would help a lot! -
Susanne Moog changed target version 09/19/18, 12:21
-
Christian Richter commented 09/19/18, 12:31
I would love to create more helpful bug reports in the future!
If you have the motivation and most of all the time to guide me through the process, that would be awesome!
Best
Christian -
Tymoteusz Motylewski commented 09/27/18, 16:03
Please reach out to me on slack Christian.
-
Tymoteusz Motylewski changed removed the assignee 07/08/24, 17:55
-
Garvin Hicking commented and changed status
NewClosed 07/08/24, 20:43IMO this is a general problem of how LazyObjects work. The stubs are needed and can only be really worked on after they have been ‘thawed’.
Using count() on it doesn’t invoke the thawing, so you’d have to really use the getter for that member property, and after that you can count them.
Since no work has been done on the issue and I believe this is an implementation detail that can’t be changed easily, I’m closing the issue. I hope that is okay with you; if you believe this is a mistake or want to restart work on this, please let me know and we can see. :)
Thanks, also for the initiative to try to work on it!
I’m sorry @Tymoteusz Motylewski, I didn’t really want to assign someone directly…
If it was some kind of auto-assignment, I’m happy to provide more details!
Have a nice Sunday!