From b651d32a4c0a6070d9bfd70b002e790031e32865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Tue, 3 Mar 2015 17:40:18 +0100 Subject: [PATCH 1/4] Remove old .bowerrc copy. --- resources/vagrant/config/bower/.bowerrc | 4 ---- .../phraseanet-php54-nginx/puphpet/files/exec-once/setup | 7 +------ 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 resources/vagrant/config/bower/.bowerrc diff --git a/resources/vagrant/config/bower/.bowerrc b/resources/vagrant/config/bower/.bowerrc deleted file mode 100644 index f303864386..0000000000 --- a/resources/vagrant/config/bower/.bowerrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "directory": "www/assets", - "interactive": false -} diff --git a/resources/vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-once/setup b/resources/vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-once/setup index bdf48a27ce..4f62bf5ee8 100644 --- a/resources/vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-once/setup +++ b/resources/vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-once/setup @@ -145,16 +145,12 @@ then #copy configuration template mv /var/www/phraseanet/lib/conf.d/configuration.yml /var/www/phraseanet/lib/conf.d/configuration.yml.bkp cp /vagrant/resources/vagrant/config/phraseanet/configuration.yml /var/www/phraseanet/lib/conf.d/configuration.yml - mv /var/www/phraseanet/.bowerrc /var/www/phraseanet/.bowerrc.bkp - cp /vagrant/resources/vagrant/config/bower/.bowerrc /var/www/phraseanet/.bowerrc cd /var/www/phraseanet sudo -u vagrant composer install -n --prefer-source --dev sudo -u vagrant npm install sudo -u vagrant grunt install-assets sudo -u vagrant bin/developer assets:compile-less sudo -u vagrant rm -f /var/www/phraseanet/lib/conf.d/configuration.yml - rm -f /var/www/phraseanet/.bowerrc - mv /www/phraseanet/.bowerrc.bkp /www/phraseanet/.bowerrc mv /var/www/phraseanet/lib/conf.d/configuration.yml.bkp /var/www/phraseanet/lib/conf.d/configuration.yml fi @@ -167,5 +163,4 @@ sudo service nginx restart sudo service iptables-persistent stop # reload bash -source ~/.bashrc - +source ~/.bashrc \ No newline at end of file From bfabecc1ad5780748af65f66e88acee22bb7f1d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Tue, 3 Mar 2015 18:56:10 +0100 Subject: [PATCH 2/4] Fix phraseanet install (generate ORM proxies) --- .../Subscriber/PhraseaInstallSubscriber.php | 9 +++ lib/Alchemy/Phrasea/Helper/DatabaseHelper.php | 67 +++++++------------ 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaInstallSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaInstallSubscriber.php index ae0f9b415a..91d7efaaac 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaInstallSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaInstallSubscriber.php @@ -16,6 +16,7 @@ use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Model\Entities\ApiApplication; use Silex\Application; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\Process\Process; class PhraseaInstallSubscriber implements EventSubscriberInterface { @@ -37,6 +38,7 @@ class PhraseaInstallSubscriber implements EventSubscriberInterface { $this->createNavigatorApplication(); $this->createOfficePluginApplication(); + $this->generateProxies(); } private function createNavigatorApplication() @@ -74,4 +76,11 @@ class PhraseaInstallSubscriber implements EventSubscriberInterface $this->app['manipulator.api-application']->update($application); } + + private function generateProxies() + { + $process = new Process('php ' . $this->app['root.path']. '/bin/developer orm:generate:proxies'); + $process->setTimeout(300); + $process->run(); + } } diff --git a/lib/Alchemy/Phrasea/Helper/DatabaseHelper.php b/lib/Alchemy/Phrasea/Helper/DatabaseHelper.php index 49bc1207bb..ec4fb89bd3 100644 --- a/lib/Alchemy/Phrasea/Helper/DatabaseHelper.php +++ b/lib/Alchemy/Phrasea/Helper/DatabaseHelper.php @@ -21,64 +21,47 @@ 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; + $db_ok = $is_databox = $is_appbox = $empty = false; try { $connection = $this->app['dbal.provider']([ 'host' => $hostname, 'port' => $port, 'user' => $user, - 'password' => $password + 'password' => $password, + 'dbname' => $db_name, ]); - $connection->connect(); - $connection_ok = true; + + $db_ok = true; + + $sql = "SHOW TABLE STATUS"; + $stmt = $connection->prepare($sql); + $stmt->execute(); + + $empty = $stmt->rowCount() === 0; + + $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); + $stmt->closeCursor(); + + foreach ($rs as $row) { + if ($row["Name"] === 'sitepreff') { + $is_appbox = true; + } + if ($row["Name"] === 'pref') { + $is_databox = true; + } + } $connection->close(); } catch (\Exception $e) { } + unset($connection); - if (null !== $db_name && $connection_ok) { - try { - $connection = $this->app['dbal.provider']([ - 'host' => $hostname, - 'port' => $port, - 'user' => $user, - 'password' => $password, - 'dbname' => $db_name, - ]); - - $db_ok = true; - - $sql = "SHOW TABLE STATUS"; - $stmt = $connection->prepare($sql); - $stmt->execute(); - - $empty = $stmt->rowCount() === 0; - - $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - foreach ($rs as $row) { - if ($row["Name"] === 'sitepreff') { - $is_appbox = true; - } - if ($row["Name"] === 'pref') { - $is_databox = true; - } - } - $connection->close(); - } catch (\Exception $e) { - - } - - unset($connection); - } - $this->app['connection.pool.manager']->closeAll(); return [ - 'connection' => $connection_ok, + 'connection' => $db_ok, 'innodb' => true, 'database' => $db_ok, 'is_empty' => $empty, From 4b48e829f788b07a761d50cbfe151209efc6428f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Tue, 3 Mar 2015 19:03:38 +0100 Subject: [PATCH 3/4] Add default data path in twig --- templates/web/setup/step2.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/web/setup/step2.html.twig b/templates/web/setup/step2.html.twig index 35dcdd4896..a331ae4e09 100644 --- a/templates/web/setup/step2.html.twig +++ b/templates/web/setup/step2.html.twig @@ -654,7 +654,7 @@ - +
From 1d6d0ab82f8940fbe45801608d92fa0c5f3eea4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Wed, 4 Mar 2015 18:50:47 +0100 Subject: [PATCH 4/4] DatabaseHelper does not try to connect twice. --- lib/Alchemy/Phrasea/Helper/DatabaseHelper.php | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/Alchemy/Phrasea/Helper/DatabaseHelper.php b/lib/Alchemy/Phrasea/Helper/DatabaseHelper.php index ec4fb89bd3..2d39b5f0c7 100644 --- a/lib/Alchemy/Phrasea/Helper/DatabaseHelper.php +++ b/lib/Alchemy/Phrasea/Helper/DatabaseHelper.php @@ -11,6 +11,8 @@ namespace Alchemy\Phrasea\Helper; +use Doctrine\DBAL\Connection; + class DatabaseHelper extends Helper { public function checkConnection() @@ -21,19 +23,18 @@ class DatabaseHelper extends Helper $password = $this->request->query->get('password'); $db_name = $this->request->query->get('db_name'); - $db_ok = $is_databox = $is_appbox = $empty = false; + $is_databox = $is_appbox = $empty = false; - try { - $connection = $this->app['dbal.provider']([ - 'host' => $hostname, - 'port' => $port, - 'user' => $user, - 'password' => $password, - 'dbname' => $db_name, - ]); - - $db_ok = true; + /** @var Connection $connection */ + $connection = $this->app['dbal.provider']([ + 'host' => $hostname, + 'port' => $port, + 'user' => $user, + 'password' => $password, + 'dbname' => $db_name, + ]); + if (false !== $dbOK = $connection->isConnected()) { $sql = "SHOW TABLE STATUS"; $stmt = $connection->prepare($sql); $stmt->execute(); @@ -52,8 +53,6 @@ class DatabaseHelper extends Helper } } $connection->close(); - } catch (\Exception $e) { - } unset($connection); @@ -61,9 +60,9 @@ class DatabaseHelper extends Helper $this->app['connection.pool.manager']->closeAll(); return [ - 'connection' => $db_ok, + 'connection' => $dbOK, 'innodb' => true, - 'database' => $db_ok, + 'database' => $dbOK, 'is_empty' => $empty, 'is_appbox' => $is_appbox, 'is_databox' => $is_databox