From 0764c0ed1e2067a59f12e3dbdc3e9bf9db568367 Mon Sep 17 00:00:00 2001 From: jovenden Date: Thu, 8 Mar 2018 14:17:33 +1300 Subject: [PATCH] Ensure only Namespaced format is used for Configure --- src/Solr/Services/SolrService.php | 15 +-------------- src/Solr/SolrIndex.php | 8 ++------ 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/Solr/Services/SolrService.php b/src/Solr/Services/SolrService.php index c719e89..7f20d88 100644 --- a/src/Solr/Services/SolrService.php +++ b/src/Solr/Services/SolrService.php @@ -21,12 +21,7 @@ class SolrService extends SolrService_Core */ protected function coreCommand($command, $core, $params = array()) { - // Unencode the class name - $core = SolrIndex::getClassNameFromIndex($core); - $command = strtoupper($command); - //get the non-namespaced name of the Solr core, since backslashes not valid characters - $core = ClassInfo::shortName($core); $params = array_merge($params, array('action' => $command, 'wt' => 'json')); $params[$command == 'CREATE' ? 'name' : 'core'] = $core; @@ -40,17 +35,9 @@ class SolrService extends SolrService_Core */ public function coreIsActive($core) { - // Unencode the class name - $core = SolrIndex::getClassNameFromIndex($core); - // Request the status of the full core name $result = $this->coreCommand('STATUS', $core); - - // Solr returns the core as the 'short name' of the class (e.g. Mysite\Search\SolrIndex -> SolrIndex) - $reflection = new \ReflectionClass($core); - $shortClass = $reflection->getShortName(); - - return isset($result->status->$shortClass->uptime); + return isset($result->status->$core->uptime); } /** diff --git a/src/Solr/SolrIndex.php b/src/Solr/SolrIndex.php index 6311a5f..ef3a82b 100644 --- a/src/Solr/SolrIndex.php +++ b/src/Solr/SolrIndex.php @@ -3,7 +3,6 @@ namespace SilverStripe\FullTextSearch\Solr; use SilverStripe\Control\Director; -use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Environment; use SilverStripe\FulltextSearch\Search\Indexes\SearchIndex; use SilverStripe\FullTextSearch\Search\Variants\SearchVariant_Caller; @@ -1052,12 +1051,9 @@ abstract class SolrIndex extends SearchIndex */ public function uploadConfig($store) { - // Ensure the short class name is used to match the call which creates the core in SolrService->coreCreate() - $indexName = self::getClassNameFromIndex($this->getIndexName()); - $indexName = ClassInfo::shortName($indexName); // Upload the config files for this index $store->uploadString( - $indexName, + $this->getIndexName(), 'schema.xml', (string)$this->generateSchema() ); @@ -1065,7 +1061,7 @@ abstract class SolrIndex extends SearchIndex // Upload additional files foreach (glob($this->getExtrasPath().'/*') as $file) { if (is_file($file)) { - $store->uploadFile($indexName, $file); + $store->uploadFile($this->getIndexName(), $file); } } }