This is introduced when go to search/content?search_api_fulltext=foo

Drupal 8.1.3
php 7.0.8

Enabled modules: search_api, search_api_db,search_api_db_defaults

Comments

edysmp created an issue. See original summary.

drunken monkey’s picture

I can't reproduce this. Can you try again with the latest dev version? (Please re-install the modules after updating.)
And you're not using any other related modules, like Facets?

edysmp’s picture

Hi @drunken monkey thanks for review.

I reinstalled all and continue much of this:

Notice: Undefined index: roles in Drupal\search_api\Plugin\search_api\processor\RenderedItem->addFieldValues() (line 181 of modules/contrib/search_api/src/Plugin/search_api/processor/RenderedItem.php).
Drupal\search_api\Plugin\search_api\processor\RenderedItem->addFieldValues(Object) (Line: 244)
Drupal\search_api\Item\Item->getFields() (Line: 176)
Drupal\search_api\Plugin\search_api\processor\RenderedItem->addFieldValues(Object) (Line: 300)
Drupal\search_api\Processor\ProcessorPluginBase->extractItemValues(Array, Array, 1) (Line: 292)
Drupal\search_api\Plugin\search_api\processor\Highlight->getFulltextFields(Array, Array) (Line: 216)
Drupal\search_api\Plugin\search_api\processor\Highlight->addExcerpts(Array, Array, Array) (Line: 189)
Drupal\search_api\Plugin\search_api\processor\Highlight->postprocessSearchResults(Object) (Line: 720)
Drupal\search_api\Entity\Index->postprocessSearchResults(Object) (Line: 400)
Drupal\search_api\Query\Query->postExecute() (Line: 349)
Drupal\search_api\Query\Query->execute() (Line: 501)
Drupal\search_api\Plugin\views\query\SearchApiQuery->execute(Object) (Line: 1412)
Drupal\views\ViewExecutable->execute(NULL) (Line: 1440)
Drupal\views\ViewExecutable->render() (Line: 170)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1615)
Drupal\views\ViewExecutable->executeDisplay('page_1', Array) (Line: 78)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func(Array, Array) (Line: 381)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 149)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 98)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 77)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 628)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

...

Steps to reproduce:

- Install Drupal 8.1.3
- drush dl search_api --select (selected dev version)
- drush dl search_api_db --select (selected dev version)
- install search_api, search_api_db, search_api_db_defaults
- drupal create:nodes (created 25 nodes , page and articles with Drupal Console)
- review Index status (25/25 indexed)
- go to /search/content
- search something... apply
- show Notice ^ and below the result

Thanks

frankcarey’s picture

I'm getting the same thing on a fresh install with drupal 8.1.5, search_api_solr 8.x-1.0-alpha5 and search_api alpha16.

Putting this through the debugger and I see that on line 181 of modules/contrib/search_api/src/Plugin/search_api/processor/RenderedItem.php

For some reason, the entity:node Item seems to have a "0" keyed empty field..

fields = {array} [12]
 0 = {Drupal\search_api\Item\Field} [20]
 author = {Drupal\search_api\Item\Field} [20]
 changed = {Drupal\search_api\Item\Field} [20]
 created = {Drupal\search_api\Item\Field} [20]
 field_tags = {Drupal\search_api\Item\Field} [20]
 rendered_item = {Drupal\search_api\Item\Field} [20]
 search_api_node_grants = {Drupal\search_api\Item\Field} [20]
 status = {Drupal\search_api\Item\Field} [20]
 sticky = {Drupal\search_api\Item\Field} [20]
 title = {Drupal\search_api\Item\Field} [20]
 type = {Drupal\search_api\Item\Field} [20]
 uid = {Drupal\search_api\Item\Field} [20]

That empty field has no configuration (it's an empty array), hence no $configuration["roles"]

$field = {Drupal\search_api\Item\Field} [20]
 boost = null
 configuration = {array} [0]
 dataDefinition = null
 datasource = null
 datasourceId = null
 dataTypeManager = null
 dependencies = {array} [0]
 description = null
 fieldIdentifier = "rendered_item"
 hidden = null
 index = {Drupal\search_api\Entity\Index} [36]
 indexedLocked = null
 indexId = null
 label = null
 labelPrefix = null
 originalType = null
 propertyPath = "rendered_item"
 type = null
 typeLocked = null
 values = {array} [0]
frankcarey’s picture

I decided to check on the "General" field that was added by search_api_solr_defaults' search index, and figured maybe setting the roles there would fix it, but when I go to save the index field, I get another error..

FastCGI: server "/usr/lib/cgi-bin/php5-fcgi" stderr: PHP message: PHP Fatal error:  Nesting level too deep - recursive dependency? in /var/www/docroot/modules/search_api/src/Entity/Index.php on line 1429, referer: http://192.168.99.100:32771/admin/config/search/search-api/index/default_solr_index/fields/rendered_item/edit

Which I think is from this issue: #2758583: Comparison of recursive processor arrays can lead to fatal error

frankcarey’s picture

I think the new default index provided by search_api_solr_defaults may be to blame? The default view doesn't provide configuration for all fields.. is that ok?

// Omitted - issue is fixed
frankcarey’s picture

Actually, this only seems to happen for the Highlight Processor..

as a workaround locally, I'm just setting the role config if it doesn't exist :

  // Change the current user to our dummy implementation to ensure we are
      // using the configured roles.
      if (!isset($configuration['roles'])) {
        $configuration['roles'] = array('anonymous' => 'anonymous');
      }
      $this->currentUser->setAccount(new UserSession(array('roles' => $configuration['roles'])));
drunken monkey’s picture

Status: Active » Needs review
StatusFileSize
new1.77 KB

- drush dl search_api_db --select (selected dev version)

The search_api_db project has no D8 version, that's now included in the Search API project (again). So this step isn't necessary.

But, anyways, thanks a lot for providing such detailed steps for reproducing the problem! With this, I was finally able to reproduce the problem. I also got a fatal error when doing it, so fixing two issues with one stroke here!
Please test!

@ frankcarey: Please do not post entire index configurations in a comment. That makes it unnecessarily hard to scroll through the whole issue. Use an attachment instead.

edysmp’s picture

Status: Needs review » Reviewed & tested by the community

@drunken monkey Yeah, fixed two issues with one stroke.

Thanks.

  • drunken monkey committed 946c206 on 8.x-1.x
    Issue #2760953 by drunken monkey: Fixed problems with defaults module...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Great to hear, thanks a lot for testing!
Committed.

Status: Fixed » Closed (fixed)

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