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:
@@ -38,6 +38,11 @@ return call_user_func(function() {
|
|||||||
|
|
||||||
$app['upgrade'] = true;
|
$app['upgrade'] = true;
|
||||||
} elseif (\setup::needUpgradeConfigurationFile()) {
|
} elseif (\setup::needUpgradeConfigurationFile()) {
|
||||||
|
|
||||||
|
if (\setup::requireGVUpgrade()) {
|
||||||
|
setup::upgradeGV($app['phraseanet.core']['Registry']);
|
||||||
|
}
|
||||||
|
|
||||||
$connexionInc = new \SplFileInfo(__DIR__ . '/../../../../config/connexion.inc');
|
$connexionInc = new \SplFileInfo(__DIR__ . '/../../../../config/connexion.inc');
|
||||||
$configInc = new \SplFileInfo(__DIR__ . '/../../../../config/config.inc');
|
$configInc = new \SplFileInfo(__DIR__ . '/../../../../config/config.inc');
|
||||||
|
|
||||||
|
@@ -45,14 +45,11 @@ class module_console_systemUpgrade extends Command
|
|||||||
{
|
{
|
||||||
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
|
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');
|
$interactive = !$input->getOption('yes');
|
||||||
|
|
||||||
$Core = \bootstrap::getCore();
|
$Core = \bootstrap::getCore();
|
||||||
|
|
||||||
if (!$Core->getConfiguration()->isInstalled() && file_exists($old_config_file) && file_exists($old_connexion_file)) {
|
if (!$Core->getConfiguration()->isInstalled() && \setup::needUpgradeConfigurationFile()) {
|
||||||
|
|
||||||
if ($interactive) {
|
if ($interactive) {
|
||||||
$output->writeln('This version of Phraseanet requires a config/config.yml, config/connexion.yml, config/service.yml');
|
$output->writeln('This version of Phraseanet requires a config/config.yml, config/connexion.yml, config/service.yml');
|
||||||
@@ -68,8 +65,12 @@ class module_console_systemUpgrade extends Command
|
|||||||
|
|
||||||
if ($continue == 'y') {
|
if ($continue == 'y') {
|
||||||
try {
|
try {
|
||||||
$connexionInc = new \SplFileInfo($old_connexion_file);
|
if (\setup::requireGVUpgrade()) {
|
||||||
$configInc = new \SplFileInfo($old_config_file);
|
setup::upgradeGV($Core['Registry']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$connexionInc = new \SplFileInfo(__DIR__ . '/../../../../config/connexion.inc');
|
||||||
|
$configInc = new \SplFileInfo(__DIR__ . '/../../../../config/config.inc');
|
||||||
|
|
||||||
$Core->getConfiguration()->upgradeFromOldConf($configInc, $connexionInc);
|
$Core->getConfiguration()->upgradeFromOldConf($configInc, $connexionInc);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@@ -53,8 +53,12 @@ class patch_320aa implements patchInterface
|
|||||||
|
|
||||||
public function apply(base &$appbox)
|
public function apply(base &$appbox)
|
||||||
{
|
{
|
||||||
if (is_file(__DIR__ . '/../../../config/_GV.php'))
|
if (is_file(__DIR__ . '/../../../config/_GV.php')) {
|
||||||
require __DIR__ . '/../../../config/_GV.php';
|
require __DIR__ . '/../../../config/_GV.php';
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
require __DIR__ . '/../../../lib/conf.d/_GV_template.inc';
|
require __DIR__ . '/../../../lib/conf.d/_GV_template.inc';
|
||||||
|
|
||||||
define('GV_STATIC_URL', '');
|
define('GV_STATIC_URL', '');
|
||||||
|
@@ -80,7 +80,68 @@ class setup
|
|||||||
public static function needUpgradeConfigurationFile()
|
public static function needUpgradeConfigurationFile()
|
||||||
{
|
{
|
||||||
return (is_file(__DIR__ . "/../../config/connexion.inc")
|
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())
|
public function create_global_values(registryInterface &$registry, $datas = array())
|
||||||
@@ -120,16 +181,16 @@ class setup
|
|||||||
$datas[$variable['name']] = (string) trim($datas[$variable['name']]);
|
$datas[$variable['name']] = (string) trim($datas[$variable['name']]);
|
||||||
break;
|
break;
|
||||||
case 'enum':
|
case 'enum':
|
||||||
if ( ! isset($variable['available'])) {
|
if (!isset($variable['available'])) {
|
||||||
$variable['error'] = 'avalaibility';
|
$variable['error'] = 'avalaibility';
|
||||||
} elseif ( ! is_array($variable['available'])) {
|
} elseif (!is_array($variable['available'])) {
|
||||||
$variable['error'] = 'avalaibility';
|
$variable['error'] = 'avalaibility';
|
||||||
} elseif ( ! in_array($datas[$variable['name']], $variable['available'])) {
|
} elseif (!in_array($datas[$variable['name']], $variable['available'])) {
|
||||||
$variable['error'] = 'avalaibility';
|
$variable['error'] = 'avalaibility';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'enum_multi':
|
case 'enum_multi':
|
||||||
if ( ! isset($datas[$variable['name']]))
|
if (!isset($datas[$variable['name']]))
|
||||||
$datas[$variable['name']] = null;
|
$datas[$variable['name']] = null;
|
||||||
$datas[$variable['name']] = ($datas[$variable['name']]);
|
$datas[$variable['name']] = ($datas[$variable['name']]);
|
||||||
$type = 'array';
|
$type = 'array';
|
||||||
@@ -210,7 +271,7 @@ class setup
|
|||||||
$constraints = array();
|
$constraints = array();
|
||||||
|
|
||||||
foreach ($binaries as $name => $binary) {
|
foreach ($binaries as $name => $binary) {
|
||||||
if (trim($binary) == '' || ( ! is_file($binary))) {
|
if (trim($binary) == '' || (!is_file($binary))) {
|
||||||
$constraints[] = new Setup_Constraint(
|
$constraints[] = new Setup_Constraint(
|
||||||
$name
|
$name
|
||||||
, false
|
, false
|
||||||
@@ -218,7 +279,7 @@ class setup
|
|||||||
, false
|
, false
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if ( ! is_executable($binary)) {
|
if (!is_executable($binary)) {
|
||||||
$constraints[] = new Setup_Constraint(
|
$constraints[] = new Setup_Constraint(
|
||||||
$name
|
$name
|
||||||
, false
|
, false
|
||||||
@@ -465,7 +526,7 @@ class setup
|
|||||||
$constraints = array();
|
$constraints = array();
|
||||||
|
|
||||||
foreach ($pathes as $p) {
|
foreach ($pathes as $p) {
|
||||||
if ( ! is_writable($p)) {
|
if (!is_writable($p)) {
|
||||||
$message = sprintf('%s not writeable', $p);
|
$message = sprintf('%s not writeable', $p);
|
||||||
} else {
|
} else {
|
||||||
$message = sprintf('%s OK', $p);
|
$message = sprintf('%s OK', $p);
|
||||||
@@ -490,7 +551,6 @@ class setup
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,7 +560,7 @@ class setup
|
|||||||
public static function check_php_version()
|
public static function check_php_version()
|
||||||
{
|
{
|
||||||
$version_ok = version_compare(PHP_VERSION, '5.3.3', '>');
|
$version_ok = version_compare(PHP_VERSION, '5.3.3', '>');
|
||||||
if ( ! $version_ok) {
|
if (!$version_ok) {
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
'Wrong PHP version : % ; PHP >= 5.3.3 required'
|
'Wrong PHP version : % ; PHP >= 5.3.3 required'
|
||||||
, PHP_VERSION
|
, PHP_VERSION
|
||||||
@@ -589,7 +649,7 @@ class setup
|
|||||||
foreach ($availables as $ext) {
|
foreach ($availables as $ext) {
|
||||||
if (extension_loaded($ext) === true) {
|
if (extension_loaded($ext) === true) {
|
||||||
$constraints[] = new Setup_Constraint($ext, true, sprintf('%s loaded', $ext), false);
|
$constraints[] = new Setup_Constraint($ext, true, sprintf('%s loaded', $ext), false);
|
||||||
$found ++;
|
$found++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -636,14 +696,14 @@ class setup
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($memoryFound >= $memoryRequired) {
|
if ($memoryFound >= $memoryRequired) {
|
||||||
$constraints[] = new Setup_Constraint($conf, true, sprintf('%s = `%s` => OK', $conf, $value), ! in_array($conf, $nonblockers));
|
$constraints[] = new Setup_Constraint($conf, true, sprintf('%s = `%s` => OK', $conf, $value), !in_array($conf, $nonblockers));
|
||||||
} else {
|
} else {
|
||||||
$constraints[] = new Setup_Constraint($conf, false, sprintf('Bad configuration for %1$s, found `%2$s`, required `%3$s`', $conf, $tmp, $value), ! in_array($conf, $nonblockers));
|
$constraints[] = new Setup_Constraint($conf, false, sprintf('Bad configuration for %1$s, found `%2$s`, required `%3$s`', $conf, $tmp, $value), !in_array($conf, $nonblockers));
|
||||||
}
|
}
|
||||||
} elseif (($tmp = self::test_php_conf($conf, $value)) !== $value) {
|
} elseif (($tmp = self::test_php_conf($conf, $value)) !== $value) {
|
||||||
$constraints[] = new Setup_Constraint($conf, false, sprintf('Bad configuration for %1$s, found `%2$s`, required `%3$s`', $conf, $tmp, $value), ! in_array($conf, $nonblockers));
|
$constraints[] = new Setup_Constraint($conf, false, sprintf('Bad configuration for %1$s, found `%2$s`, required `%3$s`', $conf, $tmp, $value), !in_array($conf, $nonblockers));
|
||||||
} else {
|
} else {
|
||||||
$constraints[] = new Setup_Constraint($conf, true, sprintf('%s = `%s` => OK', $conf, $value), ! in_array($conf, $nonblockers));
|
$constraints[] = new Setup_Constraint($conf, true, sprintf('%s = `%s` => OK', $conf, $value), !in_array($conf, $nonblockers));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -681,7 +741,7 @@ class setup
|
|||||||
{
|
{
|
||||||
$constraints = array();
|
$constraints = array();
|
||||||
|
|
||||||
if ( ! extension_loaded('gettext')) {
|
if (!extension_loaded('gettext')) {
|
||||||
return new Setup_ConstraintsIterator($constraints);
|
return new Setup_ConstraintsIterator($constraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -727,7 +787,7 @@ class setup
|
|||||||
{
|
{
|
||||||
$structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml");
|
$structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml");
|
||||||
|
|
||||||
if ( ! $structure) {
|
if (!$structure) {
|
||||||
throw new Exception('Unable to load schema');
|
throw new Exception('Unable to load schema');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user