MediaMosa solr module strips https from URL

26Oct2011

When entering a URL with https for the 'Server connection setup for Solr' at /admin/mediamosa/config/solr, MediaMosa strips the protocol, reverting it to http instead.

Eg.
https://mm-solr-test01.uio.no/solr

becomes
http://mm-solr-test01.uio.no:8983/solr/

whereas it should be interpreted as
https://mm-solr-test01.uio.no:443/solr

Comments

This is a real

This is a real issue.
Eg.
https://mm-solr-test01.uio.no:443/solr
Converted to:
http://mm-solr-test01.uio.no:443/solr
(Port stays the same, but scheme changes.)

Solution:

diff -r a33bbefa1781 sites/all/modules/mediamosa_solr/mediamosa_solr_apache_solr_service.class.inc
--- a/sites/all/modules/mediamosa_solr/mediamosa_solr_apache_solr_service.class.inc Thu Oct 13 11:49:14 2011 +0200
+++ b/sites/all/modules/mediamosa_solr/mediamosa_solr_apache_solr_service.class.inc Wed Oct 26 15:34:28 2011 +0200
@@ -128,8 +128,8 @@
'path' => self::MEDIAMOSA_SOLR_DEFAULT_PATH,
);

- // Solr only uses host, port and path.
- return 'http://' . $parse_url['host'] . ':' . $parse_url['port'] . '/' . trim($parse_url['path'], '/') . '/';
+ // Solr only uses scheme, host, port and path.
+ return $parse_url['scheme'] . '://' . $parse_url['host'] . ':' . $parse_url['port'] . '/' . trim($parse_url['path'], '/') . '/';
}

/**

More fix needed

The problem still persists, even with the above mentioned bug fix.
Entered URL https://mm-solr-test01.uio.no:443/solr

In file sites/all/modules/mediamosa_solr/mediamosa_solr_apache_solr_service.class.inc, I've added
drupal_set_message('test: <pre>' . htmlspecialchars(print_r($url, TRUE)) . '</pre>'); to line 214 (approx.) , which prints out the correct URL.

Whereas
drupal_set_message('test: <pre>' . htmlspecialchars(print_r($mediamosa_apache_solr_service[$url], TRUE)) . '</pre>');
on line 218 (or thereabout) prints out the following:

Debug info
mediamosa_solr_apache_solr_service Object
(
[_host:protected] => mm-solr-test01.uio.no
[_port:protected] => 443
[_path:protected] => /solr/
[_createDocuments:protected] => 1
[_collapseSingleValueArrays:protected] => 1
[_namedListTreatment:protected] => map
[_queryDelimiter:protected] => ?
[_queryStringDelimiter:protected] => &
[_pingUrl:protected] => http://mm-solr-test01.uio.no:443/solr/admin/ping
[_updateUrl:protected] => http://mm-solr-test01.uio.no:443/solr/update?wt=json
[_searchUrl:protected] => http://mm-solr-test01.uio.no:443/solr/select
[_threadsUrl:protected] => http://mm-solr-test01.uio.no:443/solr/admin/threads?wt=json
[_urlsInited:protected] => 1
[_getContext:protected] => Resource id #156
[_postContext:protected] => Resource id #157
[_defaultTimeout:protected] => 60
)

The fix

The problem lies in the file sites/all/modules/mediamosa_solr/3rdparty/SolrPhpClient/Apache/Solr/Service.php, line 286:

return 'http://' . $this->_host . ':' . $this->_port . $this->_path . $servlet . $queryString;

This should be changed to something generic

Håvard, Thanks for your error

Håvard, Thanks for your error report. We will fix this issue later.

Created ticket

Hi,

I've created a ticket for this issue, and added a minor patch in github.
http://mediamosa.org/trac/ticket/546

Hi, The patch looks good, i

Hi,

The patch looks good, i could not get it to work, probably because i used a self signed certificate. Did you got this patch working with a self-signed certificate?

Also there is some more hardcoded 'http' strings in the 3rdparty code (sendRawPost() and sendRawPost() and ping()). Should they not also be overridden?

The patch I submitted was the

The patch I submitted was the code that Peter Forgacs posted.

I have gotten MediaMosa to connect to our Solr-instance, however, we are using a setup where write access requires authentication. This is not implemented in the 3rd party code that is included in the MediaMosa Solr module.

The drawback is that once MediaMosa failes to write to the Solr-instance, all cron jobs fails - even if you disable the module and delete it from the modules directory.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.