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

SolrPower_Api->get_server_info returns inaccurate server information #408

Open
pavellishin opened this issue May 20, 2019 · 3 comments
Open
Labels

Comments

@pavellishin
Copy link
Contributor

https://github.com/pantheon-systems/solr-power/blob/master/includes/class-solrpower-api.php#L575-L584

get_server_info() assumes that the host name and port are the pantheon environmental variables, but it's possible to override the connection data via filters and constants.

(I'll try to get a PR out for this this week if I can.)

@danielbachhuber
Copy link
Contributor

(I'll try to get a PR out for this this week if I can.)

That'd be great, thanks!

@fembuelita
Copy link

I know there's a PR for this right now, but since it hasn't been approved yet, here's another option to solve this:

    public function get_server_info() {
        $connection_options = apply_filters('s4wp_connection_options', [
            'endpoint' => [
                'localhost' => [
                    'host' => getenv( 'PANTHEON_INDEX_HOST' ),
                    'port' => getenv( 'PANTHEON_INDEX_PORT' ),
                    'path' => $this->compute_path()
                ]
            ]
        ]);

        $server_info = [
            'ping_status' => $this->ping_server(),
            'ip_address'  => $connection_options['endpoint']['localhost']['host'],
            'port'        => $connection_options['endpoint']['localhost']['port'],
            'path'        => $connection_options['endpoint']['localhost']['path'],
        ];

        return $server_info;

    }

@jocastaneda
Copy link

I was tinkering with code trying to get a slightly better understanding of things as well and one possible way is also by changing the function to something like:

public function get_server_info() {
	return array(
		'ping_status' => $this->ping_server(),
		'ip_address'  => $this->get_solr()->getEndpoint('localhost')->getHost(),
		'port'        => $this->get_solr()->getEndpoint('localhost')->getPort(),
		'path'        => $this->compute_path(),
	);
}

This would also mean changing the get_solr() function but that can be done like:

$host = getenv( 'PANTHEON_INDEX_HOST' ) ? getenv( 'PANTHEON_INDEX_HOST' ) : null;
$port = getenv( 'PANTHEON_INDEX_PORT' ) ? getenv( 'PANTHEON_INDEX_PORT' ) : null;

$solarium_config      = array(
	'endpoint' => array(
		'localhost' => array(
			'host'   => apply_filters( 'solr_power_hostname', $host ),
			'port'   => apply_filters( 'solr_power_port', $port ),
			'scheme' => $this->get_default_scheme(),
			'path'   => $this->compute_path(),
			'ssl'    => array(
				'local_cert' => self::get_cert_path(),
			),
		),
	),
);

Or just not have those *_power_(hostname|port) filters since it can be filtered with the s4wp_connection_options filter that is created here.

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

4 participants