When using the module on views integration it throws a notice:

Notice: Undefined offset: 0 in search_api_autocomplete_form_search_api_page_block_form_alter() (line 155 of modules/contrib/search_api_autocomplete/search_api_autocomplete.module)...

Comments

ceaucari created an issue. See original summary.

ceaucari’s picture

StatusFileSize
new1.55 KB

this patch fixes it:

ceaucari’s picture

Status: Active » Needs review
drunken monkey’s picture

Title: Views Integration Broken » Fix notice in form alter hook
Component: General code » Framework
Priority: Major » Normal
StatusFileSize
new933 bytes
  1. This is obviously not a problem with Views, but with Search API Pages (given the hook implementation you're changing).
  2. I don't see any way this argument would not be set, unless you have custom code building the form incorrectly. Looking through the Pages module, the form is only built twice, and both with the correct arguments. The form itself (cf. \Drupal\search_api_page\Form\SearchApiPageBlockForm::buildForm()) also expects the argument and doesn't check for its existence.
  3. However, even considering all that, I guess there's no reason to not code a bit more defensively there. However, it should be done properly, not with a large if block. See the attached patch.
  4. Also, you should probably still find out where that call is coming from. Looks like a potential bug on your site.
ceaucari’s picture

Thank you Thomas for your comments, on the patch I indeed modified a hook related to Search API Pages, but I'm not using Search API Pages on the site, the results are being displayed using a view showing results from a Solr Index so that's probably why the argument is not being set, if Search API Pages is not being used search_api_autocomplete_form_search_api_page_block_form_alter() shouldn't be getting in the way.

I also disabled all our custom code to make sure is not a bug introduced by us, but the notice keeps showing up.

I can also confirm that your patch on #4 also fixes the problem.

drunken monkey’s picture

That's weird, then. Could you get a backtrace for the error? It would really be interesting to know how that hook gets invoked.

drunken monkey’s picture

Status: Needs review » Fixed

OK, as said, defensive coding can't hurt anyways. Getting more information would have been great, but the patch can go in anyways.
So, committed. Thanks again!

Status: Fixed » Closed (fixed)

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