TYPO3-Solr / ext-solr

A TYPO3 extension that integrates the Apache Solr search server with TYPO3 CMS. dkd Internet Service GmbH is developing the extension. Community contributions are welcome. See CONTRIBUTING.md for details.
GNU General Public License v3.0
137 stars 252 forks source link

[BUG] indexing news content_elements fails / local tsfe not passed down #3358

Open akiessling opened 2 years ago

akiessling commented 2 years ago

Describe the bug I'm trying to index news records that have content elements attached to it. Since i need the "fully rendered" content and not just single fields, i wanted to use RECORDS for the content field. But this fails since RECORDS does not pass down the TSFE when it calls itself recursive and $GLOBALS['TSFE'] is empty --> nothing gets rendered.

Since this was already tackled in https://github.com/TYPO3-Solr/ext-solr/issues/3244 / https://github.com/TYPO3-Solr/ext-solr/issues/3239 and https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073 i'm not sure if i am missing something.

It seems to work with patching the RecordsContentObject like this so it passes down the TSFE to the new ContentObjectRenderer

https://github.com/TYPO3/typo3/blob/6962acffc9b7169f84838f77bc47ac312663e510/typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php#L91

if ($itemArrayCount > 0) {
    $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class, $this->getTypoScriptFrontendController());
    $cObj->setParent($this->cObj->data, $this->cObj->currentRecord);

Are there any known side effects to this? I'll add a core bugreport if you don't have any objections

To Reproduce Steps to reproduce the behavior:

  1. Add a news indexer with content set to this

    content = SOLR_CONTENT
    content {
    cObject = COA
    cObject {
        10 = TEXT
        10 {
            field = bodytext
            noTrimWrap = || |
        }
    
        20 = CONTENT
        20 {
            table = tt_content
            select {
                pidInList.field = pid
                orderBy = sorting
                languageField = sys_language_uid
                includeRecordsWithoutDefaultTranslation = 1
                where = {#tt_content.tx_news_related_news} = ###NEWS_UID###
                markers {
                    NEWS_UID.field = uid
                }
            }
        }
    }
    }
  2. index the news record
  3. check the indexed solr document if the content field actually contains the content from the attached content elements

Expected behavior The content of the related content elements should get indexed

Used versions (please complete the following information):

dkd-kaehm commented 2 years ago

@akiessling Thanks for reporting. The suggested code in core should work. Please link the core issue and change-set here.

akiessling commented 2 years ago

https://forge.typo3.org/issues/98622 https://review.typo3.org/c/Packages/TYPO3.CMS/+/76121

ContentContentObject also needs the same patch, otherwise running the indexer from the scheduler complained about a missing tmpl from the TSFE