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;

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

therealwebguy created an issue. See original summary.

therealwebguy’s picture

Issue summary: View changes
therealwebguy’s picture

borisson_’s picture

Status: Active » Closed (duplicate)

This is not the right fix. The new method is getServerInstance. This is already fixed in the latest dev version.

Antonnavi’s picture

Version: 8.x-1.0-alpha2 » 8.x-1.x-dev
FileSize
808 bytes

Had the same issue, usage getServerInstance fix it. Patch with fix in attachment.

borisson_’s picture

Status: Closed (duplicate) » Needs review
mpp’s picture

Successfully applied patch.

mpp’s picture

Status: Needs review » Reviewed & tested by the community
snufkin’s picture

Status: Reviewed & tested by the community » Fixed

The 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).

borisson_’s picture

Status: Fixed » Needs review
FileSize
472 bytes

Wasn't fixed in search_api_solr.views.inc

mpp’s picture

Indeed. The try catch statement seems a bit strange now, maybe you can also use hasValidServer() here?

borisson_’s picture

FileSize
994 bytes
986 bytes

This cleans that up a little bit.

mpp’s picture

Status: Needs review » Reviewed & tested by the community
Berdir’s picture

Status: Reviewed & tested by the community » Fixed

Looks good, committed.

Status: Fixed » Closed (fixed)

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