With a "Multi-index search" view when clicking "Query settings: Settings" it gives the following error:

Error: Call to a member function getEntityType() on null in SearchApiViewsQuery->options_form() (line 216 of search_api/contrib/search_api_views/includes/query.inc).

Can be worked-around by doing:

search_api/contrib/search_api_views/includes/query.inc

  public function options_form(&$form, &$form_state) {
    ...
-   if ($this->index->getEntityType()) {
+   if ($this->index && $this->index->getEntityType()) {
      $form['entity_access'] = array(
        '#type' => 'checkbox',
        '#title' => t('Additional access checks on result entities'),
        '#description' => t("Execute an access check for all <snip>"),
        '#default_value' => $this->options['entity_access'],
      );
    }
    ...
  }

Comments

MustangGB created an issue. See original summary.

mustanggb’s picture

Issue summary: View changes

Truncated #description for readability.

drunken monkey’s picture

Status: Active » Postponed (maintainer needs more info)

With "Multi-index search" you mean a search powered by the "Search API multi-index searches" module?
Then why not report it in that module? Seems like it should be fixed there.

mustanggb’s picture

Project: Search API » Search API Multi-Index Searches
Component: Views integration » Code
Status: Postponed (maintainer needs more info) » Active

@drunken monkey:
Yes, that's exactly what I meant. If it's a requirement of search_api that "index" is specified then I agree it should be fixed in search_api_multi. As for why I reported it here, well only because this is my first time using this family of modules so I'm not particularly au fait with their inner working, "Multi-index search" is the only view I've created so far, so I wasn't aware that this wasn't an issue for the other index types, and as I mentioned originally my findings were only a worked-around rather than an explicit fix. I was envisaging that which module should contain the fix would be at your prerogative.

drunken monkey’s picture

Project: Search API Multi-Index Searches » Search API
Component: Code » Views integration
Status: Active » Needs review
StatusFileSize
new629 bytes

Thanks for the information!
After taking a closer look at the multi-index Views query plugin, it seems it's not really possible to fix the problem just there after all (unless with a pretty large, hack-ish workaround). So, I guess adding that small additional check to the Search API Views query plugin is the simpler and better option. Doesn't really hurt in any case, after all.
Sorry for the confusion!

highermath’s picture

The patch effectively fixes this specific issue and does not break anything else in testing. I believe that even if it is not perfect, it is good, and it should be committed.

drunken monkey’s picture

Status: Needs review » Fixed

Good to hear, thanks for the feedback!
Committed.

  • drunken monkey committed df04cb1 on 7.x-1.x
    Issue #2788593 by drunken monkey: Fixed error in Views query settings...

Status: Fixed » Closed (fixed)

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