fix #396 incorrect pdo_sqlite path

This commit is contained in:
Nicolas Le Goff
2012-02-16 12:49:43 +01:00
parent 273d29ab3e
commit 97dcb9b301
5 changed files with 329 additions and 326 deletions

View File

@@ -24,187 +24,185 @@ require_once __DIR__ . '/../../../bootstrap.php';
* @link www.phraseanet.com
*/
return call_user_func(function()
{
$app = new \Silex\Application();
{
$app = new \Silex\Application();
$app['Core'] = \bootstrap::getCore();
$app['Core'] = \bootstrap::getCore();
$app['install'] = false;
$app['upgrade'] = false;
$app['install'] = false;
$app['upgrade'] = false;
$app->before(function($a) use ($app)
{
if (\setup::is_installed())
{
$appbox = \appbox::get_instance();
$app->before(function($a) use ($app)
{
if (\setup::is_installed())
{
$appbox = \appbox::get_instance();
if (!$appbox->need_major_upgrade())
{
throw new \Exception_Setup_PhraseaAlreadyInstalled();
}
if (!$appbox->need_major_upgrade())
{
throw new \Exception_Setup_PhraseaAlreadyInstalled();
}
$app['upgrade'] = true;
}
elseif (\setup::needUpgradeConfigurationFile())
{
$registry = \registry::get_instance();
$app['upgrade'] = true;
}
elseif (\setup::needUpgradeConfigurationFile())
{
$registry = \registry::get_instance();
//copy config sample
$configSampleFile = __DIR__ . "/../../../../config/config.sample.yml";
$configFile = __DIR__ . "/../../../../config/config.yml";
//copy config sample
$configSampleFile = __DIR__ . "/../../../../config/config.sample.yml";
$configFile = __DIR__ . "/../../../../config/config.yml";
if (!copy($configSampleFile, $configFile))
{
throw new \Exception(sprintf("Unable to copy %s", $configSampleFile));
}
if (!copy($configSampleFile, $configFile))
{
throw new \Exception(sprintf("Unable to copy %s", $configSampleFile));
}
//copy service sample
$serviceSampleFile = __DIR__ . "/../../../../config/services.sample.yml";
$serviceFile = __DIR__ . "/../../../../config/services.yml";
//copy service sample
$serviceSampleFile = __DIR__ . "/../../../../config/services.sample.yml";
$serviceFile = __DIR__ . "/../../../../config/services.yml";
if (!copy($serviceSampleFile, $serviceFile))
{
throw new \Exception(sprintf("Unable to copy %s", $serviceSampleFile));
}
if (!copy($serviceSampleFile, $serviceFile))
{
throw new \Exception(sprintf("Unable to copy %s", $serviceSampleFile));
}
//copy connexion sample
$connexionSampleFile = __DIR__ . "/../../../../config/connexions.sample.yml";
$connexionFile = __DIR__ . "/../../../../config/connexions.yml";
//copy connexion sample
$connexionSampleFile = __DIR__ . "/../../../../config/connexions.sample.yml";
$connexionFile = __DIR__ . "/../../../../config/connexions.yml";
if (!copy($connexionSampleFile, $connexionFile))
{
throw new \Exception(sprintf("Unable to copy %s", $connexionFile));
}
if (!copy($connexionSampleFile, $connexionFile))
{
throw new \Exception(sprintf("Unable to copy %s", $connexionFile));
}
//get configuration object
$appConf = new \Alchemy\Phrasea\Core\Configuration\Application();
$parser = new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml();
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler($appConf, $parser);
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
//get configuration object
$appConf = new \Alchemy\Phrasea\Core\Configuration\Application();
$parser = new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml();
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler($appConf, $parser);
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
//refactor credentials
$connexionINI = array();
//refactor credentials
$connexionINI = array();
require __DIR__ . "/../../../../config/connexion.inc";
require __DIR__ . "/../../../../config/connexion.inc";
$connexionINI['host'] = $hostname;
$connexionINI['port'] = $port;
$connexionINI['user'] = $user;
$connexionINI['password'] = $password;
$connexionINI['dbname'] = $dbname;
$connexionINI['driver'] = 'pdo_mysql';
$connexionINI['charset'] = 'UTF8';
$connexionINI['host'] = $hostname;
$connexionINI['port'] = $port;
$connexionINI['user'] = $user;
$connexionINI['password'] = $password;
$connexionINI['dbname'] = $dbname;
$connexionINI['driver'] = 'pdo_mysql';
$connexionINI['charset'] = 'UTF8';
$request = $app["request"];
//write servername
$serverName = $request->getScheme() . '://' . $request->getHttpHost() . '/';
$request = $app["request"];
//write servername
$serverName = $request->getScheme() . '://' . $request->getHttpHost() . '/';
//write credentials to connexion file
$connexionFile = $appConf->getConnexionFile();
//write credentials to connexion file
$connexionFile = $appConf->getConnexionFile();
$connexion = array(
'main_connexion' => $connexionINI,
'test_connexion' => array(
'driver' => 'pdo_sqlite',
'path' => realpath($registry->get("GV_RootPath") . 'lib/unitTest/tests.sqlite'),
'charset' => 'UTF8'
));
$connexion = array(
'main_connexion' => $connexionINI,
'test_connexion' => array(
'driver' => 'pdo_sqlite',
'path' => realpath(__DIR__ . '/../../../unitTest') . '/tests.sqlite',
'charset' => 'UTF8'
));
$yaml = $configuration->getConfigurationHandler()->getParser()->dump($connexion, 2);
$yaml = $configuration->getConfigurationHandler()->getParser()->dump($connexion, 2);
if (!file_put_contents($connexionFile->getPathname(), $yaml) !== false)
{
throw new \Exception(sprintf(_('Impossible d\'ecrire dans le fichier %s'), $connexionFile->getPathname()));
}
if (!file_put_contents($connexionFile->getPathname(), $yaml) !== false)
{
throw new \Exception(sprintf(_('Impossible d\'ecrire dans le fichier %s'), $connexionFile->getPathname()));
}
$cacheService = "array_cache";
$cacheService = "array_cache";
if (extension_loaded('apc'))
{
$cacheService = "apc_cache";
}
elseif (extension_loaded('xcache'))
{
$cacheService = "xcache_cache";
}
if (extension_loaded('apc'))
{
$cacheService = "apc_cache";
}
elseif (extension_loaded('xcache'))
{
$cacheService = "xcache_cache";
}
//rewrite service file
$serviceFile = $appConf->getServiceFile();
$services = $configuration->getConfigurationHandler()->getParser()->parse($serviceFile);
//rewrite service file
$serviceFile = $appConf->getServiceFile();
$services = $configuration->getConfigurationHandler()->getParser()->parse($serviceFile);
foreach ($services as $serviceName => $service)
{
if ($serviceName === "doctrine_prod")
{
foreach ($services as $serviceName => $service)
{
if ($serviceName === "doctrine_prod")
{
$services["doctrine_prod"]["options"]["orm"]["cache"] = array(
"query" => $cacheService,
"result" => $cacheService,
"metadata" => $cacheService
);
}
}
$yaml = $configuration->getConfigurationHandler()->getParser()->dump($services, 5);
$services["doctrine_prod"]["options"]["orm"]["cache"] = array(
"query" => $cacheService,
"result" => $cacheService,
"metadata" => $cacheService
);
}
}
$yaml = $configuration->getConfigurationHandler()->getParser()->dump($services, 5);
if (!file_put_contents($serviceFile->getPathname(), $yaml) !== false)
{
throw new \Exception(sprintf(_('Impossible d\'ecrire dans le fichier %s'), $serviceFile->getPathname()));
}
$arrayConf = $configuration->all();
if (!file_put_contents($serviceFile->getPathname(), $yaml) !== false)
{
throw new \Exception(sprintf(_('Impossible d\'ecrire dans le fichier %s'), $serviceFile->getPathname()));
}
$arrayConf = $configuration->all();
//rewrite main conf
foreach ($arrayConf as $key => $value)
{
if (is_array($value) && array_key_exists('phraseanet', $value))
{
$arrayConf[$key]["phraseanet"]["servername"] = $serverName;
}
//rewrite main conf
foreach ($arrayConf as $key => $value)
{
if (is_array($value) && array_key_exists('phraseanet', $value))
{
$arrayConf[$key]["phraseanet"]["servername"] = $serverName;
}
if (is_array($value) && $key === 'prod')
{
$arrayConf[$key]["cache"] = $cacheService;
}
}
if (is_array($value) && $key === 'prod')
{
$arrayConf[$key]["cache"] = $cacheService;
}
}
$configuration->write($arrayConf);
$configuration->write($arrayConf);
$app['install'] = true;
$app['install'] = true;
// $app->redirect("/setup/installer/");
}
else
{
$app['install'] = true;
}
}
else
{
$app['install'] = true;
}
return;
});
return;
});
$app->get('/', function() use ($app)
{
if ($app['install'] === true)
return $app->redirect('/setup/installer/');
if ($app['upgrade'] === true)
return $app->redirect('/setup/upgrader/');
});
$app->get('/', function() use ($app)
{
if ($app['install'] === true)
return $app->redirect('/setup/installer/');
if ($app['upgrade'] === true)
return $app->redirect('/setup/upgrader/');
});
$app->mount('/installer/', new Controller\Installer());
$app->mount('/upgrader/', new Controller\Upgrader());
$app->mount('/test', new ControllerUtils\PathFileTest());
$app->mount('/connection_test', new ControllerUtils\ConnectionTest());
$app->mount('/installer/', new Controller\Installer());
$app->mount('/upgrader/', new Controller\Upgrader());
$app->mount('/test', new ControllerUtils\PathFileTest());
$app->mount('/connection_test', new ControllerUtils\ConnectionTest());
$app->error(function($e) use ($app)
{
if ($e instanceof \Exception_Setup_PhraseaAlreadyInstalled)
{
return $app->redirect('/login/');
}
$app->error(function($e) use ($app)
{
if ($e instanceof \Exception_Setup_PhraseaAlreadyInstalled)
{
return $app->redirect('/login/');
}
return new Response('Internal Server Error', 500);
});
return new Response('Internal Server Error', 500);
});
return $app;
});
return $app;
});

View File

@@ -38,7 +38,7 @@ class Root implements ControllerProviderInterface
$controllers = new ControllerCollection();
$controllers->get('/', function(Application $app)
$controllers->get('/', function(Application $app, Request $request)
{
$Core = $app['Core'];
@@ -47,7 +47,7 @@ class Root implements ControllerProviderInterface
\User_Adapter::updateClientInfos(3);
$section = $app['request']->get('section', false);
$section = $request->get('section', false);
$available = array(
'connected'
@@ -98,6 +98,7 @@ class Root implements ControllerProviderInterface
'module' => 'admin'
, 'events' => \eventsmanager_broker::getInstance($appbox, $Core)
, 'module_name' => 'Admin'
, 'notice' => $request->get("notice")
, 'feature' => $feature
, 'featured' => $featured
, 'databoxes' => $databoxes

View File

@@ -315,7 +315,7 @@ class Installer implements ControllerProviderInterface
$appbox->get_session()->authenticate($auth);
$redirection = '/admin/index.php?section=taskmanager&notice=install_success';
$redirection = '/admin/?section=taskmanager&notice=install_success';
return $app->redirect($redirection);
}

View File

@@ -138,12 +138,10 @@ class appbox extends base
$custom_path.= $collection->get_base_id();
if (is_null($pathfile))
return $this;
$datas = file_get_contents($pathfile->getPathname());
if (is_null($datas))
return $this;
file_put_contents($file, $datas);
@@ -195,12 +193,10 @@ class appbox extends base
$custom_path.= $pic_type . '_' . $databox->get_sbas_id();
if (is_null($pathfile))
return $this;
$datas = file_get_contents($pathfile->getPathname());
if (is_null($datas))
return $this;
file_put_contents($file, $datas);
@@ -492,7 +488,7 @@ class appbox extends base
'main_connexion' => $connexionINI,
'test_connexion' => array(
'driver' => 'pdo_sqlite',
'path' => realpath($root . 'lib/unitTest/tests.sqlite'),
'path' => realpath($root . 'lib/unitTest') . '/tests.sqlite',
'charset' => 'UTF8'
));
@@ -575,7 +571,7 @@ class appbox extends base
}
catch (Exception $e)
{
}
try
@@ -612,7 +608,6 @@ class appbox extends base
public function get_databoxes()
{
if ($this->databoxes)
return $this->databoxes;
$ret = array();
@@ -624,7 +619,7 @@ class appbox extends base
}
catch (Exception $e)
{
}
}
@@ -641,7 +636,7 @@ class appbox extends base
}
catch (Exception $e)
{
}
$sql = 'SELECT sbas_id FROM sbas';

View File

@@ -8,205 +8,214 @@
{% endblock %}
{% block stylesheet %}
<link type="text/css" rel="stylesheet" href="/include/minify/f=include/jslibs/yui2.8/build/reset/reset.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,include/jslibs/jquery-treeview/jquery.treeview.css,skins/common/main.css,skins/admin/admincolor.css,login/geonames.css,include/jslibs/jquery.contextmenu.css" />
<link type="text/css" rel="stylesheet" href="/include/minify/f=include/jslibs/yui2.8/build/reset/reset.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,include/jslibs/jquery-treeview/jquery.treeview.css,skins/common/main.css,skins/admin/admincolor.css,login/geonames.css,include/jslibs/jquery.contextmenu.css" />
<style>
<style>
li.selected, div.selected{
background-color:#f0ad30;
color:white;
}
li.selected a, div.selected a{
background-color:#f0ad30;
color:white;
}
#right-ajax.loading{
background-image: url(/skins/icons/loaderFFF.gif);
background-position: center center;
background-repeat: no-repeat;
}
</style>
li.selected, div.selected{
background-color:#f0ad30;
color:white;
}
li.selected a, div.selected a{
background-color:#f0ad30;
color:white;
}
#right-ajax.loading{
background-image: url(/skins/icons/loaderFFF.gif);
background-position: center center;
background-repeat: no-repeat;
}
</style>
{% endblock %}
{% block javascript %}
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="/include/minify/g=admin"></script>
<script type="text/javascript">
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="/include/minify/g=admin"></script>
<script type="text/javascript">
var p4 = {users:{sel:[]}};
var bodySize = {x:0,y:0};
var p4 = {users:{sel:[]}};
var bodySize = {x:0,y:0};
var language = {
serverName: '{{ registry.get('GV_ServerName') }}',
serverError: '{% trans 'phraseanet::erreur: Une erreur est survenue, si ce probleme persiste, contactez le support technique' %}',
serverTimeout: '{% trans 'phraseanet::erreur: La connection au serveur Phraseanet semble etre indisponible' %}',
serverDisconnected: '{% trans 'phraseanet::erreur: Votre session est fermee, veuillez vous re-authentifier' %}',
check_all : '{% trans 'Cocher toute la colonne' %}',
uncheck_all : '{% trans 'Decocher toute la colonne' %}',
create_template : '{% trans 'Creer un model' %}',
create_user : '{% trans 'Creer un utilisateur' %}',
annuler : '{% trans 'boutton::annuler' %}'
};
var language = {
serverName: '{{ registry.get('GV_ServerName') }}',
serverError: '{% trans 'phraseanet::erreur: Une erreur est survenue, si ce probleme persiste, contactez le support technique' %}',
serverTimeout: '{% trans 'phraseanet::erreur: La connection au serveur Phraseanet semble etre indisponible' %}',
serverDisconnected: '{% trans 'phraseanet::erreur: Votre session est fermee, veuillez vous re-authentifier' %}',
check_all : '{% trans 'Cocher toute la colonne' %}',
uncheck_all : '{% trans 'Decocher toute la colonne' %}',
create_template : '{% trans 'Creer un model' %}',
create_user : '{% trans 'Creer un utilisateur' %}',
annuler : '{% trans 'boutton::annuler' %}'
};
window.onbeforeunload = function()
{
var xhr_object = null;
if(window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // Internet Explorer
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else // XMLHttpRequest non supporte par le navigateur
return;
url= "/include/delses.php?app=3&t="+Math.random();
xhr_object.open("GET", url, false);
xhr_object.send(null);
};
function sessionactive(){
$.ajax({
type: "POST",
url: "/include/updses.php",
dataType: 'json',
data: {
app : 3,
usr : {{ session.get_usr_id() }}
},
error: function(){
window.setTimeout("sessionactive();", 10000);
},
timeout: function(){
window.setTimeout("sessionactive();", 10000);
},
success: function(data){
if(data)
manageSession(data);
var t = 120000;
if(data.apps && parseInt(data.apps)>1)
t = Math.round((Math.sqrt(parseInt(data.apps)-1) * 1.3 * 120000));
window.setTimeout("sessionactive();", t);
return;
}
})
};
function activeTree(click)
{
$('#FNDR').treeview({
collapsed: true,
animated: "medium"
});
$.each($('#tree a[target=right]'),function(){
var dest = $(this).attr('href');
$(this).bind('click',function(){
if($(this).hasClass('ajax'))
{
$('#right-ajax').empty().addClass('loading').parent().show();
$('#right').hide();
$.get(dest, function(data) {
$('#right-ajax').removeClass('loading').html(data);
});
}
else
{
$('#right-ajax').empty().parent().hide();
$('#right').show().addClass('loading').attr('src',dest);
}
$('#tree .selected').removeClass('selected');
$(this).parent().addClass('selected');
return false;
});
$(this).removeAttr('target');
});
if(click === true)
{
if($('#tree li.selected').length > 0)
$('#tree li.selected a').trigger('click');
else
$('.zone_online_users').trigger('click');
}
}
$(document).ready(
function(){
resize();
setTimeout('sessionactive();',15000);
activeTree(true);
}
);
function refreshBaskets()
window.onbeforeunload = function()
{
return;
}
function resize()
{
$('#right').height($(this).height()-$('#mainMenu').height()-20);
$('#right').width($('#mainContent').width()-$('#left').width()-20);
bodySize.y = $(window).height() - $('#mainMenu').outerHeight();
bodySize.x = $(window).width();
}
var xhr_object = null;
if(window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // Internet Explorer
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else // XMLHttpRequest non supporte par le navigateur
$(window).bind('resize',function(){resize();});
return;
url= "/include/delses.php?app=3&t="+Math.random();
xhr_object.open("GET", url, false);
xhr_object.send(null);
};
function reloadTree(position, click){
function sessionactive(){
$.ajax({
type: "POST",
url: "adminFeedback.php",
url: "/include/updses.php",
dataType: 'json',
data: {
action : 'TREE',
position : position
app : 3,
usr : {{ session.get_usr_id() }}
},
success: function(datas){
$('#FNDR').empty().append(datas);
activeTree(click);
error: function(){
window.setTimeout("sessionactive();", 10000);
},
timeout: function(){
window.setTimeout("sessionactive();", 10000);
},
success: function(data){
if(data)
manageSession(data);
var t = 120000;
if(data.apps && parseInt(data.apps)>1)
t = Math.round((Math.sqrt(parseInt(data.apps)-1) * 1.3 * 120000));
window.setTimeout("sessionactive();", t);
return;
}
})
};
function activeTree(click)
{
$('#FNDR').treeview({
collapsed: true,
animated: "medium"
});
$.each($('#tree a[target=right]'),function(){
var dest = $(this).attr('href');
$(this).bind('click',function(){
if($(this).hasClass('ajax'))
{
$('#right-ajax').empty().addClass('loading').parent().show();
$('#right').hide();
$.get(dest, function(data) {
$('#right-ajax').removeClass('loading').html(data);
});
}
else
{
$('#right-ajax').empty().parent().hide();
$('#right').show().addClass('loading').attr('src',dest);
}
$('#tree .selected').removeClass('selected');
$(this).parent().addClass('selected');
return false;
});
$(this).removeAttr('target');
});
if(click === true)
{
if($('#tree li.selected').length > 0)
$('#tree li.selected a').trigger('click');
else
$('.zone_online_users').trigger('click');
}
}
$(document).ready(
function(){
resize();
setTimeout('sessionactive();',15000);
activeTree(true);
}
);
function refreshBaskets()
{
return;
}
function resize()
{
$('#right').height($(this).height()-$('#mainMenu').height()-20);
$('#right').width($('#mainContent').width()-$('#left').width()-20);
bodySize.y = $(window).height() - $('#mainMenu').outerHeight();
bodySize.x = $(window).width();
}
$(window).bind('resize',function(){resize();});
function reloadTree(position, click){
$.ajax({
type: "POST",
url: "adminFeedback.php",
data: {
action : 'TREE',
position : position
},
success: function(datas){
$('#FNDR').empty().append(datas);
activeTree(click);
return;
}
})
}
</script>
{% endblock %}
{% block content %}
<div id="left" class="PNB" style="width:250px;right:auto;">
<div class="PNB10" style="right:0">
<div id="FNDR">
<div id="left" class="PNB" style="width:250px;right:auto;">
<div class="PNB10" style="right:0">
<div id="FNDR">
{% include 'admin/tree.html.twig' %}
</div>
</div>
</div>
</div>
</div>
<iframe class="right PNB10" src="about:blank;" name="right" id="right" frameborder="1" border="0" framespacing="0" style="left:260px;border:none;right:0;"></iframe>
<div class="right PNB" style="left:250px;overflow:auto;">
<div id="right-ajax" class="PNB10"></div>
</div>
<div id="quotas_dialog"></div>
<div id="masks_dialog"></div>
<div id="time_dialog"></div>
<div id="user_add_dialog" title="{% trans 'Ajouter un nouvel utilisateur' %}">
<form>
<label>{% trans 'Adresse email du nouvel utilisateur' %}</label>
<input type="text" name="value" />
<img src="/skins/icons/loaderFFF.gif" class="new_user_loader" style="display:none;"/>
</form>
</div>
<div id="template_add_dialog" title="{% trans 'Creer un modele' %}">
<form>
<label>{% trans 'Nom du nouveau modele' %}</label>
<input type="text" name="value" />
<img src="/skins/icons/loaderFFF.gif" class="new_user_loader" style="display:none;"/>
</form>
</div>
<div id="DIALOG" style="color:white;"></div>
{% if notice %}
<div class="right PNB10 notice" style="left:260px;">
{% if notice == "install_success" %}
{% trans %}Successful install{% endtrans %}
{% endif %}
</div>
{% endif %}
<iframe class="right PNB10" src="about:blank;" name="right" id="right" frameborder="1" border="0" framespacing="0" style="left:260px;border:none;right:0;{{ notice ? "top:30px" : "top:0" }}"></iframe>
<div class="right PNB" style="left:250px;overflow:auto;">
<div id="right-ajax" class="PNB10"></div>
</div>
<div id="quotas_dialog"></div>
<div id="masks_dialog"></div>
<div id="time_dialog"></div>
<div id="user_add_dialog" title="{% trans 'Ajouter un nouvel utilisateur' %}">
<form>
<label>{% trans 'Adresse email du nouvel utilisateur' %}</label>
<input type="text" name="value" />
<img src="/skins/icons/loaderFFF.gif" class="new_user_loader" style="display:none;"/>
</form>
</div>
<div id="template_add_dialog" title="{% trans 'Creer un modele' %}">
<form>
<label>{% trans 'Nom du nouveau modele' %}</label>
<input type="text" name="value" />
<img src="/skins/icons/loaderFFF.gif" class="new_user_loader" style="display:none;"/>
</form>
</div>
<div id="DIALOG" style="color:white;"></div>
{% endblock %}