Problem/Motivation

Saw the error above when using version 2.0.1 on a fresh install. Here's the full test of the error:

Notice: Undefined index: target_id in Drupal\search_overrides\Element\AddOverride::processInput() (line 147 of /Users/martin/Sites/search/web/modules/contrib/search_overrides/src/Element/AddOverride.php)
#0 /Users/martin/Sites/search/web/core/includes/bootstrap.inc(305): _drupal_error_handler_real(8, 'Undefined index...', '/Users/martin/S...', 147)
#1 /Users/martin/Sites/search/web/modules/contrib/search_overrides/src/Element/AddOverride.php(147): _drupal_error_handler(8, 'Undefined index...', '/Users/martin/S...', 147, Array)
#2 [internal function]: Drupal\search_overrides\Element\AddOverride::processInput(Array, Object(Drupal\Core\Form\FormState), Object(Symfony\Component\HttpFoundation\Request))
#3 /Users/martin/Sites/search/web/core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php(69): call_user_func_array(Array, Array)
#4 /Users/martin/Sites/search/web/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php(109): Drupal\Core\Form\FormAjaxResponseBuilder->buildResponse(Object(Symfony\Component\HttpFoundation\Request), Array, Object(Drupal\Core\Form\FormState), Array)
#5 [internal function]: Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber->onException(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#6 /Users/martin/Sites/search/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#7 /Users/martin/Sites/search/vendor/symfony/http-kernel/HttpKernel.php(219): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...')
#8 /Users/martin/Sites/search/vendor/symfony/http-kernel/HttpKernel.php(91): Symfony\Component\HttpKernel\HttpKernel->handleThrowable(Object(Drupal\Core\Form\FormAjaxException), Object(Symfony\Component\HttpFoundation\Request), 1)
#9 /Users/martin/Sites/search/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#10 /Users/martin/Sites/search/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#11 /Users/martin/Sites/search/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#12 /Users/martin/Sites/search/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /Users/martin/Sites/search/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /Users/martin/Sites/search/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /Users/martin/Sites/search/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /Users/martin/Sites/search/web/core/lib/Drupal/Core/DrupalKernel.php(706): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /Users/martin/Sites/search/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#18 {main}

Proposed resolution

At the cited line, check that $value['target_id'] is not empty before doing the comparison.

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

mandclu created an issue. See original summary.

  • ff503ab committed on 2.0.x
    Issue #3207337 by mandclu: Notice: Undefined index: target_id in Drupal\...
mandclu’s picture

Status: Active » Fixed

Went ahead and merged this in, since the fix is pretty innocuous. Will issue a new release since this seemed to be breaking some AJAX functionality under certain circumstances.

Status: Fixed » Closed (fixed)

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