When creating a View based on Apache SOLR Views (http://drupal.org/project/apachesolr_views), getting the list of operations for the Views admin UI, the list of operations isn't built.

In _views_bulk_operations_object_info_for_view(), the check that $object_info['base_table'] == $view->base_table fails, resulting in no operations returned due to $view->base_table not existing.

Expanding the check's logic to $object_info['base_table'] == $view->base_table || ($view->base_table == 'apachesolr') will allow views created using the Apache SOLR Views Integration to get the list of operations.

My initial testing, indicates that once this is in place, Views 3, VBO and Apache SOLR Views play nice together.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mlsamuelson’s picture

Status: Active » Needs review
FileSize
932 bytes

Patch attached.

Scott Reynolds’s picture

As the solr views maintainer this strikes me as naive. Will test it though.

infojunkie’s picture

Category: task » feature

Waiting for test results. If anyone could explain why Apache SOLR Views changes the $view->base_table attribute, it would help clarify the logic needed.

mlsamuelson’s picture

@Scott Reynolds Definitely is naive. :) Once I found the hangup in VBO, I tried this (the patch) and from the testing I've done so far - at least on standard node results, it's worked without error for me. Doesn't mean we shouldn't look further upstream into Apache SOLR Views... but at least this starts the conversation.

Scott Reynolds’s picture

If anyone could explain why Apache SOLR Views changes the $view->base_table attribute, it would help clarify the logic needed.

So the base_table for a View defines what fields, arguments, filters, relationships, header, footer, and empty text handlers can be used. Since Apache Solr is a separate separate Database, the base table can't be 'node' even though we would like to use the 'node' actions etc on the result set. Still haven't come up with an alternative approach.

infojunkie’s picture

@Scott Reynolds, thanks for the explanation. I looked at the module's code a few days ago and that's what I thought.

Of course, I won't be able to commit the patch sent here. What I suggest instead is to let the module implement the hook hook_views_bulk_operations_object_info that allows extending VBO with new view types. In this case, here are the parameters I expect to work:

<?php
function apachesolr_views_views_bulk_operations_object_info() {
  return array(
    'node' => array(
      'type' => 'node',
      'base_table' => 'apachesolr',
      'load' => '_views_bulk_operations_node_load', // version of node_load that forces reloading
      'oid' => 'nid',
      'title' => 'title',
      'access' => 'node_access',
      'hook' => 'nodeapi',
      'normalize' => '_views_bulk_operations_normalize_node_context', // allows user actions etc to work on nodes
    ),
  );
}
?>

This hook tells VBO that when it encounters a view of type 'apachesolr', what it's dealing with is really node entities.

mlsamuelson’s picture

That should probably be "apachesolr" as the top level key in the array, right? Otherwise, you end up doubling the entries in the node array.

function apachesolr_views_views_bulk_operations_object_info() {
  return array(
    'apachesolr' => array(
      'type' => 'node',
      'base_table' => 'apachesolr',
      'load' => '_views_bulk_operations_node_load', // version of node_load that forces reloading
      'oid' => 'nid',
      'title' => 'title',
      'access' => 'node_access',
      'hook' => 'nodeapi',
      'normalize' => '_views_bulk_operations_normalize_node_context', // allows user actions etc to work on nodes
    ),
  );
}
mlsamuelson’s picture

Project: Views Bulk Operations (VBO) » Apache Solr Views
Version: 6.x-3.x-dev » 6.x-1.x-dev
Component: Core » Code
FileSize
1.09 KB

Changing project to Apache SOLR Views.

New patch attached that incorporates the hook from #7 into apachesolr_views.module.

VBO and Apache SOLR Views are working together.

mlsamuelson’s picture

Title: Allow for Apache SOLR Views Integration compatibility » Allow for Apache SOLR Views to integrate with Views Bulk Operations
FileSize
1.09 KB

Something went wrong in the save of comment #8. The path for the patch isn't working correctly. Posting it again.

digi24’s picture

Status: Needs review » Needs work

The latest commit in cvs http://drupal.org/cvs?commit=369072 breaks this patch. The base table part needs to be adjusted. As I am only using apachesolr_views in node context, my quick fix was to hardcode the apachesolr_node base table, but obvoiusly this is not a clean solution.

dpalmer’s picture

Subscribing.

lewie6’s picture

any ideas on this?

tbenice’s picture

Tried adding #7 to apachesolr_views as:


function apachesolr_views_views_bulk_operations_object_info() {
  return array(
    'apachesolr_search_node' => array(
      'type' => 'node',
      'base_table' => 'apachesolr_search_node',
      'load' => '_views_bulk_operations_node_load', // version of node_load that forces reloading
      'oid' => 'nid',
      'title' => 'title',
      'access' => 'node_access',
      'hook' => 'nodeapi',
      'normalize' => '_views_bulk_operations_normalize_node_context', // allows user actions etc to work on nodes
    ),
  );
}

but there still is no list of actions in the views ui. going to try the workaround in #1 for now. Boy this would be nice!

EDIT: changed base_table to 'apachesolr_node' and it worked. For some reason I thought it was the actual db table name needed but it's the one used by views.

itarato’s picture

Hi there,
I've created a connector that does the basic integration. Feedback and patches are more than welcomed: http://drupal.org/project/apachesolr_vbo