Only admins can use the apache solr user search. Normal users can't search for any profile.

Comments

nick_vh’s picture

This smells like a duplicate? Have you searched the queue? This is a apachesolr_user problem, not apachesolr main module

raulmuroc’s picture

@Nick_vh,

Do not think so because I am not using apachesolr_user but Apachesolr_search_integration itself and the same problem when searching through Profile2 types. :S

Besides, I wrote in that issue and they told me to open this new one.

lechucks’s picture

Version: 7.x-1.x-dev » 7.x-1.1

Same error, with both 7 version dev and stable. An user without "Bypass content access control" cant use Solr search.

I think this an important issue. If you want have sorl search active , everybody must edit and delete all documents and i think its a mistake.

UPDATE!!: I fix it.

You need change in /apachesolr/apachesolr_access/apachesolr_access.module

Find

<?php
function apachesolr_access_apachesolr_query_alter(DrupalSolrQueryInterface $query) {
  global $user;
  try {
    $subquery = apachesolr_access_build_subquery($user);
    $query->addFilterSubQuery($subquery);
  }
  catch (Exception $e) {
    watchdog("apachesolr_access", 'User %name (UID:!uid) cannot search: @message', array('%name' => $user->name, '!uid' => $user->uid, '@message' => $e->getMessage()));
    $query->abort_search = TRUE;
  }
}

?>

to this

<?php
function apachesolr_access_apachesolr_query_alter(DrupalSolrQueryInterface $query) {
  global $user;
  try {
    $query->removeFilterSubQueries();
    $subquery = apachesolr_drupal_subquery();
    $subquery->addFilter('hash', apachesolr_site_hash());
    $query->addFilterSubQuery($subquery);
  }
  catch (Exception $e) {
    watchdog("apachesolr_access", 'User %name (UID:!uid) cannot search: @message', array('%name' => $user->name, '!uid' => $user->uid, '@message' => $e->getMessage()));
    $query->abort_search = TRUE;
  }

?>
raulmuroc’s picture

Status: Active » Closed (duplicate)

@Nick_vh, you had reason. It would be better to have it in the same issue because it seems the solution will be in 'Apachesolr_access' sub-module wich is both used either by 'Users' or 'Profiles'.

@lechucks, your solution loooks promising hence I created a patch and pushed it in: #1665350: Only users with the "Bypass content access control" permission are able to search for users when Apache Solr Access is enabled

P.S: I have just tested the patch and it doesn't seem that solves the problem. Anyway, I would let that community test it better and at least we have a beginning point. Thanks @lechucks for your effort & contribution to Drupa'ls community :-)

Thank you.

lechucks’s picture

Im using dev version with solr 4 and anybody can search with this modification but cant edit or delete post.

I dont have much knowledge in php but apparently solved the problem for me.

Update: Only solved the problem with Apache Solr Search Integration module, not with Apachesolr User module

raulmuroc’s picture

Status: Closed (duplicate) » Needs review
StatusFileSize
new688 bytes

If so then this issue must be considered appart :-D!!!

Patch attached ;)

raulmuroc’s picture

@Lechuck: Thank you!:-) You're right, it works for ApacheSolr Search Integration though not for ApacheSolr Search User.

I confirm this patch worked, at least for me.

I guess there are more confirmations needed to assign the Status as 'Reviewed & Tested by the community".

Status: Needs review » Needs work

The last submitted patch, apachesolr-bypassControlAccess-1665350-23.patch, failed testing.