IchHabRecht/content_defender

EXT:container maxitems, same colPos + translation

akoenig-clickstorm opened this issue · 2 comments

Hi,
there is a bug for me with maxitems for containers created with b13/container.

I have multiple container elements on a single page, some of them use the same colPos for their children.
Even if the defined maxitems is not reached for the container element, you are not allowed to add more items or even create translations of theese child elements.

The issue seams to be the method fetchRecordsForColPos() in the ContentRepository.php. The result of the method fetchRecordsForColPos() is an array of uids with the same pid, colPos and language as my new record, so there will be UIDs in the result from other container elements with the same colPos, pid and language.

I have create a patch which also checks the field "tx_container_parent", so that we just get the child uids of the requested container element. With that patch, I have no issue translating container elements with maxitems anymore.

diff --git a/Classes/Repository/ContentRepository.php b/Classes/Repository/ContentRepository.php
index 81920c8..4f6536b 100644
--- a/Classes/Repository/ContentRepository.php
+++ b/Classes/Repository/ContentRepository.php
@@ -196,6 +196,10 @@ class ContentRepository
                 $queryBuilder->expr()->eq(
                     $languageField,
                     $queryBuilder->createNamedParameter($language[0], \PDO::PARAM_INT)
+                ),
+                $queryBuilder->expr()->eq(
+                    'tx_container_parent',
+                    $queryBuilder->createNamedParameter($record['tx_container_parent'], \PDO::PARAM_INT)
                 )
             )
             ->execute();

Hi @akoenig-clickstorm,

Thank you for your patch. But this breaks every installation without container as extension as the field isn't available by default. This needs to be addressed in EXT:container and as far as I remember there is an issue for it already.

I will look into EXT:container to find a solution... and there is a bugfix branch for this issue:
b13/container@a57ddff

Thanks for the hint