mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 19:43:16 +00:00
PHRAS-288 Check if storage engines is available
This commit is contained in:
@@ -92,6 +92,11 @@ class Install extends Command
|
||||
}
|
||||
|
||||
$abConn = $this->getABConn($input, $output, $dialog);
|
||||
|
||||
if (false === $abConn->supportInnoDB()){
|
||||
throw new \Exception('Database server does not support InnoDB storage engine');
|
||||
}
|
||||
|
||||
list($dbConn, $template) = $this->getDBConn($input, $output, $abConn, $dialog);
|
||||
list($email, $password) = $this->getCredentials($input, $output, $dialog);
|
||||
$dataPath = $this->getDataPath($input, $output, $dialog);
|
||||
|
@@ -178,6 +178,9 @@ class Databoxes implements ControllerProviderInterface
|
||||
case 'mount-failed' :
|
||||
$errorMsg = _('Database could not be mounted');
|
||||
break;
|
||||
case 'innodb-support' :
|
||||
$errorMsg = _('Database server does not support InnoDB storage engine');
|
||||
break;
|
||||
}
|
||||
|
||||
$upgrader = new \Setup_Upgrade($app);
|
||||
@@ -228,6 +231,10 @@ class Databoxes implements ControllerProviderInterface
|
||||
return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'database-failed'));
|
||||
}
|
||||
|
||||
if (false === $connbas->supportInnoDB()){
|
||||
return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'innodb-support'));
|
||||
}
|
||||
|
||||
try {
|
||||
$base = \databox::create($app, $connbas, $dataTemplate, $app['phraseanet.registry']);
|
||||
$base->registerAdmin($app['authentication']->getUser());
|
||||
@@ -250,6 +257,11 @@ class Databoxes implements ControllerProviderInterface
|
||||
try {
|
||||
$data_template = new \SplFileInfo($app['root.path'] . '/lib/conf.d/data_templates/' . $dataTemplate . '.xml');
|
||||
$connbas = new \connection_pdo('databox_creation', $hostname, $port, $userDb, $passwordDb, $dbName, array(), $app['debug']);
|
||||
|
||||
if (false === $connbas->supportInnoDB()){
|
||||
return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'innodb-support'));
|
||||
}
|
||||
|
||||
try {
|
||||
$base = \databox::create($app, $connbas, $data_template, $app['phraseanet.registry']);
|
||||
$base->registerAdmin($app['authentication']->getUser());
|
||||
|
@@ -23,10 +23,12 @@ class DatabaseHelper extends Helper
|
||||
$password = $this->request->query->get('password');
|
||||
$db_name = $this->request->query->get('db_name');
|
||||
|
||||
$connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false;
|
||||
$connection_ok = $innodb = $db_ok = $is_databox = $is_appbox = $empty = false;
|
||||
|
||||
try {
|
||||
new \connection_pdo('test', $hostname, $port, $user, $password, $db_name, array(), false);
|
||||
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, $db_name, array(), false);
|
||||
$innodb = $conn->supportInnoDB();
|
||||
|
||||
$connection_ok = true;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@@ -61,6 +63,7 @@ class DatabaseHelper extends Helper
|
||||
|
||||
return array(
|
||||
'connection' => $connection_ok,
|
||||
'innodb' => $innodb,
|
||||
'database' => $db_ok,
|
||||
'is_empty' => $empty,
|
||||
'is_appbox' => $is_appbox,
|
||||
|
@@ -59,6 +59,27 @@ abstract class connection_abstract
|
||||
return $this->connection->getAttribute(constant("PDO::ATTR_SERVER_VERSION"));
|
||||
}
|
||||
|
||||
public function supportInnoDB()
|
||||
{
|
||||
if (false === $this->ping()) {
|
||||
throw new \Exception('Mysql server is not reachable');
|
||||
}
|
||||
|
||||
$stmt = $this->connection->query('SHOW ENGINES');
|
||||
$stmt->execute();
|
||||
$engines = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($engines as $engine) {
|
||||
if (strtolower($engine['Engine']) !== 'innodb') {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $engine['Support'] !== 'NO';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->close();
|
||||
|
@@ -618,6 +618,10 @@ class databox extends base
|
||||
{
|
||||
$connection = new connection_pdo('test', $host, $port, $user, $password, $dbname, array(), $app['debug']);
|
||||
|
||||
if (false === $connection->supportInnoDB()) {
|
||||
throw new \Exception('Database server does not support InnoDB storage engine');
|
||||
}
|
||||
|
||||
$conn = $app['phraseanet.appbox']->get_connection();
|
||||
$sql = 'SELECT MAX(ord) as ord FROM sbas';
|
||||
$stmt = $conn->prepare($sql);
|
||||
|
@@ -211,7 +211,7 @@
|
||||
},
|
||||
success: function (data) {
|
||||
el_loader.css('visibility', 'hidden');
|
||||
if (data.connection === true && data.database === true) {
|
||||
if (data.connection === true && data.database === true && data.innodb === true) {
|
||||
el_status.attr('src', '/skins/icons/ok.png').show();
|
||||
el_message.empty().append("{% trans 'Successfull connection' %}");
|
||||
if (!data.is_empty) {
|
||||
@@ -223,6 +223,11 @@
|
||||
|
||||
return;
|
||||
}
|
||||
if (false === data.innodb) {
|
||||
el_message.empty().append("{% trans 'Database server does not support InnoDB storage engine' %}");
|
||||
|
||||
return;
|
||||
}
|
||||
if (data.connection === true) {
|
||||
el_message.empty().append("{% trans 'Connection is OK but database does not exists or can not be accessed' %}");
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user