ext-solr
ext-solr copied to clipboard
[BUG] tstamp field of record is required but should not
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 useif ($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 Thanks for reporting that issue. Which versions are affected?
all versions, tstamp is optional since ever, code is in main
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.
it is also safe to enforce the tstamp and skip the table if not configured