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
- Remove the 'smart' formatting in
getServerUri() - Account for configuration overrides in
\Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBaseOR do not display the Solr server URI on the edit form
Remaining tasks
- Write a patch
- Review
- Commit
User interface changes
To be determined.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3066614-4.patch | 922 bytes | idebr |
Comments
Comment #2
idebr commentedAttached 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.Comment #3
mkalkbrennerRemoving 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.
Comment #4
idebr commented#3
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.
Comment #5
mkalkbrennerComment #7
mkalkbrennercommitted, thanks!