ext-solr icon indicating copy to clipboard operation
ext-solr copied to clipboard

[BUG] tstamp field of record is required but should not

Open georgringer opened this issue 11 months ago • 4 comments

The tstamp and starttime fields of a record are optional and must be checked properly, otherwise exception like

     An error occurred while initializing the index queue: PHP Warning: Undefined array key "ctrl" in /var/www/html/app/site/vendor/apache-solr-for-typo3/solr/Classes/IndexQueue/Initializer/AbstractInitializer.php line 177

happens

see https://github.com/TYPO3-Solr/ext-solr/blob/fb9043c8a5a96ccc35a7171cab26173c270384e2/Classes/IndexQueue/Initializer/AbstractInitializer.php#L177-L188

2 changes required:

  • instead of if (!empty($GLOBALS['TCA'][$this->type]['ctrl']['enablecolumns']['starttime'])) { better use if ($GLOBALS['TCA'][$this->type]['ctrl']['enablecolumns']['starttime'] ?? '') {
  • $GLOBALS['TCA'][$this->type]['ctrl']['tstamp'] must be checked as well but I can't provide a PR as I don't know enough of internals

georgringer avatar Sep 21 '23 08:09 georgringer

@georgringer Thanks for reporting that issue. Which versions are affected?

dkd-kaehm avatar Sep 21 '23 09:09 dkd-kaehm

all versions, tstamp is optional since ever, code is in main

georgringer avatar Sep 21 '23 10:09 georgringer

I agree, we should check and handle such configurations correctly.

Currently EXT:solr requires a timestamp field, the timestamp is used to determine if a record has changed and has to be reindexed. As the QueueItemRepository is looking for items having a timestamp greater than the indexed time, which is 0 initially, I would assume that currently tables without a timestamp won't be indexed at all.

I think we could extend the initializer to check the table setup and print a proper message otherwise.

dkd-friedrich avatar Sep 25 '23 10:09 dkd-friedrich

it is also safe to enforce the tstamp and skip the table if not configured

georgringer avatar Sep 25 '23 11:09 georgringer