mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 14:05:29 +02:00
Ensure all cores are initialised on configure
This commit is contained in:
parent
deddbe5f15
commit
75938c19a9
@ -87,6 +87,7 @@ class Solr_Configure extends BuildTask {
|
|||||||
|
|
||||||
public function run($request) {
|
public function run($request) {
|
||||||
$service = Solr::service();
|
$service = Solr::service();
|
||||||
|
$indexes = Solr::get_indexes();
|
||||||
|
|
||||||
if (!isset(Solr::$solr_options['indexstore']) || !($index = Solr::$solr_options['indexstore'])) {
|
if (!isset(Solr::$solr_options['indexstore']) || !($index = Solr::$solr_options['indexstore'])) {
|
||||||
user_error('No index configuration for Solr provided', E_USER_ERROR);
|
user_error('No index configuration for Solr provided', E_USER_ERROR);
|
||||||
@ -99,13 +100,15 @@ class Solr_Configure extends BuildTask {
|
|||||||
$local = $index['path'];
|
$local = $index['path'];
|
||||||
$remote = isset($index['remotepath']) ? $index['remotepath'] : $local;
|
$remote = isset($index['remotepath']) ? $index['remotepath'] : $local;
|
||||||
|
|
||||||
foreach (Solr::get_indexes() as $index => $instance) {
|
foreach ($indexes as $index => $instance) {
|
||||||
$sourceDir = $instance->getExtrasPath();
|
$sourceDir = $instance->getExtrasPath();
|
||||||
$targetDir = "$local/$index/conf";
|
$targetDir = "$local/$index/conf";
|
||||||
if (!is_dir($targetDir)) {
|
if (!is_dir($targetDir)) {
|
||||||
$worked = @mkdir($targetDir, 0770, true);
|
$worked = @mkdir($targetDir, 0770, true);
|
||||||
if(!$worked) echo sprintf('Failed creating target directory %s, please check permissions', $targetDir);
|
if(!$worked) {
|
||||||
return;
|
echo sprintf('Failed creating target directory %s, please check permissions', $targetDir);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents("$targetDir/schema.xml", $instance->generateSchema());
|
file_put_contents("$targetDir/schema.xml", $instance->generateSchema());
|
||||||
@ -152,18 +155,22 @@ class Solr_Configure extends BuildTask {
|
|||||||
user_error('Unknown Solr index mode '.$index['mode'], E_USER_ERROR);
|
user_error('Unknown Solr index mode '.$index['mode'], E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($service->coreIsActive($index)) {
|
foreach ($indexes as $index => $instance) {
|
||||||
echo "Reloading configuration...";
|
$indexName = $instance->getName();
|
||||||
$service->coreReload($index);
|
|
||||||
echo "done\n";
|
if ($service->coreIsActive($index)) {
|
||||||
} else {
|
echo "Reloading configuration...";
|
||||||
echo "Creating configuration...";
|
$service->coreReload($index);
|
||||||
$instanceDir = $indexName;
|
echo "done\n";
|
||||||
if ($remote) {
|
} else {
|
||||||
$instanceDir = "$remote/$instanceDir";
|
echo "Creating configuration...";
|
||||||
|
$instanceDir = $indexName;
|
||||||
|
if ($remote) {
|
||||||
|
$instanceDir = "$remote/$instanceDir";
|
||||||
|
}
|
||||||
|
$service->coreCreate($indexName, $instanceDir);
|
||||||
|
echo "done\n";
|
||||||
}
|
}
|
||||||
$service->coreCreate($indexName, $instanceDir);
|
|
||||||
echo "done\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user