I just ran into an issue not being able to connect to the solr server. No error message appears, so it was hard to track down. Problem, the leading @:

    // attempt a HEAD request to the solr ping page
    $ping = @file_get_contents($this->_pingUrl, FALSE, $context);

Without the @ I see the error message ;)

Warning: file_get_contents(): URL file-access is disabled in the server configuration in SearchApiSolrConnection->ping() (line 77 of .../modules/search_api/contrib/search_api_solr/solr_connection.inc).

So is it necessary to use the streams there? Perhaps the raw functions ala _sendRawPost() could be used instead?

Comments

Title:don't hide error messagesDon't hide error messages
Component:Code» Solr search
Status:Active» Fixed

_sendRawPost() uses exactly the same @file_get_contents call, so no improvement there. Also, we're doing a HEAD request here, which wouldn't work with those other methods (although it would probably only give a slightly higher latency).

Anyways, fixed as far as my part is concerned – I removed the "@". And hopefully we can soon switch to a better Solr PHP library altogether, so such ugly hacks aren't necessary anymore …

Status:Fixed» Active

OK, not so easy – now when the Solr server isn't running, this will give a PHP warning in addition to the normal error message:

Warning: file_get_contents(http://localhost:8983/solr/admin/ping?q=id:1): failed to open stream: Connection refused in SearchApiSolrConnection->ping() (line 76 of …/search_api/contrib/search_api_solr/solr_connection.inc).

So, any better ideas on how to do this? Maybe we can use $php_errormsg to log the error with watchdog …

Title:Don't hide error messagesHide error messages
Status:Active» Fixed

OK, reverted as described in the previous comment.
The $php_errormsg thing doesn't seem to work for me locally, but maybe it does for someone else, so I left it in.

Status:Fixed» Closed (fixed)

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

Project:Search API» Search API Solr Search
Component:Solr search» Code