tpwd / 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
7 stars 31 forks source link

Hook "modifyFieldValuesBeforeStoring" not used by TtContent indexer #209

Closed tntrpsw closed 7 months ago

tntrpsw commented 7 months ago

We ran into the issue, that the "modifyFieldValuesBeforeStoring" hook is only used by the "Page" indexer class, but not by the "TtContent" indexer class. Therefore is seems to be impossible to prevent certain record from being indexed.

Would it be possible to add such function either to the TtContent indexer or provide a differen solution?

As a background of usage:

Under older versions we could use the "modifyContentIndexEntry" hook and just assigned an empty array to the "contentRecord" variable (just by doing "$contentRecord = [];"). That successfully prevented certain records (e.g. based on a specific "colPos" value) from being indexed. But using TYPO3 12 with PHP 8.2, it seems no longer be possible to prevent "tt_content" records to be saved to the database. That is the case because the call of "modifyContentIndexEntry" function tries to use no longer existing array keys (e.g. "uid"), which leads to a PHP warning and an exception as a result (using "ke_search" version 5.2.1):

PHP Warning: Undefined array key "uid" in /var/www/web-dev8/html/typo3conf/ext/ke_search/Classes/Indexer/Types/TtContent.php line 207

christianbltr commented 7 months ago

The hook "modifyFieldValuesBeforeStoring" is used for every record because it is executed just before the database insertion happens.

But for your requirement you could store the content elements to a different folder, or the root page to hide them from the result list like so:

    public function modifyContentIndexEntry(&$title, &$contentRecord, &$tags, $contentUid, &$additionalFields, &$indexerConfig)
    {
        $indexerConfig['storagepid'] = 0;
    }
tntrpsw commented 7 months ago

Hi. Thank you very much. The suggested solution is working "like magic".