Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
drunken monkey_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 …
Comment #2
drunken monkeyOK, not so easy – now when the Solr server isn't running, this will give a PHP warning in addition to the normal error message:
So, any better ideas on how to do this? Maybe we can use
$php_errormsg
to log the error with watchdog …Comment #3
drunken monkeyOK, 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.Comment #5
drunken monkey