You are here

public function SolrConnectorPluginBase::getSolrVersion in Search API Solr 8

Same name and namespace in other branches
  1. 8.3 src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::getSolrVersion()
  2. 8.2 src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::getSolrVersion()
  3. 4.x src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::getSolrVersion()

Gets the current Solr version.

Parameters

bool $force_auto_detect: If TRUE, ignore user overwrites.

Return value

string The full Solr version string.

Overrides SolrConnectorInterface::getSolrVersion

3 calls to SolrConnectorPluginBase::getSolrVersion()
SolrConnectorPluginBase::getLuceneMatchVersion in src/SolrConnector/SolrConnectorPluginBase.php
Gets the LuceneMatchVersion string.
SolrConnectorPluginBase::getSolrMajorVersion in src/SolrConnector/SolrConnectorPluginBase.php
Gets the current Solr major version.
SolrConnectorPluginBase::getStatsSummary in src/SolrConnector/SolrConnectorPluginBase.php
Gets summary information about the Solr Core.

File

src/SolrConnector/SolrConnectorPluginBase.php, line 371

Class

SolrConnectorPluginBase
Defines a base class for Solr connector plugins.

Namespace

Drupal\search_api_solr\SolrConnector

Code

public function getSolrVersion($force_auto_detect = FALSE) {

  // Allow for overrides by the user.
  if (!$force_auto_detect && !empty($this->configuration['solr_version'])) {

    // In most cases the already stored solr_version is just the major version
    // number as integer. In this case we will expand it to the minimum
    // corresponding full version string.
    $min_version = [
      '0',
      '0',
      '0',
    ];
    $version = implode('.', explode('.', $this->configuration['solr_version']) + $min_version);
    return '4.0.0' === $version ? '4.5.0' : $version;
  }
  $info = [];
  try {
    $info = $this
      ->getCoreInfo();
  } catch (SearchApiSolrException $e) {
    try {
      $info = $this
        ->getServerInfo();
    } catch (SearchApiSolrException $e) {
    }
  }

  // Get our solr version number.
  if (isset($info['lucene']['solr-spec-version'])) {
    return $info['lucene']['solr-spec-version'];
  }
  return '0.0.0';
}