Setup

  • Solr version: 9.10.1
  • Drupal Core version: 10.6.13
  • Search API version: 1.41
  • Search API Solr version: 4.3.11
  • Configured Solr Connector: Standard

Issue

During batch indexing, ~30000 node to index, batch size 10, after few steps I got a fatal error: "Call to undefined method Drupal\search_api\Entity\Index::isIndexingEmptyIndex()"

The trace:

#0 .../www/modules/contrib/search_api/src/Entity/Server.php(462): Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend->deleteItems(Object(Drupal\search_api\Entity\Index), Array)
#1 .../www/modules/contrib/search_api/src/Entity/Index.php(1199): Drupal\search_api\Entity\Server->deleteItems(Object(Drupal\search_api\Entity\Index), Array)
#2 .../www/modules/contrib/search_api/src/Entity/Index.php(1133): Drupal\search_api\Entity\Index->indexSpecificItems(Array)
#3 .../www/modules/contrib/search_api/src/Utility/IndexingBatchHelper.php(149): Drupal\search_api\Entity\Index->indexItems(10)
#4 .../www/core/includes/batch.inc(296): Drupal\search_api\Utility\IndexingBatchHelper->process(Object(Drupal\search_api\Entity\Index), 10, -1, -1, Array)
#5 .../www/core/includes/batch.inc(138): _batch_process()
#6 .../www/core/includes/batch.inc(95): _batch_do()
#7 .../www/core/modules/system/src/Controller/BatchController.php(52): _batch_page(Object(Symfony\Component\HttpFoundation\Request))
#8 [internal function]: Drupal\system\Controller\BatchController->batchPage(Object(Symfony\Component\HttpFoundation\Request))
#9 .../www/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#10 .../www/core/lib/Drupal/Core/Render/Renderer.php(637): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#11 .../www/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#12 .../www/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#13 .../vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#14 .../vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#15 .../www/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 .../www/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 .../www/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 .../vendor/asm89/stack-cors/src/Cors.php(53): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 .../www/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Asm89\Stack\Cors->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 .../www/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 .../www/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 .../www/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 .../www/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 .../www/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#25 {main}

When i downgrade SearchAPISolr to the previous version to 4.3.10 this problem does not appears.

This error happens with redis cache backend, DB Cache backend, and disabled cache (dev mode) if i'm using the version 4.3.11. I cannot determine after how many batch steps this happens.

There is an other issue #3481375: Call to undefined method Drupal\search_api\Entity\Index::isIndexingEmptyIndex() which reports the same problem, but there was no resolution there.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tikaszvince created an issue. See original summary.

reloxo95’s picture

Priority: Normal » Critical
reloxo95’s picture

I know this is not a fix but you can re-index all your data:

On /src/Plugin/search_api/backend/SearchApiSolrBackend.php, line 1528:

// if ($index->isIndexingEmptyIndex()) {
    //   return;
    // }

This is not a fix, Is just quick "by-pass" to avoid this error.

mkalkbrenner’s picture

Category: Bug report » Support request
Priority: Critical » Normal

Like in the other issue, it must be caused by your environment or the way how you deploy code. The method was already part of 4.3.10.

This is the code that "adds" the method:

  /**
   * Implements hook_entity_type_alter().
   */
  #[Hook('entity_type_alter')]
  public function entityTypeAlter(array &$entity_types): void {
    /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
    $entity_types['search_api_index']->setClass(Index::class);
    $entity_types['search_api_index']->setFormClass('solr_multisite_clone', IndexSolrMultisiteCloneForm::class);
    $entity_types['search_api_index']->setFormClass('solr_multisite_update', IndexSolrMultisiteUpdateForm::class);
    $entity_types['search_api_index']->setFormClass('add_solr_document_fields', IndexAddSolrDocumentFieldsForm::class);
    $entity_types['search_api_index']->setLinkTemplate('add-solr-document-fields', '/admin/config/search/search-api/index/{search_api_index}/fields/add/solr-document');
  }

rex.barkdoll’s picture

I wanted to report that we're seeing similar issues.

Also, reloxo95's suggestion for commenting out that if statement around line 1528 did allow me to bypass the issue and reindex my site.

$ drush search-api:index
 [success] Found 13740 items to index for WEBSITE-index. Indexing all items.
 [success] Indexing a maximum number of 13740 items (50 items per batch run) for the index 'WEBSITE-index'.
 [warning] The index Solr Log is read-only.
>  [error]  Error: Call to undefined method Drupal\search_api\Entity\Index::isIndexingEmptyIndex() in Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend->deleteItems() (line 1528 of /var/www/html/website.com/web/modules/contrib/search_api_solr/src/Plugin/search_api/backend/SearchApiSolrBackend.php) #0 /var/www/html/website.com/web/modules/contrib/search_api/src/Entity/Server.php(462): Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend->deleteItems()
> #1 /var/www/html/website.com/web/modules/contrib/search_api/src/Entity/Index.php(1199): Drupal\search_api\Entity\Server->deleteItems()
> #2 /var/www/html/website.com/web/modules/contrib/search_api/src/Entity/Index.php(1133): Drupal\search_api\Entity\Index->indexSpecificItems()
> #3 /var/www/html/website.com/web/modules/contrib/search_api/src/Utility/IndexingBatchHelper.php(149): Drupal\search_api\Entity\Index->indexItems()
> #4 /var/www/html/website.com/vendor/drush/drush/includes/batch.inc(259): Drupal\search_api\Utility\IndexingBatchHelper->process()
> #5 /var/www/html/website.com/vendor/drush/drush/includes/batch.inc(205): _drush_batch_worker()
> #6 /var/www/html/website.com/vendor/drush/drush/includes/batch.inc(76): _drush_batch_command()
> #7 /var/www/html/website.com/vendor/drush/drush/src/Commands/core/BatchCommands.php(25): drush_batch_command()
> #8 [internal function]: Drush\Commands\core\BatchCommands->process()
> #9 /var/www/html/website.com/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array()
> #10 /var/www/html/website.com/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
> #11 /var/www/html/website.com/vendor/consolidation/annotated-command/src/CommandProcessor.php(175): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
> #12 /var/www/html/website.com/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(389): Consolidation\AnnotatedCommand\CommandProcessor->process()
> #13 /var/www/html/website.com/vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
> #14 /var/www/html/website.com/vendor/symfony/console/Application.php(1121): Symfony\Component\Console\Command\Command->run()
> #15 /var/www/html/website.com/vendor/drush/drush/src/Application.php(201): Symfony\Component\Console\Application->doRunCommand()
> #16 /var/www/html/website.com/vendor/symfony/console/Application.php(324): Drush\Application->doRunCommand()
> #17 /var/www/html/website.com/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun()
> #18 /var/www/html/website.com/vendor/drush/drush/src/Runtime/Runtime.php(113): Symfony\Component\Console\Application->run()
> #19 /var/www/html/website.com/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
> #20 /var/www/html/website.com/vendor/drush/drush/drush.php(140): Drush\Runtime\Runtime->run()
> #21 /var/www/html/website.com/vendor/bin/drush.php(120): include('...')
> #22 {main}. 
> Error: Call to undefined method Drupal\search_api\Entity\Index::isIndexingEmptyIndex() in /var/www/html/website.com/web/modules/contrib/search_api_solr/src/Plugin/search_api/backend/SearchApiSolrBackend.php on line 1528 #0 /var/www/html/website.com/web/modules/contrib/search_api/src/Entity/Server.php(462): Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend->deleteItems()
> #1 /var/www/html/website.com/web/modules/contrib/search_api/src/Entity/Index.php(1199): Drupal\search_api\Entity\Server->deleteItems()
> #2 /var/www/html/website.com/web/modules/contrib/search_api/src/Entity/Index.php(1133): Drupal\search_api\Entity\Index->indexSpecificItems()
> #3 /var/www/html/website.com/web/modules/contrib/search_api/src/Utility/IndexingBatchHelper.php(149): Drupal\search_api\Entity\Index->indexItems()
> #4 /var/www/html/website.com/vendor/drush/drush/includes/batch.inc(259): Drupal\search_api\Utility\IndexingBatchHelper->process()
> #5 /var/www/html/website.com/vendor/drush/drush/includes/batch.inc(205): _drush_batch_worker()
> #6 /var/www/html/website.com/vendor/drush/drush/includes/batch.inc(76): _drush_batch_command()
> #7 /var/www/html/website.com/vendor/drush/drush/src/Commands/core/BatchCommands.php(25): drush_batch_command()
> #8 [internal function]: Drush\Commands\core\BatchCommands->process()
> #9 /var/www/html/website.com/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array()
> #10 /var/www/html/website.com/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
> #11 /var/www/html/website.com/vendor/consolidation/annotated-command/src/CommandProcessor.php(175): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
> #12 /var/www/html/website.com/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(389): Consolidation\AnnotatedCommand\CommandProcessor->process()
> #13 /var/www/html/website.com/vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
> #14 /var/www/html/website.com/vendor/symfony/console/Application.php(1121): Symfony\Component\Console\Command\Command->run()
> #15 /var/www/html/website.com/vendor/drush/drush/src/Application.php(201): Symfony\Component\Console\Application->doRunCommand()
> #16 /var/www/html/website.com/vendor/symfony/console/Application.php(324): Drush\Application->doRunCommand()
> #17 /var/www/html/website.com/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun()
> #18 /var/www/html/website.com/vendor/drush/drush/src/Runtime/Runtime.php(113): Symfony\Component\Console\Application->run()
> #19 /var/www/html/website.com/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
> #20 /var/www/html/website.com/vendor/drush/drush/drush.php(140): Drush\Runtime\Runtime->run()
> #21 /var/www/html/website.com/vendor/bin/drush.php(120): include('...')
> #22 {main}
>  [warning] Drush command terminated abnormally.

In ProcessBase.php line 171:
                                                                                                                                                           
  Unable to decode output into JSON: Syntax error                                                                                                          
                                                                                                                                                           
  Error: Call to undefined method Drupal\search_api\Entity\Index::isIndexingEmptyIndex() in Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSol  
  rBackend->deleteItems() (line 1528 of /var/www/html/website.com/web/modules/contrib/search_api_solr/src/Plugin/search_api/backend/SearchApiSolrBackend.ph  
  p).                                                                                                                                                      
        

marco.pagliarulo’s picture

Title: Call to undefined method Drupal\search_api\Entity\Index::isIndexingEmptyIndex() » Search API Solr 4.3.11 incompatible with D10 - Call to undefined method Drupal\search_api\Entity\Index::isIndexingEmptyIndex()
Category: Support request » Bug report
Priority: Normal » Critical

Changed the title to reflect better the actual issue.
Version 4.3.11 moved the hooks to the class hooks, which are supported since Drupal 11.1
Drupal 10.1+ and Drupal 11.1 require the procedural hooks in place with the attribute LegacyHook that is missing in your implementation.
As result every hooks is not executed on D10 and D11.0

marco.pagliarulo’s picture

Status: Active » Needs review

MR created, please review ASAP and create a urgent release.

klemendev’s picture

I can confirm this is happening and is breaking the website. We need to rollback for now

caspervoogt’s picture

I just ran into this and rolled back to 4.3.10 as well, which solved it.

mkalkbrenner’s picture

 ------ ---------------------------------------------------------------------- 
  Line   search_api_solr.module                                                
 ------ ---------------------------------------------------------------------- 
  154    Function search_api_solr_entity_operation() implements                
         hook_entity_operation but is missing the CacheableMetadata parameter  
         added in Drupal 11.3. Update the signature to:                        
         search_api_solr_entity_operation(\Drupal\Core\Entity\EntityInterface  
         $entity, \Drupal\Core\Cache\CacheableMetadata $cacheability).         
         🪪  drupal.proceduralHookEntityOperationMissingCacheabilityParameter  
         💡  See https://www.drupal.org/node/3533080                           
 ------ ---------------------------------------------------------------------- 

All these backward compatibility handling is crazy. Since this project doesn't have sponsors anymore, I can't take care of all of that anymore.
I will create an intermediate 4.3.12 release and then drop Drupal 10 support.

mkalkbrenner’s picture

Status: Needs review » Fixed

https://www.drupal.org/project/search_api_solr/releases/4.3.12

Thanks for your help!

4.3.12 will be the last release that supports Drupal versions before 11.3.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

klemendev’s picture

Thank you for fixing this!

marco.pagliarulo’s picture

Thanks for the quick merge and release

jennypanighetti’s picture

I'm still getting this error, even after upgrading to 4.3.12. I may have to roll back too.

Apparently I just needed to run drush cr multiple times... no idea why, but it works okay now....

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.