Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The port number should not be required for configuration. #1145

Open
azovsky opened this issue Jan 30, 2025 · 1 comment
Open

The port number should not be required for configuration. #1145

azovsky opened this issue Jan 30, 2025 · 1 comment
Labels

Comments

@azovsky
Copy link

azovsky commented Jan 30, 2025

Solarium version(s) affected: 6.3.6
Solr version: 8.11.3
Solr mode: standalone

Description
There is no way to connect to the server WITHOUT specifying a port.

How to reproduce
I try set an "empty string" port in configs and get an error like:

TypeError: Solarium\Core\Client\Endpoint::getPort(): Return value must be of type ?int, string returned in Solarium\Core\Client\Endpoint->getPort() (line 123 of /var/www/html/vendor/solarium/solarium/src/Core/Client/Endpoint.php).

If I set port = NULL then I have : mark/symbol in the URI and this URL does not work.

Possible Solution
Fix / make more flexible Endpoint class -> function getServerUri().

instead of:

public function getServerUri(): string
  {
      return $this->getScheme().'://'.$this->getHost().':'.$this->getPort().$this->getPath().'/';
  }

upgrade to for example:

  public function getServerUri(): string
  {
    if ($this->getPort()) {
      return $this->getScheme() . '://' . $this->getHost() . ':' . $this->getPort() . $this->getPath() . '/';
    }
    else {
      return $this->getScheme() . '://' . $this->getHost() . $this->getPath() . '/';
    }
  }

Additional context

@thomascorthals
Copy link
Member

Can you provide a code sample that reproduces the problem? I'd like to see how you configured Solarium and which adapter you're using.

I did a quick test with examples 6.1.1 (PSR-18 adapter), 6.1.2 (cURL adapter), and 6.1.3 (HTTP adapter). All three do work for me with the scheme set to 'https' and the port explicitly set to null. Verified by setting up nginx as a reverse proxy that listens on port 443 and passes requests to Solr.

Having a : in the URI without a port number is allowed by RFC 3986.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants