Problem/Motivation

The Search API server edit form displays the Solr server URI as follows through \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend:

$form['server_description'] = [
  '#type' => 'item',
   '#title' => $this->t('Solr server URI'),
  '#description' => $this->getSolrConnector()->getServerLink(),
];

The server link is generated by replacing the localhost with the $_SERVER['SERVER_NAME']. However, the server name global is incorrect for servers behind a load balancer, for example http://localhost turns into http://~^uu(0(3|4)|)\\.nl$:8983/, which is misleading.

Furthermore, the $configuration object in \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase does not include configuration overrides. A typical way to implement different Solr backend for different environments is to apply a configuration override in settings.php, for example:

$config['search_api.server.solr']['backend_config']['connector_config']['host'] = 'solr-test.combell.net';

This URL is then reflected in the user interface on the server canonical page, but not its edit form.

Proposed resolution

  1. Remove the 'smart' formatting in getServerUri()
  2. Account for configuration overrides in \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase OR do not display the Solr server URI on the edit form

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

To be determined.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#4 3066614-4.patch922 bytesidebr
#2 3066614-2.patch748 bytesidebr

Comments

idebr created an issue. See original summary.

idebr’s picture

Status: Active » Needs review
StatusFileSize
new748 bytes

Attached patch removes the 'smart' formatting from \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::getServerUri. The Solr server URI now matches the parts defined in the form, which seems a more logical way to display the server information.

mkalkbrenner’s picture

Status: Needs review » Needs work

Removing the "smart" formatting is the wrong choice for most users. The purpose of the generated Link is clickable to reach the Solr UI.
For a lot of installations the host is 'localhost' which is for not reachable from outside and therefore needs to be converted.
So instead of removing the formatting, a "smarter" formatting would be the right solution.

But you're right that the Server URI must not be shown on the edit form, only on the view where overwrites should be applied.

idebr’s picture

Status: Needs work » Needs review
StatusFileSize
new922 bytes

#3

But you're right that the Server URI must not be shown on the edit form, only on the view where overwrites should be applied.

This works for me, since the configuration override is applied correctly on the overview page. Attached patch removes the server information from the edit form.

mkalkbrenner’s picture

Title: SolrConnectorPluginBase::getServerUri() returns incorrect information in common application structures » SolrConnectorPluginBase::getServerUri() returns incorrect information on edit form

  • mkalkbrenner committed 5e50886 on 8.x-3.x authored by idebr
    Issue #3066614 by idebr, mkalkbrenner: SolrConnectorPluginBase::...
mkalkbrenner’s picture

Status: Needs review » Fixed

committed, thanks!

Status: Fixed » Closed (fixed)

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