protected function processGroup(
        LoggerInterface $logger,
        SolrIndex $indexInstance,
        $state,
        $class,
        $groups,
        $group,
        $taskName
    ) {
        $indexClass = get_class($indexInstance);

        // Build script parameters
        $indexClassEscaped = $indexClass;
        $statevar = json_encode($state);

        if (strpos(PHP_OS, "WIN") !== false) {
            $statevar = '"' . str_replace('"', '\\"', $statevar) . '"';
        } else {
            $statevar = "'" . $statevar . "'";
            $class = addslashes($class);
            $indexClassEscaped = addslashes($indexClass);
        }

        $php = Environment::getEnv('SS_PHP_BIN') ?: Config::inst()->get(static::class, 'php_bin');

        // Build script line
        $frameworkPath = ModuleLoader::getModule('silverstripe/framework')->getPath();
        $scriptPath = sprintf("%s%scli-script.php", $frameworkPath, DIRECTORY_SEPARATOR);
        $scriptTask = "{$php} {$scriptPath} dev/tasks/{$taskName}";

        $cmd = "{$scriptTask} index={$indexClassEscaped} class={$class} group={$group} groups={$groups} variantstate={$statevar}";
        $cmd .= " verbose=1";
        $logger->info("Running '$cmd'");

        // Execute script via shell
        $process = new Process($cmd);

        // Set timeout from config. Process default is 60 seconds
        $process->setTimeout($this->config()->get('process_timeout'));

        $process->inheritEnvironmentVariables();
        $process->run();

        $res = $process->getOutput();
        if ($logger) {
            $logger->info(preg_replace('/\r\n|\n/', '$0  ', $res));
        }

        // If we're in dev mode, commit more often for fun and profit
        if (Director::isDev()) {
            Solr::service($indexClass)->commit();
        }

        // This will slow down things a tiny bit, but it is done so that we don't timeout to the database during a reindex
        DB::query('SELECT 1');
    }
protected function processGroup(
        LoggerInterface $logger,
        SolrIndex $indexInstance,
        $state,
        $class,
        $groups,
        $group,
        $taskName
    ) {
        $indexClass = get_class($indexInstance);

        // Build script parameters
        $indexClassEscaped = $indexClass;
        $statevar = json_encode($state);

        if (strpos(PHP_OS, "WIN") !== false) {
            $statevar = '"' . str_replace('"', '\\"', $statevar) . '"';
        } else {
            $statevar = "'" . $statevar . "'";
            $class = addslashes($class);
            $indexClassEscaped = addslashes($indexClass);
        }

        $php = Environment::getEnv('SS_PHP_BIN') ?: Config::inst()->get(static::class, 'php_bin');

        // Build script line
        $frameworkPath = ModuleLoader::getModule('silverstripe/framework')->getPath();
        $scriptPath = sprintf("%s%scli-script.php", $frameworkPath, DIRECTORY_SEPARATOR);
        $scriptTask = "{$php} {$scriptPath} dev/tasks/{$taskName}";

        $cmd = "{$scriptTask} index={$indexClassEscaped} class={$class} group={$group} groups={$groups} variantstate={$statevar}";
        $cmd .= " verbose=1";
        $logger->info("Running '$cmd'");

        // Execute script via shell
        $process = new Process($cmd);

        // Set timeout from config. Process default is 60 seconds
        $process->setTimeout($this->config()->get('process_timeout'));

        $process->inheritEnvironmentVariables();
        $process->run();

        $res = $process->getOutput();
        if ($logger) {
            $logger->info(preg_replace('/\r\n|\n/', '$0  ', $res));
        }

        // If we're in dev mode, commit more often for fun and profit
        if (Director::isDev()) {
            Solr::service($indexClass)->commit();
        }

        // This will slow down things a tiny bit, but it is done so that we don't timeout to the database during a reindex
        DB::query('SELECT 1');
    }
protected function processGroup ( LoggerInterface $ logger , SolrIndex $ indexInstance , $ state , $ class , $ groups , $ group , $ taskName ) { $ indexClass = get_class ( $ indexInstance ) ; // Build script parameters $ indexClassEscaped = $ indexClass ; $ statevar = json_encode ( $ state ) ; if ( strpos ( PHP_OS , "WIN" ) !== false ) { $ statevar = '"' . str_replace ( '"' , '\\"' , $ statevar ) . '"' ; } else { $ statevar = "'" . $ statevar . "'" ; $ class = addslashes ( $ class ) ; $ indexClassEscaped = addslashes ( $ indexClass ) ; } $ php = Environment :: getEnv ( 'SS_PHP_BIN' ) ? : Config :: inst ( ) -> get ( static :: class , 'php_bin' ) ; // Build script line $ frameworkPath = ModuleLoader :: getModule ( 'silverstripe/framework' ) -> getPath ( ) ; $ scriptPath = sprintf ( "%s%scli-script.php" , $ frameworkPath , DIRECTORY_SEPARATOR ) ; $ scriptTask = "{$php} {$scriptPath} dev/tasks/{$taskName}" ; $ cmd = "{$scriptTask} index={$indexClassEscaped} class={$class} group={$group} groups={$groups} variantstate={$statevar}" ; $ cmd .= " verbose=1" ; $ logger -> info ( "Running '$cmd'" ) ; // Execute script via shell $ process = new Process ( $ cmd ) ; // Set timeout from config. Process default is 60 seconds $ process -> setTimeout ( $ this -> config ( ) -> get ( 'process_timeout' ) ) ; $ process -> inheritEnvironmentVariables ( ) ; $ process -> run ( ) ; $ res = $ process -> getOutput ( ) ; if ( $ logger ) { $ logger -> info ( preg_replace ( '/\r\n|\n/' , '$0  ' , $ res ) ) ; } // If we're in dev mode, commit more often for fun and profit if ( Director :: isDev ( ) ) { Solr :: service ( $ indexClass ) -> commit ( ) ; } // This will slow down things a tiny bit, but it is done so that we don't timeout to the database during a reindex DB :: query ( 'SELECT 1' ) ; }
Process a single group.

Without queuedjobs, it's necessary to shell this out to a background task as this is
very memory intensive.

The sub-process will then invoke $processor->runGroup() in {@see Solr_Reindex::doReindex}

@param LoggerInterface $logger
@param SolrIndex $indexInstance Index instance
@param array $state Variant state
@param string $class Class to index
@param int $groups Total groups
@param int $group Index of group to process
@param string $taskName Name of task script to run
Process a single group .