mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 11:33:17 +00:00
Remove support of binary paths by registry
This commit is contained in:
@@ -57,7 +57,9 @@ class PluginServiceProvider implements ServiceProviderInterface
|
|||||||
});
|
});
|
||||||
|
|
||||||
$app['plugins.composer-installer'] = $app->share(function (Application $app) {
|
$app['plugins.composer-installer'] = $app->share(function (Application $app) {
|
||||||
$phpBinary = $app['phraseanet.registry']->get('php_binary');
|
$binaries = $app['phraseanet.configuration']['binaries'];
|
||||||
|
$phpBinary = isset($binaries['php_binary']) ? $binaries['php_binary'] : null;
|
||||||
|
|
||||||
if (!is_executable($phpBinary)) {
|
if (!is_executable($phpBinary)) {
|
||||||
$finder = new ExecutableFinder();
|
$finder = new ExecutableFinder();
|
||||||
$phpBinary = $finder->find('php');
|
$phpBinary = $finder->find('php');
|
||||||
|
@@ -50,15 +50,11 @@ class Installer
|
|||||||
$this->phraseaIndexer = $path;
|
$this->phraseaIndexer = $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function populateRegistryData($serverName, $dataPath, $binaryData)
|
private function populateRegistryData($serverName, $dataPath)
|
||||||
{
|
{
|
||||||
$this->app['phraseanet.registry']->set('GV_base_datapath_noweb', $dataPath, \registry::TYPE_STRING);
|
$this->app['phraseanet.registry']->set('GV_base_datapath_noweb', $dataPath, \registry::TYPE_STRING);
|
||||||
$this->app['phraseanet.registry']->set('GV_ServerName', $serverName, \registry::TYPE_STRING);
|
$this->app['phraseanet.registry']->set('GV_ServerName', $serverName, \registry::TYPE_STRING);
|
||||||
|
|
||||||
foreach ($binaryData as $key => $value) {
|
|
||||||
$this->app['phraseanet.registry']->set($key, $value, \registry::TYPE_STRING);
|
|
||||||
}
|
|
||||||
|
|
||||||
// required to load GV template
|
// required to load GV template
|
||||||
$app = $this->app;
|
$app = $this->app;
|
||||||
$GV = require __DIR__ . '/../../../../lib/conf.d/_GV_template.inc';
|
$GV = require __DIR__ . '/../../../../lib/conf.d/_GV_template.inc';
|
||||||
|
@@ -16,20 +16,20 @@ use Alchemy\Phrasea\Setup\Requirements\BinariesRequirements;
|
|||||||
|
|
||||||
class BinariesProbe extends BinariesRequirements implements ProbeInterface
|
class BinariesProbe extends BinariesRequirements implements ProbeInterface
|
||||||
{
|
{
|
||||||
public function __construct(\registryInterface $registry)
|
public function __construct(array $binaries)
|
||||||
{
|
{
|
||||||
parent::__construct(array_filter(array(
|
parent::__construct(array_filter(array(
|
||||||
'php_binary' => $registry->get('php_binary'),
|
'php_binary' => isset($binaries['php_binary']) ? $binaries['php_binary'] : null,
|
||||||
'convert_binary' => $registry->get('convert_binary'),
|
'convert_binary' => isset($binaries['convert_binary']) ? $binaries['convert_binary'] : null,
|
||||||
'pdf2swf_binary' => $registry->get('pdf2swf_binary'),
|
'pdf2swf_binary' => isset($binaries['pdf2swf_binary']) ? $binaries['pdf2swf_binary'] : null,
|
||||||
'unoconv_binary' => $registry->get('unoconv_binary'),
|
'unoconv_binary' => isset($binaries['unoconv_binary']) ? $binaries['unoconv_binary'] : null,
|
||||||
'swf_extract_binary' => $registry->get('swf_extract_binary'),
|
'swf_extract_binary' => isset($binaries['swf_extract_binary']) ? $binaries['swf_extract_binary'] : null,
|
||||||
'swf_render_binary' => $registry->get('swf_render_binary'),
|
'swf_render_binary' => isset($binaries['swf_render_binary']) ? $binaries['swf_render_binary'] : null,
|
||||||
'mp4box_binary' => $registry->get('mp4box_binary'),
|
'mp4box_binary' => isset($binaries['mp4box_binary']) ? $binaries['mp4box_binary'] : null,
|
||||||
'pdftotext_binary' => $registry->get('pdftotext_binary'),
|
'pdftotext_binary' => isset($binaries['pdftotext_binary']) ? $binaries['pdftotext_binary'] : null,
|
||||||
'composite_binary' => $registry->get('composite_binary'),
|
'composite_binary' => isset($binaries['composite_binary']) ? $binaries['composite_binary'] : null,
|
||||||
'ffmpeg_binary' => $registry->get('ffmpeg_binary'),
|
'ffmpeg_binary' => isset($binaries['ffmpeg_binary']) ? $binaries['ffmpeg_binary'] : null,
|
||||||
'ffprobe_binary' => $registry->get('ffprobe_binary'),
|
'ffprobe_binary' => isset($binaries['ffprobe_binary']) ? $binaries['ffprobe_binary'] : null,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,6 +40,6 @@ class BinariesProbe extends BinariesRequirements implements ProbeInterface
|
|||||||
*/
|
*/
|
||||||
public static function create(Application $app)
|
public static function create(Application $app)
|
||||||
{
|
{
|
||||||
return new static($app['phraseanet.registry']);
|
return new static($app['phraseanet.configuration']['binaries']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -335,6 +335,8 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$SEStatus = array('error' => $e->getMessage());
|
$SEStatus = array('error' => $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$binaries = $app['phraseanet.configuration']['binaries'];
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'global_values' => array(
|
'global_values' => array(
|
||||||
'serverName' => $app['phraseanet.registry']->get('GV_ServerName'),
|
'serverName' => $app['phraseanet.registry']->get('GV_ServerName'),
|
||||||
@@ -426,17 +428,17 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
'binary' => array(
|
'binary' => array(
|
||||||
'phpCli' => $app['phraseanet.registry']->get('php_binary'),
|
'phpCli' => isset($binaries['php_binary']) ? $binaries['php_binary'] : null,
|
||||||
'phpIni' => $app['phraseanet.registry']->get('GV_PHP_INI'),
|
'phpIni' => $app['phraseanet.registry']->get('GV_PHP_INI'),
|
||||||
'imagick' => $app['phraseanet.registry']->get('convert_binary'),
|
'imagick' => $app['phraseanet.registry']->get('convert_binary'),
|
||||||
'swfExtract' => $app['phraseanet.registry']->get('swf_extract_binary'),
|
'swfExtract' => isset($binaries['swf_extract_binary']) ? $binaries['swf_extract_binary'] : null,
|
||||||
'pdf2swf' => $app['phraseanet.registry']->get('pdf2swf_binary'),
|
'pdf2swf' => isset($binaries['pdf2swf_binary']) ? $binaries['pdf2swf_binary'] : null,
|
||||||
'swfRender' => $app['phraseanet.registry']->get('swf_render_binary'),
|
'swfRender' => isset($binaries['swf_render_binary']) ? $binaries['swf_render_binary'] : null,
|
||||||
'unoconv' => $app['phraseanet.registry']->get('unoconv_binary'),
|
'unoconv' => isset($binaries['unoconv_binary']) ? $binaries['unoconv_binary'] : null,
|
||||||
'ffmpeg' => $app['phraseanet.registry']->get('ffmpeg_binary'),
|
'ffmpeg' => isset($binaries['ffmpeg_binary']) ? $binaries['ffmpeg_binary'] : null,
|
||||||
'ffprobe' => $app['phraseanet.registry']->get('ffprobe_binary'),
|
'ffprobe' => isset($binaries['ffprobe_binary']) ? $binaries['ffprobe_binary'] : null,
|
||||||
'mp4box' => $app['phraseanet.registry']->get('mp4box_binary'),
|
'mp4box' => isset($binaries['mp4box_binary']) ? $binaries['mp4box_binary'] : null,
|
||||||
'pdftotext' => $app['phraseanet.registry']->get('pdftotext_binary'),
|
'pdftotext' => isset($binaries['pdftotext_binary']) ? $binaries['pdftotext_binary'] : null,
|
||||||
'pdfmaxpages' => $app['phraseanet.registry']->get('GV_pdfmaxpages'),),
|
'pdfmaxpages' => $app['phraseanet.registry']->get('GV_pdfmaxpages'),),
|
||||||
'mainConfiguration' => array(
|
'mainConfiguration' => array(
|
||||||
'adminMail' => $app['phraseanet.registry']->get('GV_adminMail'),
|
'adminMail' => $app['phraseanet.registry']->get('GV_adminMail'),
|
||||||
|
@@ -90,12 +90,12 @@ class patch_373 implements patchInterface
|
|||||||
'GV_pdftotext' => 'pdftotext_binary',
|
'GV_pdftotext' => 'pdftotext_binary',
|
||||||
);
|
);
|
||||||
|
|
||||||
$binaries = array('ghostscript_binary' => '');
|
$binaries = array('ghostscript_binary' => null);
|
||||||
|
|
||||||
foreach ($Regbinaries as $name) {
|
foreach ($Regbinaries as $name) {
|
||||||
$stmt->execute(array(':key' => $name));
|
$stmt->execute(array(':key' => $name));
|
||||||
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||||
$value = is_executable($row['value']) ? $row['value'] : '';
|
$value = is_executable($row['value']) ? $row['value'] : null;
|
||||||
|
|
||||||
$binaries[$mapping[$name]] = $value;
|
$binaries[$mapping[$name]] = $value;
|
||||||
}
|
}
|
||||||
|
@@ -75,6 +75,7 @@ class recordutils_image extends recordutils
|
|||||||
public static function stamp(Application $app, \media_subdef $subdef)
|
public static function stamp(Application $app, \media_subdef $subdef)
|
||||||
{
|
{
|
||||||
$base_id = $subdef->get_record()->get_base_id();
|
$base_id = $subdef->get_record()->get_base_id();
|
||||||
|
$binaries = $app['phraseanet.configuration']['binaries'];
|
||||||
|
|
||||||
if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) {
|
if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) {
|
||||||
return $subdef->get_pathfile();
|
return $subdef->get_pathfile();
|
||||||
@@ -84,7 +85,7 @@ class recordutils_image extends recordutils
|
|||||||
return $subdef->get_pathfile();
|
return $subdef->get_pathfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $app['phraseanet.registry']->get('convert_binary')) {
|
if ( ! isset($binaries['convert_binary'])) {
|
||||||
return $subdef->get_pathfile();
|
return $subdef->get_pathfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +288,7 @@ class recordutils_image extends recordutils
|
|||||||
|
|
||||||
$newh = $image_height + $stampheight;
|
$newh = $image_height + $stampheight;
|
||||||
|
|
||||||
$builder = ProcessBuilder::create(array($app['phraseanet.registry']->get('convert_binary')));
|
$builder = ProcessBuilder::create(array($binaries['convert_binary']));
|
||||||
$builder->add('-extent')
|
$builder->add('-extent')
|
||||||
->add($image_width . 'x' . $newh)
|
->add($image_width . 'x' . $newh)
|
||||||
->add('-draw')
|
->add('-draw')
|
||||||
@@ -316,6 +317,7 @@ class recordutils_image extends recordutils
|
|||||||
public static function watermark(Application $app, \media_subdef $subdef)
|
public static function watermark(Application $app, \media_subdef $subdef)
|
||||||
{
|
{
|
||||||
$base_id = $subdef->get_record()->get_base_id();
|
$base_id = $subdef->get_record()->get_base_id();
|
||||||
|
$binaries = $app['phraseanet.configuration']['binaries'];
|
||||||
|
|
||||||
if ($subdef->get_name() !== 'preview') {
|
if ($subdef->get_name() !== 'preview') {
|
||||||
return $subdef->get_pathfile();
|
return $subdef->get_pathfile();
|
||||||
@@ -341,11 +343,11 @@ class recordutils_image extends recordutils
|
|||||||
return $pathOut;
|
return $pathOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($app['phraseanet.registry']->get('composite_binary') &&
|
if (isset($binaries['composite_binary']) &&
|
||||||
file_exists($app['root.path'] . '/config/wm/' . $base_id)) {
|
file_exists($app['root.path'] . '/config/wm/' . $base_id)) {
|
||||||
|
|
||||||
$builder = ProcessBuilder::create(array(
|
$builder = ProcessBuilder::create(array(
|
||||||
$app['phraseanet.registry']->get('composite_binary'),
|
$binaries['composite_binary'],
|
||||||
$app['root.path'] . '/config/wm/' . $base_id,
|
$app['root.path'] . '/config/wm/' . $base_id,
|
||||||
$pathIn,
|
$pathIn,
|
||||||
'-strip', '-watermark', '90%', '-gravity', 'center',
|
'-strip', '-watermark', '90%', '-gravity', 'center',
|
||||||
@@ -353,7 +355,7 @@ class recordutils_image extends recordutils
|
|||||||
));
|
));
|
||||||
|
|
||||||
$builder->getProcess()->run();
|
$builder->getProcess()->run();
|
||||||
} elseif ($app['phraseanet.registry']->get('convert_binary')) {
|
} elseif (isset($binaries['convert_binary'])) {
|
||||||
$collname = phrasea::bas_labels($base_id, $app);
|
$collname = phrasea::bas_labels($base_id, $app);
|
||||||
$tailleimg = @getimagesize($pathIn);
|
$tailleimg = @getimagesize($pathIn);
|
||||||
$max = ($tailleimg[0] > $tailleimg[1] ? $tailleimg[0] : $tailleimg[1]);
|
$max = ($tailleimg[0] > $tailleimg[1] ? $tailleimg[0] : $tailleimg[1]);
|
||||||
@@ -369,7 +371,7 @@ class recordutils_image extends recordutils
|
|||||||
$decalage = 1;
|
$decalage = 1;
|
||||||
|
|
||||||
$builder = ProcessBuilder::create(array(
|
$builder = ProcessBuilder::create(array(
|
||||||
$app['phraseanet.registry']->get('convert_binary'),
|
$binaries['convert_binary'],
|
||||||
'-fill', 'white', '-draw', 'line 0,0 ' . $tailleimg[0] . ',' . $tailleimg[1] . '',
|
'-fill', 'white', '-draw', 'line 0,0 ' . $tailleimg[0] . ',' . $tailleimg[1] . '',
|
||||||
'-fill', 'black', '-draw', 'line 1,0 ' . $tailleimg[0] + 1 . ',' . $tailleimg[1] . '',
|
'-fill', 'black', '-draw', 'line 1,0 ' . $tailleimg[0] + 1 . ',' . $tailleimg[1] . '',
|
||||||
'-fill', 'white', '-draw', 'line ' . $tailleimg[0] . ',0 0,' . $tailleimg[1] . '',
|
'-fill', 'white', '-draw', 'line ' . $tailleimg[0] . ',0 0,' . $tailleimg[1] . '',
|
||||||
|
@@ -55,14 +55,6 @@ class registry implements registryInterface
|
|||||||
if (isset($config['main']['key'])) {
|
if (isset($config['main']['key'])) {
|
||||||
$this->cache->save('GV_sit', $config['main']['key']);
|
$this->cache->save('GV_sit', $config['main']['key']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($config['binaries'])) {
|
|
||||||
foreach ($config['binaries'] as $name => $path) {
|
|
||||||
if ($path) {
|
|
||||||
$this->cache->save($name, $path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
|
use Symfony\Component\Process\ExecutableFinder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -62,7 +63,14 @@ class task_Scheduler
|
|||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
//prevent scheduler to fail if GV_cli is not provided
|
//prevent scheduler to fail if GV_cli is not provided
|
||||||
if ( ! is_executable($this->dependencyContainer['phraseanet.registry']->get('php_binary'))) {
|
if (isset($this->dependencyContainer['phraseanet.configuration']['binaries']['php_binary'])) {
|
||||||
|
$php = $this->dependencyContainer['phraseanet.configuration']['binaries']['php_binary'];
|
||||||
|
} else {
|
||||||
|
$finder = new ExecutableFinder();
|
||||||
|
$php = $finder->find($php);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! is_executable($php)) {
|
||||||
throw new \RuntimeException('PHP cli is not provided in registry');
|
throw new \RuntimeException('PHP cli is not provided in registry');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,7 +233,7 @@ class task_Scheduler
|
|||||||
$taskPoll[$tkey] = array(
|
$taskPoll[$tkey] = array(
|
||||||
"task" => $task,
|
"task" => $task,
|
||||||
"current_status" => $status,
|
"current_status" => $status,
|
||||||
"cmd" => $this->dependencyContainer['phraseanet.registry']->get('php_binary'),
|
"cmd" => $php,
|
||||||
"args" => array(
|
"args" => array(
|
||||||
'-f',
|
'-f',
|
||||||
$this->dependencyContainer['root.path'] . '/bin/console',
|
$this->dependencyContainer['root.path'] . '/bin/console',
|
||||||
|
@@ -126,9 +126,15 @@ class task_manager
|
|||||||
|
|
||||||
public function getSchedulerProcess()
|
public function getSchedulerProcess()
|
||||||
{
|
{
|
||||||
$phpcli = $this->app['phraseanet.registry']->get('php_binary');
|
//prevent scheduler to fail if GV_cli is not provided
|
||||||
|
if (isset($this->app['phraseanet.configuration']['binaries']['php_binary'])) {
|
||||||
|
$php = $this->app['phraseanet.configuration']['binaries']['php_binary'];
|
||||||
|
} else {
|
||||||
|
$finder = new ExecutableFinder();
|
||||||
|
$php = $finder->find($php);
|
||||||
|
}
|
||||||
|
|
||||||
$cmd = $phpcli . ' -f ' . $this->app['root.path'] . "/bin/console scheduler:start";
|
$cmd = $php . ' -f ' . $this->app['root.path'] . "/bin/console scheduler:start";
|
||||||
|
|
||||||
return new Process($cmd);
|
return new Process($cmd);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user