Ensure only Namespaced format is used for Configure

This commit is contained in:
jovenden 2018-03-08 14:17:33 +13:00
parent b6e64a2ec4
commit 0764c0ed1e
2 changed files with 3 additions and 20 deletions

View File

@ -21,12 +21,7 @@ class SolrService extends SolrService_Core
*/ */
protected function coreCommand($command, $core, $params = array()) protected function coreCommand($command, $core, $params = array())
{ {
// Unencode the class name
$core = SolrIndex::getClassNameFromIndex($core);
$command = strtoupper($command); $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 = array_merge($params, array('action' => $command, 'wt' => 'json'));
$params[$command == 'CREATE' ? 'name' : 'core'] = $core; $params[$command == 'CREATE' ? 'name' : 'core'] = $core;
@ -40,17 +35,9 @@ class SolrService extends SolrService_Core
*/ */
public function coreIsActive($core) public function coreIsActive($core)
{ {
// Unencode the class name
$core = SolrIndex::getClassNameFromIndex($core);
// Request the status of the full core name // Request the status of the full core name
$result = $this->coreCommand('STATUS', $core); $result = $this->coreCommand('STATUS', $core);
return isset($result->status->$core->uptime);
// 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);
} }
/** /**

View File

@ -3,7 +3,6 @@
namespace SilverStripe\FullTextSearch\Solr; namespace SilverStripe\FullTextSearch\Solr;
use SilverStripe\Control\Director; use SilverStripe\Control\Director;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Environment; use SilverStripe\Core\Environment;
use SilverStripe\FulltextSearch\Search\Indexes\SearchIndex; use SilverStripe\FulltextSearch\Search\Indexes\SearchIndex;
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant_Caller; use SilverStripe\FullTextSearch\Search\Variants\SearchVariant_Caller;
@ -1052,12 +1051,9 @@ abstract class SolrIndex extends SearchIndex
*/ */
public function uploadConfig($store) 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 // Upload the config files for this index
$store->uploadString( $store->uploadString(
$indexName, $this->getIndexName(),
'schema.xml', 'schema.xml',
(string)$this->generateSchema() (string)$this->generateSchema()
); );
@ -1065,7 +1061,7 @@ abstract class SolrIndex extends SearchIndex
// Upload additional files // Upload additional files
foreach (glob($this->getExtrasPath().'/*') as $file) { foreach (glob($this->getExtrasPath().'/*') as $file) {
if (is_file($file)) { if (is_file($file)) {
$store->uploadFile($indexName, $file); $store->uploadFile($this->getIndexName(), $file);
} }
} }
} }