Remove phraseanet services, update configuration

This commit is contained in:
Romain Neutron
2013-06-11 11:57:43 +02:00
parent 8ecc97e94e
commit 32c2d6154a
99 changed files with 1545 additions and 5049 deletions

View File

@@ -10,7 +10,6 @@
*/
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\Checker;
/**
*
@@ -55,92 +54,13 @@ class patch_370a9 implements patchInterface
}
/**
* Add new border manager service to services.yml & config.yml configuration files
*
* @param base $appbox
* @param Application $app
*/
public function apply(base $appbox, Application $app)
{
$services = $app['phraseanet.configuration']->getServices();
$app['phraseanet.configuration']->setDefault('border-manager');
if ( ! isset($services['Border'])) {
$services['Border'] = array(
'border_manager' => array(
'type' => 'Border\\BorderManager',
'options' => array(
'enabled' => true,
'checkers' => array(
array(
'type' => 'Checker\\Sha256',
'enabled' => true,
),
array(
'type' => 'Checker\\UUID',
'enabled' => true,
),
array(
'type' => 'Checker\\Colorspace',
'enabled' => false,
'options' => array(
'colorspaces' => array(
Checker\Colorspace::COLORSPACE_CMYK,
Checker\Colorspace::COLORSPACE_GRAYSCALE,
Checker\Colorspace::COLORSPACE_RGB,
)
),
),
array(
'type' => 'Checker\\Dimension',
'enabled' => false,
'options' => array(
'width' => 80,
'height' => 80,
),
),
array(
'type' => 'Checker\\Extension',
'enabled' => false,
'options' => array(
),
),
array(
'type' => 'Checker\\Filename',
'enabled' => false,
'options' => array(
'sensitive' => true,
),
),
array(
'type' => 'Checker\\MediaType',
'enabled' => false,
'options' => array(
'mediatypes' => array(
Checker\MediaType::TYPE_AUDIO,
Checker\MediaType::TYPE_DOCUMENT,
Checker\MediaType::TYPE_FLASH,
Checker\MediaType::TYPE_IMAGE,
Checker\MediaType::TYPE_VIDEO,
)
),
)
)
)
)
);
}
$app['phraseanet.configuration']->setServices($services);
$configs = $app['phraseanet.configuration']->getConfigurations();
foreach (array('prod', 'dev', 'test') as $env) {
if (isset($configs[$env])
&& is_array($configs[$env])
&& ! isset($configs[$env]['border-manager'])) {
$configs[$env]['border-manager'] = 'border_manager';
}
}
$app['phraseanet.configuration']->setConfigurations($configs);
return true;
}
}

View File

@@ -10,7 +10,6 @@
*/
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration;
/**
*
@@ -103,7 +102,8 @@ class patch_373 implements patchInterface
$stmt->closeCursor();
$app['phraseanet.configuration']->setBinaries(array('binaries' => $binaries));
$config = $app['phraseanet.configuration']->getConfig();
$config['binaries'] = $binaries;
$sql = 'DELETE FROM registry WHERE `key` = :key';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
@@ -120,9 +120,9 @@ class patch_373 implements patchInterface
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$configs = $app['phraseanet.configuration']->getConfigurations();
$configs['key'] = $row['value'];
$app['phraseanet.configuration']->setConfigurations($configs);
$config['main']['key'] = $row['value'];
$app['phraseanet.configuration']->setConfig($config);
$sql = 'DELETE FROM registry WHERE `key` = :key';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);

View File

@@ -59,12 +59,12 @@ class patch_380 implements patchInterface
*/
public function apply(base $databox, Application $app)
{
$connexions = $app['phraseanet.configuration']->getConnexions();
$config = $app['phraseanet.configuration']->getConfig();
if (isset($connexions['test_connexion'])) {
$connexions['test_connexion']['path'] = '/tmp/db.sqlite';
if (isset($config['main']['database-test'])) {
$config['main']['database-test']['path'] = '/tmp/db.sqlite';
}
$app['phraseanet.configuration']->setConnexions($connexions);
$app['phraseanet.configuration']->setConfig($config);
}
}

View File

@@ -60,58 +60,7 @@ class patch_3803 implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
$searchEngine = $app['phraseanet.registry']->get('GV_sphinx') ? 'sphinxsearch' : 'phrasea';
$confs = $app['phraseanet.configuration']->getConfigurations();
foreach ($confs as $env => $conf) {
if (in_array($env, array('environment', 'key'))) {
continue;
}
if (!isset($conf['search-engine'])) {
$confs[$env]['search-engine'] = $searchEngine;
}
}
$app['phraseanet.configuration']->setConfigurations($confs);
$services = $app['phraseanet.configuration']->getServices();
if (!isset($services['SearchEngine'])) {
$app['phraseanet.configuration']->resetServices('SearchEngine');
}
if (!$app['phraseanet.registry']->get('GV_sphinx')) {
$phraseaConfiguration = $app['phraseanet.SE']->getConfigurationPanel()->getConfiguration();
if ($app['phraseanet.registry']->get('GV_phrasea_sort')) {
$phraseaConfiguration['default_sort'] = $app['phraseanet.registry']->get('GV_phrasea_sort');
}
$app['phraseanet.SE']->getConfigurationPanel()->saveConfiguration($phraseaConfiguration);
} else {
$sphinxConfiguration = $app['phraseanet.SE']->getConfigurationPanel()->getConfiguration();
if ($app['phraseanet.registry']->get('GV_sphinx_rt_port')) {
$sphinxConfiguration['rt_port'] = $app['phraseanet.registry']->get('GV_sphinx_rt_port');
}
if ($app['phraseanet.registry']->get('GV_sphinx_rt_host')) {
$sphinxConfiguration['rt_host'] = $app['phraseanet.registry']->get('GV_sphinx_rt_host');
}
if ($app['phraseanet.registry']->get('GV_sphinx_port')) {
$sphinxConfiguration['port'] = $app['phraseanet.registry']->get('GV_sphinx_port');
}
if ($app['phraseanet.registry']->get('GV_sphinx_host')) {
$sphinxConfiguration['host'] = $app['phraseanet.registry']->get('GV_sphinx_host');
}
$app['phraseanet.SE']->getConfigurationPanel()->saveConfiguration($sphinxConfiguration);
}
$app['phraseanet.configuration']->setDefault('main', 'search-engine');
return true;
}

View File

@@ -54,31 +54,8 @@ class patch_3804 implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
try {
$confs = $app['phraseanet.configuration']->getConfigurations();
$app['phraseanet.configuration']->setDefault('main', 'task-manager');
foreach ($confs as $env => $conf) {
if (in_array($env, array('environment', 'key'))) {
continue;
}
if (!isset($conf['task-manager'])) {
$confs[$env]['task-manager'] = 'task_manager';
}
}
$app['phraseanet.configuration']->setConfigurations($confs);
$services = $app['phraseanet.configuration']->getServices();
if (!isset($services['TaskManager'])) {
$app['phraseanet.configuration']->resetServices('TaskManager');
}
return true;
} catch (\Exception $e) {
throw $e;
}
return false;
return true;
}
}

View File

@@ -10,7 +10,6 @@
*/
use Alchemy\Phrasea\Application;
use Symfony\Component\Yaml\Yaml;
class patch_3806 implements patchInterface
{
@@ -49,29 +48,7 @@ class patch_3806 implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
$parser = new Yaml();
$data = $parser->parse(file_get_contents(__DIR__ . '/../../conf.d/config.yml'));
$fields = $data['prod']['registration-fields'];
$authentication = $data['prod']['authentication'];
$confs = $app['phraseanet.configuration']->getConfigurations();
foreach ($confs as $env => $conf) {
if (in_array($env, array('environment', 'key'))) {
continue;
}
if (!isset($conf['registration-fields'])) {
$confs[$env]['registration-fields'] = $fields;
}
if (!isset($conf['authentication'])) {
$confs[$env]['authentication'] = $authentication;
}
}
$app['phraseanet.configuration']->setConfigurations($confs);
$app['phraseanet.configuration']->setDefault('registration-fields');
$app['phraseanet.configuration']->setDefault('authentication');
}
}

147
lib/classes/patch/3807.php Normal file
View File

@@ -0,0 +1,147 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
use Symfony\Component\Yaml\Yaml;
class patch_3807 implements patchInterface
{
/** @var string */
private $release = '3.8.0.a7';
/** @var array */
private $concern = array(base::APPLICATION_BOX);
private $yaml;
private $connexionsYaml;
private $binariesYaml;
private $servicesYaml;
private $configYaml;
/**
* {@inheritdoc}
*/
public function get_release()
{
return $this->release;
}
/**
* {@inheritdoc}
*/
public function require_all_upgrades()
{
return true;
}
/**
* {@inheritdoc}
*/
public function concern()
{
return $this->concern;
}
/**
* {@inheritdoc}
*/
public function apply(base $appbox, Application $app)
{
$this->yaml = new Yaml();
$this->connexionsYaml = $app['root.path'] . '/config/connexions.yml';
$this->binariesYaml = $app['root.path'] . '/config/binaries.yml';
$this->servicesYaml = $app['root.path'] . '/config/services.yml';
$this->configYaml = $app['root.path'] . '/config/config.yml';
$this->migrate($app);
return true;
}
private function migrate($app)
{
$conf = $app['phraseanet.configuration']->getConfig();
$this->migrateConnexions($conf);
$this->migrateConfigAndServices($conf);
$this->migrateBinaries($conf);
$app['phraseanet.configuration']->setConfig($conf);
foreach (array(
$this->configYaml,
$this->connexionsYaml,
$this->binariesYaml,
$this->servicesYaml
) as $file) {
if (is_file($file)) {
rename($file, $file.'.bkp');
}
}
}
private function migrateBinaries(array &$conf)
{
if (is_file($this->binariesYaml)) {
$binaries = $this->yaml->parse($this->binariesYaml);
foreach ($binaries['binaries'] as $key => $value) {
$conf['binaries'][$key] = $value;
}
}
}
private function migrateConfigAndServices(array &$conf)
{
$opcodeCacheService = $cacheService = null;
if (is_file($this->configYaml)) {
$data = $this->yaml->parse($this->configYaml);
$conf['main']['key'] = $data['key'];
$env = $data['environment'];
if (isset($data[$env])) {
$conf['main']['servername'] = $data[$env]['phraseanet']['servername'];
$conf['main']['maintenance'] = $data[$env]['phraseanet']['maintenance'];
$opcodeCacheService = $data[$env]['opcodecache'];
$cacheService = $data[$env]['cache'];
}
}
if (is_file($this->servicesYaml)) {
$services = $this->yaml->parse($this->servicesYaml);
if (null !== $opcodeCacheService) {
$conf['main']['opcodecache']['type'] = str_replace('Cache\\', '', $services['Cache'][$opcodeCacheService]['type']);
if (isset($services['Cache'][$opcodeCacheService]['options'])) {
$conf['main']['opcodecache']['options'] = $services['Cache'][$opcodeCacheService]['options'];
} else {
$conf['main']['opcodecache']['options'] = array();
}
}
if (null !== $cacheService) {
$conf['main']['cache']['type'] = str_replace('Cache\\', '', $services['Cache'][$cacheService]['type']);
if (isset($services['Cache'][$cacheService]['options'])) {
$conf['main']['cache']['options'] = $services['Cache'][$cacheService]['options'];
} else {
$conf['main']['cache']['options'] = array();
}
}
$conf['border-manager'] = $services['Border']['border_manager']['options'];
}
}
private function migrateConnexions(array &$conf)
{
$data = $this->yaml->parse($this->connexionsYaml);
$conf['main']['database'] = $data['main_connexion'];
$conf['main']['database-test'] = $data['test_connexion'];
}
}