Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new Field of type int fails #248

Open
lstitx opened this issue Oct 15, 2024 · 2 comments
Open

Adding new Field of type int fails #248

lstitx opened this issue Oct 15, 2024 · 2 comments

Comments

@lstitx
Copy link

lstitx commented Oct 15, 2024

I extended the search with some additional fields and so far it has worked great. They're all of type text / varchar. I now want to add a new field of type int and it's not working anymore:
ke_search: 5.5.0
typo3v11.5

ext_tables:

CREATE TABLE tx_kesearch_index (
	breadcrumbs text DEFAULT '' NOT NULL,
	paperturn_link varchar(255) DEFAULT '',
	filesize int(11) unsigned DEFAULT '0',
	file_type varchar(255) DEFAULT ''
);

registerAdditoonalFieldsHook:

public function registerAdditionalFields(&$additionalFields)
    {
        $additionalFields[] = 'breadcrumbs';
        $additionalFields[] = 'paperturn_link';
        $additionalFields[] = 'file_type';
        $additionalFields[] = 'filesize';
    }

modifyFileIndexxEntryHook:

$additionalFields['file_type'] = strtoupper($file->getProperty('extension')) ?? '';
        $additionalFields['filesize'] = $file->getProperty('size') ?? 0;

This is the error I get when running the pages Indexer:

Incorrect integer value: '' for column 'filesize' at row 1 
Tue, 15 Oct 2024 12:31:03 +0200 [ERROR] request="a45b0d63657a0" component="Tpwd.KeSearch.Indexer.IndexerRunner": An exception occurred while executing 'EXECUTE insertStmt USING @pid, @title, @type, @targetpid, @content, @tags, @params, @abstract, @language, @starttime, @endtime, @fe_group, @tstamp, @crdate, @breadcrumbs, @paperturn_link, @file_type, @filesize, @sortdate, @orig_uid, @orig_pid, @directory, @hash, @hidden_content;':
@christianbltr
Copy link
Member

Yes indeed, it's currently not possible to use int fields in additional fields.

The reason is that additional fields get quoted:

$queryForSet .= ', @' . $value . ' = ' . $queryBuilder->quote((string)$fieldValues[$value]);

Is it possible for you to use a string field?

@lstitx
Copy link
Author

lstitx commented Oct 28, 2024

Yes, we're currently using a string. May I ask why you quote the additonal fields?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants