Server not defined in extract method

Created on 15 January 2022, almost 3 years ago
Updated 21 February 2023, over 1 year ago

When indexing content, I am getting an occasional error. The error happens on content with PDF files attached. The vast majority of content was indexed, but 5 (out of almost 2000) threw this error. The error kept occurring for these 5 nodes. I had to unpublish them to continue indexing.

The error message is

Error: Call to a member function getBackend() on bool in Drupal\search_api_attachments\Plugin\search_api_attachments\SolrExtractor->extract() (line 81 of /home/web/modules/contrib/search_api_attachments/src/Plugin/search_api_attachments/SolrExtractor.php)

It's happening because $server is empty.

I temporarily fixed the issue by adding:

    $server = reset($server);

    if(!$server) {
        \Drupal::logger('search_api_attachments')->error('no server available for @filepath',
            array('@filepath'=> $filepath));
        throw new \Exception('Solr Server is not specified.');
    }

Once I added that code, the process ended gracefully and it appears that the PDF was added to a queue for extraction. This message appeared in the logs: File added to the queue for text extraction 4183 for node 1629.

Does this make sense as a solution? I'm not clear on why the server wouldn't be available to certain nodes.

πŸ› Bug report
Status

Closed: cannot reproduce

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States Peter Caritas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024