I'm getting a fatal error on line 34 in pages.inc. This causes a fatal error on $view->preview because the view is never loaded.

Here's the value of $_GET:

Array
(
    [q] => ajax/ajax_facets/refresh
    [f] => Array
        (
            [0] => field_course_categories:24
            [1] => field_course_categories:114
        )

    [searchPath] => home
    [index_id] => courses_index
    [facet_field] => field_course_categories
)

None of the view info is there.

I'm using panels with the view added as a view pane.

Thanks.

Comments

awolfey created an issue. See original summary.

eugene.ilyin’s picture

Status: Active » Needs work

Hello

I'll try to check it in next few days.

eugene.ilyin’s picture

Status: Needs work » Needs review

I can't understand the real reason of the problem, all works fine for me.

But something went wrong here:

ajax_facets.js

 // View by ajax.
            if (Drupal.views && Drupal.views.instances['views_dom_id:' + viewDomId]) {
              $.extend(Drupal.ajax_facets.queryState, Drupal.views.instances['views_dom_id:' + viewDomId].settings);
            }
            // View without ajax.
            else {
              Drupal.ajax_facets.queryState['view_name'] = settings.facetapi.view_name;
              Drupal.ajax_facets.queryState['view_display_id'] = settings.facetapi.display_name;
              // Respect view arguments.
              var name_display = settings.facetapi.view_name + ':' + settings.facetapi.display_name;
              if (settings.facetapi.view_args[name_display]) {
                Drupal.ajax_facets.queryState['view_args'] = settings.facetapi.view_args[name_display];
              }
              // Respect view path.
              if (settings.facetapi.view_path[name_display]) {
                Drupal.ajax_facets.queryState['view_path'] = settings.facetapi.view_path[name_display];
              }
            }

or here:

ajax_facets.module

  if (!empty($views)) {
      // Get display from current search.
      if (empty($view_name) || empty($display_name)) {
        $keys = array_keys($views);
        foreach ($keys as $key) {
          if (substr_count($key, 'search_api_views')) {
            list(, $view_name, $display_name) = explode(':', $key);
          }
        }
      }
    }

I can only propose you to debug the code in these points.

eugene.ilyin’s picture

Status: Needs review » Postponed (maintainer needs more info)
awolfey’s picture

Thanks for looking. I'll investigate further.

awolfey’s picture

I should have mentioned I'm using Search API and Solr. In `ajax_facets_add_ajax_js()` `$views` contains a `SearchApiQuery' array but no view.

shaxa’s picture

Same issue with me. Sometimes its not getting info at all.

And the other issue which relates to this is. If i have more then one view on page it sends the request to the wrong view which is not even a solr view.

szeidler’s picture

I was able to narrow down the problem in my test environment. I get the same error everytime, when I activate the views pager.
When I activate the pager

dpm($views);

returns two different views. In my case:

  • search_api_views:publication_index:panel_pane_1
  • search_api_views:publication_index:panel_pane_1-1

The first one includes the paginated limited result list.
The second one the count(*) of the whole view results without pagination.

The appended '-1' for the second view results to the error, because that element is not part of the dom. When I trick the function and remove `-1` from the $display_name string in ajax_facets_add_ajax_js() facet_ajax works as designated.

I will think a little bit around it and see, if there is a non-hacky way of solving the issue.

Can you confirm, that the broken functionality is also tied to the pagination feature, in your test cases?

eugene.ilyin’s picture

Status: Postponed (maintainer needs more info) » Needs work

Thank you for investigations. I'll check it at Saturday.

szeidler’s picture

When calling search_api_current_search(), the function adds an serial number, to prevent search ID collisions. The result is, that we have a $display_name in our ajax_facets module, that is not part of the DOM. I made a naive check now, that excludes all serial number view displays, because they will always lead to that wrong behavior. It's a pragmatic solution, but I'm not sure, if it is the cleanest one and doesn't create any side-effects. But it describes quite good the source of the problem.

awolfey’s picture

szeidler: I don't even get any view names returned from search_api_current_search(). For me in only returns 2 SearchApiQuery objects. Are you using search api solr with the view and facet blocks both placed in a panel?

szeidler’s picture

awolfey: In my test case I used search_api_db with multiple facets placed above a views content pane in a panel. Didn't tested ajax_facets with search_api_solr till now.

eugene.ilyin’s picture

Status: Needs work » Postponed (maintainer needs more info)

@szeidler mhh, I have tried to use current search block and pager, but problem is not reproduced. Could you describe all conditions to let me reproduce this problem easily? Thanks in advance.

szeidler’s picture

Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new76.55 KB

Unfortunately I'm not able to reproduce my pager related issue after 2 months now. But I found a more easy use-case in which the same error occurs and can be solved by the patch in #10.

The problem occurs, when you use the same view display at least two times on the same page.

Active following modules:

  • search_api
  • search_api_db or search_api_solr
  • panels
  • (ctools) page_manager
  • views
  • facetapi
  • search_api_views
  • search_api_facetapi
  • ajax_facets

Steps to reproduce:

  • Index your nodes with search_api
  • Create a ajax facet in your node index (I used the node title for testing purpose)
  • Create view, that list the rendered teaser view mode for your node index
  • Create a new custom page with page_manager
  • Add your facet to that panel page
  • Add your view display two times to that panel page
  • Add a dpm($views); to the code part from #3
  • You will see two views - the second one with a serial number

Both IDs will be used in the further processing and the auto-generated second one with the serial number is no actual id in the HTML DOM. For that reason the command will fail and return the error described in that issue.

If you have problem to reproduce it, I can also prepare a dump from a fresh D7 installation, to visualize you the problem.

sin’s picture

Thank you for a nice module!

I have the same issue with multiple views on the page. Display id is "attachmentX_Y" in Drupal.settings but "page" in actual DOM.

The temporary workaround is to override Drupal.settings.facetapi.display_name for example in hook_preprocess_html.

The solution may be the separate option to select view and display manually in module settings.

eugene.ilyin’s picture

Status: Active » Needs review

Hi all.

Seems I have resolved it in issue #2464823: Fix for use with multiple Search API View Displays.
Any testing are appreciated.

eugene.ilyin’s picture

Status: Needs review » Fixed

I hope that it will work. If somebody will have problem with it, please open new issue, because this issue is already big.
But would be nice to relate the new issue with this issue.

Status: Fixed » Closed (fixed)

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