Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When attempting to view the "edit" page of an index, the page returns a "Fatal error: Call to undefined method Drupal\search_api\Entity\Index::getServer()".
Call Stack
# Time Memory Function Location
1 0.0055 133208 {main}( ) .../index.php:0
2 0.1174 382848 Drupal\Core\DrupalKernel->handle( ???, ???, ??? ) .../index.php:19
3 0.1332 1066872 Stack\StackedHttpKernel->handle( ???, ???, ??? ) .../DrupalKernel.php:637
4 0.1332 1066928 Drupal\Core\StackMiddleware\NegotiationMiddleware->handle( ???, ???, ??? ) .../StackedHttpKernel.php:23
5 0.1334 1067256 Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle( ???, ???, ??? ) .../NegotiationMiddleware.php:55
6 0.1334 1067488 Drupal\services\StackMiddleware\FormatSetter->handle( ???, ???, ??? ) .../ReverseProxyMiddleware.php:51
7 0.1335 1070980 Drupal\Core\StackMiddleware\KernelPreHandle->handle( ???, ???, ??? ) .../FormatSetter.php:47
8 0.1443 1264120 Drupal\Core\StackMiddleware\Session->handle( ???, ???, ??? ) .../KernelPreHandle.php:53
9 0.1501 1367092 Symfony\Component\HttpKernel\HttpKernel->handle( ???, ???, ??? ) .../Session.php:62
10 0.1501 1367588 Symfony\Component\HttpKernel\HttpKernel->handleRaw( ???, ??? ) .../HttpKernel.php:62
11 0.2695 3294980 call_user_func_array:{/Users/nick.russell/Sites/rscom-cms/docroot/vendor/symfony/http-kernel/HttpKernel.php:139} ( ???, ??? ) .../HttpKernel.php:139
12 0.2695 3295088 Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}( ) .../HttpKernel.php:139
13 0.2695 3295216 Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext( ???, ??? ) .../EarlyRenderingControllerWrapperSubscriber.php:102
14 0.2697 3302680 Drupal\Core\Render\Renderer->executeInRenderContext( ???, ??? ) .../EarlyRenderingControllerWrapperSubscriber.php:129
15 0.2698 3302940 Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}( ) .../Renderer.php:577
16 0.2698 3302968 call_user_func_array:{/Users/nick.russell/Sites/rscom-cms/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:128} ( ???, ??? ) .../EarlyRenderingControllerWrapperSubscriber.php:128
17 0.2698 3303324 Drupal\Core\Controller\FormController->getContentResult( ???, ??? ) .../EarlyRenderingControllerWrapperSubscriber.php:128
18 0.2739 3456448 Drupal\Core\Form\FormBuilder->buildForm( ???, ??? ) .../FormController.php:79
19 0.3063 4255880 Drupal\Core\Form\FormBuilder->prepareForm( ???, ???, ??? ) .../FormBuilder.php:277
20 0.3298 4865568 Drupal\Core\Extension\ModuleHandler->alter( ???, ???, ???, ??? ) .../FormBuilder.php:821
21 0.3304 4868384 search_api_solr_form_search_api_index_edit_form_alter( ???, ???, ??? ) .../ModuleHandler.php:492
Appears that the getServer() method does not exists on $index. The following change fixes it:
Broken:
$backend = $index->getServer() ? $index->getServer()->getBackend() : NULL;
Fixed::
$backend = (method_exists($index, 'getServer')) ? $index->getServer()->getBackend() : NULL;
Comment | File | Size | Author |
---|---|---|---|
#12 | fatal_error_call_to-2659236-12.patch | 986 bytes | borisson_ |
#12 | interdiff.txt | 994 bytes | borisson_ |
Comments
Comment #2
therealwebguy CreditAttribution: therealwebguy commentedComment #3
therealwebguy CreditAttribution: therealwebguy commentedComment #4
borisson_This is not the right fix. The new method is
getServerInstance
. This is already fixed in the latest dev version.Comment #5
AntonnaviHad the same issue, usage getServerInstance fix it. Patch with fix in attachment.
Comment #6
borisson_Comment #7
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedSuccessfully applied patch.
Comment #8
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedComment #9
snufkin CreditAttribution: snufkin at Acquia commentedThe code in dev is
$backend = $index->hasValidServer() ? $index->getServerInstance()->getBackend() : NULL;
, so I'm marking this as fixed. This patch is no longer necessary (although it does fix the problem).Comment #10
borisson_Wasn't fixed in search_api_solr.views.inc
Comment #11
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedIndeed. The try catch statement seems a bit strange now, maybe you can also use hasValidServer() here?
Comment #12
borisson_This cleans that up a little bit.
Comment #13
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedComment #14
BerdirLooks good, committed.