I read through the install and grabbed the most recent SolrPhpClient (Built from 5/4/11) and kept getting the following error when I tried to add my Solr server (/admin/config/search/search_api/add_server):

Recoverable fatal error: Argument 1 passed to Apache_Solr_Response::__construct() must be an instance of Apache_Solr_HttpTransport_Response, string given, called in /yourpath/sites/all/modules/contrib/search_api_solr/solr_connection.inc on line 117 and defined in Apache_Solr_Response->__construct() (line 97 of /yourpath/sites/all/modules/contrib/search_api_solr/SolrPhpClient/Apache/Solr/Response.php).

I switched this out for the older SolrPhpClient(Built from 11/9/09) and the error went away add I was able to add my Solr server without incident.

I searched for topics around this issue but didn't see anything related so I wanted to post in case anyone else got hung up.

Comments

drunken monkey’s picture

Title: Solr PHP Client/Apache_Solr_HttpTransport_Response » Module doesn't work with the latest Solr PHP Client version
Version: 7.x-1.0-beta3 » 7.x-1.x-dev

Oh, didn't realize there was finally a new release. Thanks for reporting!

I now updated the INSTALL.txt file to reflect that the newer version won't work. However, I'll leave the issue open for now, as taking a look at the newer version might be interesting. Maybe adapting to it is a better option than writing a new connection system as suggested in #1032848: Store SolrPhpClient in Libraries folder.

LSU_JBob’s picture

subscribe

Shadlington’s picture

Subbing

pacunar’s picture

subscribe

pacunar’s picture

subscribe
-- sorry, double post!

Fidelix’s picture

Subscribing...

jbguerraz’s picture

Subscribe

mnlund’s picture

subscribe

drunken monkey’s picture

Status: Active » Needs review
StatusFileSize
new11.85 KB

OK, with that much feedback, I practically have to fix this, don't I?

I still think writing my own solution would be the better alternative, but as long as I don't have the time for that, it can't hurt to support both the old and the new version of SolrPhpClient. Since they are (at least in some internals – which I have regrettably overriden) incompatible, I had to use a little "hack" to decide which version of the code to use, but it seems to work.

Please test whether the module works both with the old and the new version of SolrPhpClient with the attached patch applied. You should also get nice little warning when r22 is installed. (Or would it be better to leace them out – after all, it should work equally well with both versions? On the other hand, I might decide to drop r22 support later, if I don't write my own client, and then a warning period would be good …)

tomogden’s picture

After getting the error message reported above, I installed the patch, but it resulted in another set of errors.

Notice: unserialize(): Error at offset 75 of 133 bytes in EntityAPIController->load() (line 211 of /var/www/vhosts/mainstreetnw.com/gallery/sites/all/modules/entity/includes/entity.controller.inc).
Notice: unserialize(): Error at offset 75 of 133 bytes in EntityAPIController->load() (line 211 of /var/www/vhosts/mainstreetnw.com/gallery/sites/all/modules/entity/includes/entity.controller.inc).
Notice: unserialize(): Error at offset 75 of 133 bytes in EntityAPIController->load() (line 211 of /var/www/vhosts/mainstreetnw.com/gallery/sites/all/modules/entity/includes/entity.controller.inc).
Recoverable fatal error: Argument 1 passed to Apache_Solr_Response::__construct() must be an instance of Apache_Solr_HttpTransport_Response, string given, called in /var/www/vhosts/mainstreetnw.com/gallery/sites/all/modules/search_api_solr/solr_connection.inc on line 117 and defined in Apache_Solr_Response->__construct() (line 97 of /var/www/vhosts/mainstreetnw.com/gallery/sites/all/modules/search_api_solr/SolrPhpClient/Apache/Solr/Response.php).
drunken monkey’s picture

If you have a call to the Apache_Solr_Response constructor at solr_connection:117, you apparently didn't apply the patch correctly.

Without patch:

115    // Attempt a HEAD request to the solr ping url.
116    list($data, $headers) = $this->_makeHttpRequest($this->_pingUrl, 'HEAD', array(), NULL, $timeout);
117    $response = new Apache_Solr_Response($data, $headers);

With patch:

107    $request_headers = array('Content-Type' => $contentType);
108    list($data, $headers) = $this->_makeHttpRequest($url, 'POST', $request_headers, $rawPost, $timeout);
109    $response = new Apache_Solr_Response($data, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays);
110    $code = (int) $response->getHttpStatus();
111    if ($code != 200) {
112      $message = $response->getHttpStatusMessage();
113      if ($code >= 400 && $code != 403 && $code != 404) {
114        // Add details, like Solr's exception message.
115        $message .= $response->getRawResponse();
116      }
117      throw new Exception('"' . $code . '" Status: ' . $message);
118    }

But thanks for taking the time to review! Apparently no-one else is willing to.

presleyd’s picture

It installed ok and seemed to work until I saved a new server and got a WSOD with the following error in the server logs:

PHP Fatal error: Class 'SearchApiSolrHttpTransport' not found in /mypath/sites/all/modules/search_api_solr/solr_connection.inc on line 62, referer: http://mysite/admin/config/search/search_api/add_server?render=overlay

I am using the dev version from 2011-07-28 so I had to patch it by hand. Other info: PHP 5.3, Solr 3.3

Aldus’s picture

subscribe

drunken monkey’s picture

It installed ok and seemed to work until I saved a new server and got a WSOD with the following error in the server logs:

PHP Fatal error: Class 'SearchApiSolrHttpTransport' not found in /mypath/sites/all/modules/search_api_solr/solr_connection.inc on line 62, referer: http://mysite/admin/config/search/search_api/add_server?render=overlay

I am using the dev version from 2011-07-28 so I had to patch it by hand. Other info: PHP 5.3, Solr 3.3

Did you clear the cache after applying the patch? It seems like the class in includes/solr_httptransport.inc isn't found by the Drupal autoloader.

Refineo’s picture

subscribe

presleyd’s picture

Ok, looking at it further it seems that the solr_httptransport.inc file wasn't inside the includes folder. I'm not sure how that happened. So far so good.

drunken monkey’s picture

Ok, looking at it further it seems that the solr_httptransport.inc file wasn't inside the includes folder. I'm not sure how that happened. So far so good.

So would you say everything works for you and this can be committed, as far as you are concerned?

@ Others: Please, don't just subscribe, review!

presleyd’s picture

As far as I can tell. PS This isn't hard to test out folks!

drunken monkey’s picture

StatusFileSize
new10.62 KB

Thanks for testing!
Re-rolling the patch – would be good, if someone else could test, too, but otherwise I'll just commit it in the next few days.

Refineo’s picture

Hi, I patched (manually) this 1184002--new-solr-client-version-19.patch and installed SolrPhpClient.r60.2011-05-04.

This causes WSOD when trying to

  • reuse existing server configuration
  • create new server config.

    on admin/config/search/search_api/server/localhost_solr_server

    Array
    (
        [type] => 1
        [message] => Call to a member function getStatusCode() on a non-object
        [file] => /***/sites/all/libraries/SolrPhpClient/Apache/Solr/Response.php
        [line] => 111
    )
    
  • presleyd’s picture

    Above it was noted that you should make sure you clear the cache after patching.

    Anonymous’s picture

    Status: Needs review » Reviewed & tested by the community

    +1

    Tested it with a few thousand custom entities, seen no problems.

    drunken monkey’s picture

    @refineo: Does clearing the cache after patching help? Otherwise, I need more information on the WSoD, when it exactly occurs, etc.

    @morningtime: Thanks for testing! Let's just see whether refineo's problems remain.

    Anonymous’s picture

    Ok, I had an existing server/index, just applied your patch and copied the new Solr version. Then I did Clear all caches, but also cleared my index before re-indexing. I didn't see a WSOD or any issues.

    Refineo’s picture

    Clearing the cache didn't help but the WSOD might be of another reason.
    Unfortunatelly I won't be able to retest this patch today. Please don't wait for me if you've already tested successfully.

    drunken monkey’s picture

    Status: Reviewed & tested by the community » Fixed

    OK then – committed.

    Status: Fixed » Closed (fixed)

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