teaminmedias-pluswerk / ke_search

Search Extension for TYPO3 Content Management System, including faceting search functions.
https://extensions.typo3.org/extension/ke_search/
GNU General Public License v3.0
35 stars 62 forks source link

The page indexer does not respect 'singe_pages' in page translations #390

Closed Zellwerker closed 3 years ago

Zellwerker commented 3 years ago

If you don't set 'startingpoints_recursive' but only 'single_pages' then the indexer cannot index the translations.

On closer inspection, it becomes apparent that 'startingpoints_recursive' must be set for the search indexing of the translation pages.

But that cannot always be wanted. I recommend paying attention to 'single_pages' when recognizing the page translations.

// The original code only works with 'startingpoints_recursive'
// EXT:ke_search\Classes\Indexer\Types\Page.php:207-221

        // get all available sys_language_uid records
        /** @var TranslationConfigurationProvider $translationProvider */
        $translationProvider = GeneralUtility::makeInstance(TranslationConfigurationProvider::class);
        if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_branch) >=
            \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger('10.0')
        ) {
            $startingPoints = GeneralUtility::trimExplode(',', $this->indexerConfig['startingpoints_recursive'], true);
            foreach ($startingPoints as $startingPoint) {
                foreach ($translationProvider->getSystemLanguages($startingPoint) as $key => $lang) {
                    $this->sysLanguages[$key] = $lang;
                }
            }
        } else {
            $this->sysLanguages = $translationProvider->getSystemLanguages();
        }

It should be right like that

// This also recognizes translations only with 'single_pages'
// EXT:ke_search\Classes\Indexer\Types\Page.php:207

        // get all available sys_language_uid records
        /** @var TranslationConfigurationProvider $translationProvider */
        $translationProvider = GeneralUtility::makeInstance(TranslationConfigurationProvider::class);
        if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_branch) >=
            \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger('10.0')
        ) {
            // FIX: Beginn
            $startingPoints = [];
            $startingPoints += GeneralUtility::trimExplode(',', $this->indexerConfig['startingpoints_recursive'], true);
            $startingPoints += GeneralUtility::trimExplode(',', $this->indexerConfig['single_pages'], true);
            // FIX: End
            foreach ($startingPoints as $startingPoint) {
                foreach ($translationProvider->getSystemLanguages($startingPoint) as $key => $lang) {
                    $this->sysLanguages[$key] = $lang;
                }
            }
        } else {
            $this->sysLanguages = $translationProvider->getSystemLanguages();
        }

Thanks for the support you have made a great product.