mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Fix #901 : allow upgrade from Phraseanet 3.1
This commit is contained in:
@@ -39,6 +39,11 @@ return call_user_func(function() {
|
||||
|
||||
$app['upgrade'] = true;
|
||||
} elseif (\setup::needUpgradeConfigurationFile()) {
|
||||
|
||||
if (\setup::requireGVUpgrade()) {
|
||||
setup::upgradeGV($app['phraseanet.core']['Registry']);
|
||||
}
|
||||
|
||||
$connexionInc = new \SplFileInfo(__DIR__ . '/../../../../config/connexion.inc');
|
||||
$configInc = new \SplFileInfo(__DIR__ . '/../../../../config/config.inc');
|
||||
|
||||
|
@@ -45,13 +45,10 @@ class module_console_systemUpgrade extends Command
|
||||
{
|
||||
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
|
||||
|
||||
$old_connexion_file = __DIR__ . '/../../../../config/connexion.inc';
|
||||
$old_config_file = __DIR__ . '/../../../../config/config.inc';
|
||||
|
||||
$interactive = !$input->getOption('yes');
|
||||
$Core = $this->getService('phraseanet.core');
|
||||
|
||||
if (!$Core->getConfiguration()->isInstalled() && file_exists($old_config_file) && file_exists($old_connexion_file)) {
|
||||
if (!$Core->getConfiguration()->isInstalled() && \setup::needUpgradeConfigurationFile()) {
|
||||
|
||||
if ($interactive) {
|
||||
$output->writeln('This version of Phraseanet requires a config/config.yml, config/connexion.yml, config/service.yml');
|
||||
@@ -67,8 +64,12 @@ class module_console_systemUpgrade extends Command
|
||||
|
||||
if ($continue == 'y') {
|
||||
try {
|
||||
$connexionInc = new \SplFileInfo($old_connexion_file);
|
||||
$configInc = new \SplFileInfo($old_config_file);
|
||||
if (\setup::requireGVUpgrade()) {
|
||||
setup::upgradeGV($Core['Registry']);
|
||||
}
|
||||
|
||||
$connexionInc = new \SplFileInfo(__DIR__ . '/../../../../config/connexion.inc');
|
||||
$configInc = new \SplFileInfo(__DIR__ . '/../../../../config/config.inc');
|
||||
|
||||
$Core->getConfiguration()->upgradeFromOldConf($configInc, $connexionInc);
|
||||
} catch (\Exception $e) {
|
||||
|
@@ -53,8 +53,12 @@ class patch_320aa implements patchInterface
|
||||
|
||||
public function apply(base &$appbox)
|
||||
{
|
||||
if (is_file(__DIR__ . '/../../../config/_GV.php'))
|
||||
if (is_file(__DIR__ . '/../../../config/_GV.php')) {
|
||||
require __DIR__ . '/../../../config/_GV.php';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../../lib/conf.d/_GV_template.inc';
|
||||
|
||||
define('GV_STATIC_URL', '');
|
||||
|
@@ -80,7 +80,68 @@ class setup
|
||||
public static function needUpgradeConfigurationFile()
|
||||
{
|
||||
return (is_file(__DIR__ . "/../../config/connexion.inc")
|
||||
&& is_file(__DIR__ . "/../../config/config.inc"));
|
||||
&& is_file(__DIR__ . "/../../config/config.inc") ||
|
||||
self::requireGVUpgrade());
|
||||
}
|
||||
|
||||
public static function requireGVUpgrade()
|
||||
{
|
||||
return is_file(__DIR__ . "/../../config/connexion.inc")
|
||||
&& is_file(__DIR__ . "/../../config/_GV.php")
|
||||
&& !is_file(__DIR__ . "/../../config/config.inc");
|
||||
}
|
||||
|
||||
public static function upgradeGV(registryInterface $registry)
|
||||
{
|
||||
$GV = array();
|
||||
if (is_file(__DIR__ . '/../../config/_GV.php')) {
|
||||
require __DIR__ . '/../../config/_GV.php';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../lib/conf.d/_GV_template.inc';
|
||||
|
||||
define('GV_STATIC_URL', '');
|
||||
define('GV_sphinx', false);
|
||||
define('GV_sphinx_host', '');
|
||||
define('GV_sphinx_port', '');
|
||||
define('GV_sphinx_rt_host', '');
|
||||
define('GV_sphinx_rt_port', '');
|
||||
|
||||
foreach ($GV as $section => $datas_section) {
|
||||
foreach ($datas_section['vars'] as $datas) {
|
||||
|
||||
$registry->un_set($datas['name']);
|
||||
eval('$test = defined("' . $datas["name"] . '");');
|
||||
if (!$test) {
|
||||
continue;
|
||||
}
|
||||
eval('$val = ' . $datas["name"] . ';');
|
||||
|
||||
$val = $val === true ? '1' : $val;
|
||||
$val = $val === false ? '0' : $val;
|
||||
|
||||
switch ($datas['type']) {
|
||||
case registry::TYPE_ENUM_MULTI:
|
||||
case registry::TYPE_INTEGER:
|
||||
case registry::TYPE_BOOLEAN:
|
||||
case registry::TYPE_STRING:
|
||||
case registry::TYPE_ARRAY:
|
||||
$type = $datas['type'];
|
||||
break;
|
||||
default:
|
||||
$type = registry::TYPE_STRING;
|
||||
break;
|
||||
}
|
||||
$registry->set($datas['name'], $val, $type);
|
||||
}
|
||||
}
|
||||
$registry->un_set('registry_loaded');
|
||||
|
||||
rename(__DIR__ . '/../../config/_GV.php', __DIR__ . '/../../config/_GV.php.old');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function create_global_values(registryInterface &$registry, $datas = array())
|
||||
|
Reference in New Issue
Block a user