diff --git a/bin/php/updatesearchindexsolr.php b/bin/php/updatesearchindexsolr.php index ed259a8b..e1eb99c5 100755 --- a/bin/php/updatesearchindexsolr.php +++ b/bin/php/updatesearchindexsolr.php @@ -105,6 +105,7 @@ public function run() 'clean-all' => "Remove all search data for all installations", 'conc' => 'Parallelization, number of concurent processes to use', 'php-exec' => 'Full path to PHP executable', + 'console-exec' => 'Full path to eZ5 console.', 'commit-within' => 'Commit to Solr within this time in seconds (default ' . self::DEFAULT_COMMIT_WITHIN . ' seconds)', 'offset' => '*For internal use only*', @@ -161,8 +162,15 @@ public function run() { $this->CLI->output( 'Starting object re-indexing' ); - // Get PHP executable from user. - $this->getPHPExecutable(); + global $input; + + if (is_null($input)) { + $this->getPHPExecutable(); // Get PHP executable from user. + } + else { + $this->getConsoleExecutable($input); + } + $this->runMain(); } @@ -233,28 +241,61 @@ protected function runSubProcess( $nodeID, $offset, $limit ) $this->Script->shutdown( 0 ); } + /** + * This script is being executed as a legacy-script from eZ5. + */ + protected function getConsoleExecutable($input) + { + $output = array(); + $exec = '../ezpublish/console'; + + if ( !empty($this->Options['console-exec']) ) + { + $exec = $this->Options['console-exec']; + } + + exec($exec, $output); + + while( !$this->validateExecutable($output, 'Symfony') ) + { + $input = readline( 'Enter path to Console executable ( or [q] to quit )' ); + if ( $input === 'q' ) + { + $this->Script->shutdown( 0 ); + } + + exec( $input, $output ); + } + + $parts = array($exec); + + if ($input->hasOption('env')) + { + $parts[] = '--env=' . $input->getOption('env'); + } + + $parts[] = $input->getArgument('command'); + + $this->Executable = implode(' ', $parts); + } + /** * Get PHP executable from user input. Exit if php executable cannot be * found and if no executable is entered. */ protected function getPHPExecutable() { - $validExecutable = false; $output = array(); $exec = 'php'; + if ( !empty( $this->Options['php-exec'] ) ) { $exec = $this->Options['php-exec']; } - exec( $exec . ' -v', $output ); - if ( count( $output ) && strpos( $output[0], 'PHP' ) !== false ) - { - $validExecutable = true; - $this->Executable = $exec; - } + exec( $exec . ' -v', $output ); - while( !$validExecutable ) + while( !$this->validateExecutable($output, 'PHP') ) { $input = readline( 'Enter path to PHP-CLI executable ( or [q] to quit )' ); if ( $input === 'q' ) @@ -263,13 +304,14 @@ protected function getPHPExecutable() } exec( $input . ' -v', $output ); - - if ( count( $output ) && strpos( $output[0], 'PHP' ) !== false ) - { - $validExecutable = true; - $this->Executable = $input; - } } + + $this->Executable = $exec; + } + + protected function validateExecutable($output, $string) + { + return count($output) && strpos ( $output[0], $string ) !== false; } /** @@ -491,7 +533,7 @@ protected function execute( $nodeID, $offset, $limit, $isSubProcess = false ) if ( $this->Options['siteaccess'] ) { - $paramString .= ' -s ' . escapeshellarg( $this->Options['siteaccess'] ); + $paramString .= ' --siteaccess=' . $this->Options['siteaccess']; } $paramString .=