mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 14:05:29 +02:00
NEW Use symfony/process to execute immediate system commands for reindexing
This commit is contained in:
parent
436b7663e1
commit
de4e2ba889
@ -23,7 +23,8 @@
|
||||
"require": {
|
||||
"silverstripe/framework": "^4.0",
|
||||
"monolog/monolog": "~1.15",
|
||||
"ptcinc/solr-php-client": "^1.0"
|
||||
"ptcinc/solr-php-client": "^1.0",
|
||||
"symfony/process": "^3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"silverstripe/cms": "^4.0",
|
||||
|
@ -8,6 +8,7 @@ use SilverStripe\Core\Manifest\ModuleLoader;
|
||||
use SilverStripe\FullTextSearch\Solr\Solr;
|
||||
use SilverStripe\FullTextSearch\Solr\SolrIndex;
|
||||
use SilverStripe\ORM\DB;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* Invokes an immediate reindex
|
||||
@ -77,11 +78,15 @@ class SolrReindexImmediateHandler extends SolrReindexBase
|
||||
$scriptTask = "php {$scriptPath} dev/tasks/{$taskName}";
|
||||
|
||||
$cmd = "{$scriptTask} index={$indexClassEscaped} class={$class} group={$group} groups={$groups} variantstate={$statevar}";
|
||||
$cmd .= " verbose=1 2>&1";
|
||||
$cmd .= " verbose=1";
|
||||
$logger->info("Running '$cmd'");
|
||||
|
||||
// Execute script via shell
|
||||
$res = $logger ? passthru($cmd) : `$cmd`;
|
||||
$process = new Process($cmd);
|
||||
$process->inheritEnvironmentVariables();
|
||||
$process->run();
|
||||
|
||||
$res = $process->getOutput();
|
||||
if ($logger) {
|
||||
$logger->info(preg_replace('/\r\n|\n/', '$0 ', $res));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user