From 8dfe16c2bde9a9b92a62f1b82bb436366cf01217 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 17 Sep 2013 16:01:26 +0200 Subject: [PATCH 01/11] Fix realtime search engine indexation --- lib/classes/record/adapter.php | 6 +----- tests/classes/record/adapterTest.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index 78aaa2c822..0d31d7e6f6 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -1165,11 +1165,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface */ public function reindex() { - $connbas = connection::getPDOConnection($this->app, $this->get_sbas_id()); - $sql = 'UPDATE record SET status=(status & ~7 | 4) - WHERE record_id= :record_id'; - $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->record_id)); + $this->app['phraseanet.SE']->updateRecord($this); $this->delete_data_from_cache(self::CACHE_STATUS); return $this; diff --git a/tests/classes/record/adapterTest.php b/tests/classes/record/adapterTest.php index b43332f790..deed1a274f 100644 --- a/tests/classes/record/adapterTest.php +++ b/tests/classes/record/adapterTest.php @@ -528,4 +528,14 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract if ( ! $found) $this->fail(); } + + public function testReindex() + { + $record = new \record_adapter(self::$DI['app'], self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id()); + self::$DI['app']['phraseanet.SE'] = $this->getMock('Alchemy\Phrasea\SearchEngine\SearchEngineInterface'); + self::$DI['app']['phraseanet.SE']->expects($this->once()) + ->method('updateRecord') + ->with($record); + $record->reindex(); + } } From 391d84ca56eef722ac2e5ada8726c381a833637b Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 17 Sep 2013 16:15:44 +0200 Subject: [PATCH 02/11] Fix merge --- lib/classes/API/V1/adapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/classes/API/V1/adapter.php b/lib/classes/API/V1/adapter.php index f8e12178fe..1310ef9df8 100644 --- a/lib/classes/API/V1/adapter.php +++ b/lib/classes/API/V1/adapter.php @@ -394,7 +394,7 @@ class API_V1_adapter extends API_V1_Abstract 'active' => $app['phraseanet.registry']->get('GV_client_navigator'), ), 'office-plugin' => array( - 'active' => $registry->get('GV_client_navigator'), + 'active' => $app['phraseanet.registry']->get('GV_client_navigator'), ), 'homepage' => array( 'viewType' => $app['phraseanet.registry']->get('GV_home_publi'), From 91dd9ce321dc9392f518eaaf8569b2d3ab68c81b Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 17 Sep 2013 11:27:23 +0200 Subject: [PATCH 03/11] Disable composer interactivity --- lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php | 2 +- .../Tests/Phrasea/Command/Developper/ComposerInstallTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php b/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php index c892b4e519..229e102292 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php +++ b/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php @@ -38,7 +38,7 @@ class ComposerInstall extends Command $composer->command('self-update'); $output->writeln("OK"); - $commands = array('install', '--optimize-autoloader'); + $commands = array('install', '--optimize-autoloader', '--quiet', '--no-interaction'); if ($input->getOption('prefer-source')) { $commands[] = '--prefer-source'; } diff --git a/tests/Alchemy/Tests/Phrasea/Command/Developper/ComposerInstallTest.php b/tests/Alchemy/Tests/Phrasea/Command/Developper/ComposerInstallTest.php index c7fe02dc48..bc6c04b95e 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Developper/ComposerInstallTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Developper/ComposerInstallTest.php @@ -21,7 +21,7 @@ class ComposerInstallTest extends \PhraseanetPHPUnitAbstract self::$DI['cli']['driver.composer']->expects($this->at(1)) ->method('command') - ->with(array('install', '--optimize-autoloader', '--dev')); + ->with(array('install', '--optimize-autoloader', '--quiet', '--no-interaction', '--dev')); $command = new ComposerInstall(); $command->setContainer(self::$DI['cli']); From b81f894d22140f9014c3bdbe911e387a964794ab Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 17 Sep 2013 11:26:39 +0200 Subject: [PATCH 04/11] Remove infinite redirection, add upgrade instructions --- lib/Alchemy/Phrasea/Application/Root.php | 8 +++- lib/Alchemy/Phrasea/Controller/Setup.php | 11 ++++++ .../web/setup/upgrade-instructions.html.twig | 38 +++++++++++++++++++ .../Tests/Phrasea/Controller/SetupTest.php | 19 ++++++++++ 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 templates/web/setup/upgrade-instructions.html.twig diff --git a/lib/Alchemy/Phrasea/Application/Root.php b/lib/Alchemy/Phrasea/Application/Root.php index 9d240a5045..35a10c21dd 100644 --- a/lib/Alchemy/Phrasea/Application/Root.php +++ b/lib/Alchemy/Phrasea/Application/Root.php @@ -31,7 +31,13 @@ return call_user_func(function($environment = PhraseaApplication::ENV_PROD) { $app->before(function (Request $request) use ($app) { if (0 === strpos($request->getPathInfo(), '/setup')) { - if (!$app['phraseanet.configuration-tester']->isBlank()) { + if (!$app['phraseanet.configuration-tester']->isInstalled()) { + if (!$app['phraseanet.configuration-tester']->isBlank()) { + if ('setup_upgrade_instructions' !== $app['request']->attributes->get('_route')) { + return $app->redirectPath('setup_upgrade_instructions'); + } + } + } elseif (!$app['phraseanet.configuration-tester']->isBlank()) { return $app->redirectPath('homepage'); } } else { diff --git a/lib/Alchemy/Phrasea/Controller/Setup.php b/lib/Alchemy/Phrasea/Controller/Setup.php index 896e7de61b..ff17e751f1 100644 --- a/lib/Alchemy/Phrasea/Controller/Setup.php +++ b/lib/Alchemy/Phrasea/Controller/Setup.php @@ -37,6 +37,9 @@ class Setup implements ControllerProviderInterface $controllers->get('/installer/', 'controller.setup:rootInstaller') ->bind('install_root'); + $controllers->get('/upgrade-instructions/', 'controller.setup:displayUpgradeInstructions') + ->bind('setup_upgrade_instructions'); + $controllers->get('/installer/step2/', 'controller.setup:getInstallForm') ->bind('install_step2'); @@ -70,6 +73,14 @@ class Setup implements ControllerProviderInterface ); } + public function displayUpgradeInstructions(Application $app, Request $request) + { + return $app['twig']->render('/setup/upgrade-instructions.html.twig', array( + 'locale' => $app['locale'], + 'available_locales' => Application::getAvailableLanguages(), + )); + } + public function getInstallForm(Application $app, Request $request) { $warnings = array(); diff --git a/templates/web/setup/upgrade-instructions.html.twig b/templates/web/setup/upgrade-instructions.html.twig new file mode 100644 index 0000000000..ffd11658da --- /dev/null +++ b/templates/web/setup/upgrade-instructions.html.twig @@ -0,0 +1,38 @@ +{% extends '/setup/wrapper.html.twig' %} + +{% block content %} +
+ + + + +
+
+

+ Upgrade Instructions +

+

+ This Phraseanet install requires an upgrade. +

+ + + + +
+ Please run the following command at your application install root. + + bin/setup system:upgrade + +
+
+
+ + + + +
+
+
+
+
+{% endblock %} diff --git a/tests/Alchemy/Tests/Phrasea/Controller/SetupTest.php b/tests/Alchemy/Tests/Phrasea/Controller/SetupTest.php index 29979b8c29..b7872d3d81 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/SetupTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/SetupTest.php @@ -39,6 +39,9 @@ class SetupTest extends \Silex\WebTestCase public function testRouteSlashWhenInstalled() { + $this->app['phraseanet.configuration-tester']->expects($this->once()) + ->method('isInstalled') + ->will($this->returnValue(true)); $this->app['phraseanet.configuration-tester']->expects($this->once()) ->method('isBlank') ->will($this->returnValue(false)); @@ -50,6 +53,22 @@ class SetupTest extends \Silex\WebTestCase $this->assertEquals('/login/', $response->headers->get('location')); } + public function testRouteInstructionsWhenUpgradeRequired() + { + $this->app['phraseanet.configuration-tester']->expects($this->once()) + ->method('isInstalled') + ->will($this->returnValue(false)); + $this->app['phraseanet.configuration-tester']->expects($this->once()) + ->method('isBlank') + ->will($this->returnValue(false)); + + $client = $this->createClient(); + $crawler = $client->request('GET', '/setup/'); + $response = $client->getResponse(); + $this->assertEquals(302, $response->getStatusCode()); + $this->assertEquals('/setup/upgrade-instructions/', $response->headers->get('location')); + } + public function testRouteSetupInstaller() { $client = $this->createClient(); From 58d920cb02c3ee1c2bd2e63b64a3f65bb6c54fea Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 17 Sep 2013 13:39:08 +0200 Subject: [PATCH 05/11] Simulate realtime db update --- templates/web/admin/databox/databox.html.twig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/templates/web/admin/databox/databox.html.twig b/templates/web/admin/databox/databox.html.twig index 38ab67fc10..62e46ff14c 100644 --- a/templates/web/admin/databox/databox.html.twig +++ b/templates/web/admin/databox/databox.html.twig @@ -286,6 +286,7 @@ } } }); + setTimeout("refreshDatabaseInformations();", 10000); } $(document).ready(function(){ @@ -365,8 +366,6 @@ }); } - setTimeout("refreshDatabaseInformations();", 6000); - $('#fileupload').fileupload({ dataType: 'html', add: function(e, data) { From 0047d0fc36e7cbd39239f4db9cb8a3eb680aa2a2 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 17 Sep 2013 14:12:36 +0200 Subject: [PATCH 06/11] Never reset date sort settings, remove date field choser --- .../Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php | 1 - templates/web/admin/search-engine/phrasea.html.twig | 9 --------- templates/web/prod/index.html.twig | 2 +- www/skins/prod/jquery.main-prod.js | 2 +- 4 files changed, 2 insertions(+), 12 deletions(-) diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php index c965eed878..d646748f0a 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php @@ -44,7 +44,6 @@ class ConfigurationPanel extends AbstractConfigurationPanel $params = array( 'configuration' => $configuration, - 'date_fields' => $this->getAvailableDateFields($app['phraseanet.appbox']->get_databoxes()), 'available_sort'=> $this->searchEngine->getAvailableSort(), ); diff --git a/templates/web/admin/search-engine/phrasea.html.twig b/templates/web/admin/search-engine/phrasea.html.twig index 1c66b0e1cb..b710b2c04b 100644 --- a/templates/web/admin/search-engine/phrasea.html.twig +++ b/templates/web/admin/search-engine/phrasea.html.twig @@ -3,15 +3,6 @@
-
- {% trans 'Date fields available for search' %} - {% for field in date_fields %} - - {% endfor %} -
{% trans 'Default sort' %} {% for sort, sort_name in app['phraseanet.SE'].getAvailableSort() %} - + {% endfor %} + @@ -135,7 +135,7 @@ - +