From 02efc2b9d1dd8592cf1ec6a82049d679d3f7c289 Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Tue, 31 Jul 2018 11:56:50 +0200 Subject: [PATCH] PHRAS-2161_coll-id-in-log-docs_MASTER moved cli "patch:log_coll_id" from bin/developer to bin/setup cs --- bin/developer | 2 -- bin/setup | 2 ++ .../{Developer => Setup}/FixLogCollId.php | 20 +++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) rename lib/Alchemy/Phrasea/Command/{Developer => Setup}/FixLogCollId.php (96%) diff --git a/bin/developer b/bin/developer index 15963da3f5..7a1f0888ae 100755 --- a/bin/developer +++ b/bin/developer @@ -22,7 +22,6 @@ use Alchemy\Phrasea\Command\Developer\RoutesDumper; use Alchemy\Phrasea\Command\Developer\SetupTestsDbs; use Alchemy\Phrasea\Command\Developer\Uninstaller; use Alchemy\Phrasea\Command\Developer\TranslationDumper; -use Alchemy\Phrasea\Command\Developer\FixLogCollId; use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper; use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; @@ -79,7 +78,6 @@ $cli->command(new Uninstaller()); $cli->command(new JsFixtures()); $cli->command(new IniReset()); $cli->command(new SetupTestsDbs()); -$cli->command(new FixLogCollId()); $cli->command(new \module_console_systemTemplateGenerator('system:generate-templates')); diff --git a/bin/setup b/bin/setup index 2b553dab3a..e778de1f60 100755 --- a/bin/setup +++ b/bin/setup @@ -13,6 +13,7 @@ namespace KonsoleKommander; use Alchemy\Phrasea\Command\Setup\ConfigurationEditor; use Alchemy\Phrasea\Command\Setup\FixAutoincrements; +use Alchemy\Phrasea\Command\Setup\FixLogCollId; use Alchemy\Phrasea\Core\Version; use Alchemy\Phrasea\Command\UpgradeDBDatas; use Alchemy\Phrasea\Command\Setup\Install; @@ -78,6 +79,7 @@ $app->command(new CheckEnvironment('check:system')); $app->command(new Install('system:install', $app['phraseanet.structure-template'])); $app->command(new CrossDomainGenerator()); $app->command(new FixAutoincrements('system:fix-autoincrements')); +$app->command(new FixLogCollId()); $app['phraseanet.setup_mode'] = true; diff --git a/lib/Alchemy/Phrasea/Command/Developer/FixLogCollId.php b/lib/Alchemy/Phrasea/Command/Setup/FixLogCollId.php similarity index 96% rename from lib/Alchemy/Phrasea/Command/Developer/FixLogCollId.php rename to lib/Alchemy/Phrasea/Command/Setup/FixLogCollId.php index c67ee2997d..ae0961423c 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/FixLogCollId.php +++ b/lib/Alchemy/Phrasea/Command/Setup/FixLogCollId.php @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace Alchemy\Phrasea\Command\Developer; +namespace Alchemy\Phrasea\Command\Setup; use Alchemy\Phrasea\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -32,7 +32,7 @@ class FixLogCollId extends Command private $databoxes; /** @var int */ - private $batchsize; + private $batch_size; /** @var bool */ private $dry; /** @var bool */ @@ -54,7 +54,7 @@ class FixLogCollId extends Command $this->setDescription('Fix empty (null) coll_id in "log_docs" and "log_view" tables.'); $this->addOption('databox', null, InputOption::VALUE_OPTIONAL, 'Mandatory : The id (or dbname or viewname) of the databox'); - $this->addOption('batchsize', null, InputOption::VALUE_OPTIONAL, 'work on a batch of n entries (default=100000)'); + $this->addOption('batch_size', null, InputOption::VALUE_OPTIONAL, 'work on a batch of n entries (default=100000)'); $this->addOption('dry', null, InputOption::VALUE_NONE, 'dry run, list but don\'t act'); $this->addOption('show_sql', null, InputOption::VALUE_NONE, 'show sql pre-selecting records'); $this->addOption('keep_tmp_table', null, InputOption::VALUE_NONE, 'keep the working "tmp_coll" table (help debug)'); @@ -99,16 +99,16 @@ class FixLogCollId extends Command } // get options - $this->batchsize = $input->getOption('batchsize'); + $this->batch_size = $input->getOption('batch_size'); $this->show_sql = $input->getOption('show_sql') ? true : false; $this->dry = $input->getOption('dry') ? true : false; $this->keep_tmp_table = $input->getOption('keep_tmp_table') ? true : false; - if(is_null($this->batchsize)) { - $this->batchsize = 100000; + if(is_null($this->batch_size)) { + $this->batch_size = 100000; } - if($this->batchsize < 1) { - $output->writeln(sprintf('batchsize must be > 0')); + if($this->batch_size < 1) { + $output->writeln(sprintf('batch_size must be > 0')); $argsOK = false; } @@ -155,7 +155,7 @@ class FixLogCollId extends Command 'minmax' => [ 'msg' => "Get a batch", 'sql' => "SELECT MIN(`id`) AS `minid`, MAX(`id`) AS `maxid` FROM\n" - . " (SELECT `id` FROM `log_docs` WHERE ISNULL(`coll_id`) ORDER BY `id` DESC LIMIT " . $this->batchsize . ") AS `t", + . " (SELECT `id` FROM `log_docs` WHERE ISNULL(`coll_id`) ORDER BY `id` DESC LIMIT " . $this->batch_size . ") AS `t", 'fetch' => false, 'code' => function(ResultStatement $stmt) { $row = $stmt->fetch(); @@ -211,7 +211,7 @@ class FixLogCollId extends Command . " ON `tmp_colls`.`record_id` = `log_docs`.`record_id`\n" . " AND `log_docs`.`id` >= `tmp_colls`.`from_id`\n" . " AND (`log_docs`.`id` < `tmp_colls`.`to_id` OR ISNULL(`tmp_colls`.`to_id`))\n" - . " SET `log_docs`.`coll_id` = `tmp_colls`.`coll_id", + . " SET `log_docs`.`coll_id` = `tmp_colls`.`coll_id`", 'fetch' => false, 'code' => null, 'playdry' => self::PLAYDRY_NONE,