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 249 forks source link

Too strict return values during indexing #3758

Closed RazielleS closed 1 year ago

RazielleS commented 1 year ago

Describe the bug We have an integer field to be indexed by the page indexer. Something like plugin.tx_solr.index.queue.pages.fields.order_intS = tx_extension_some_field. The field is of course of type int in the database.

The method \ApacheSolrForTypo3\Solr\IndexQueue\FrontendHelper\PageFieldMappingIndexer::resolveFieldValue only allows arrays and strings as return values. But when it processes our field, it has type int. Thus throwing an exception. Can the return value of this method be changed accordingly?

To Reproduce Steps to reproduce the behavior:

  1. Index an integer field with the PageFieldMappingIndexer

Expected behavior No exception because of wrong return type.

Used versions (please complete the following information):

dkd-kaehm commented 1 year ago

Current implementation does not care about right return type if value is serialized or is fetched directly from record:

https://github.com/TYPO3-Solr/ext-solr/blob/61076e3ed99ba2c4b9f17d44c2e50f278218780d/Classes/IndexQueue/FrontendHelper/PageFieldMappingIndexer.php#L120-L155

IMHO the return value can be set to mixed or a little bit stricter list of possible value types.

solarium uses the values as follows:

  • If you supply NULL as the value the field will be removed
  • If you supply a numerically indexed array of values a multivalue field will be created.
  • In all cases any existing (multi)value or child document(s) will be overwritten.
RazielleS commented 1 year ago

I have found some more occurrences of too strict return types, so I changed the title of this issue to address them all. I'll make a PR to change these.