From 3202e941adcde6cc3aadd4494cc680210c47aa64 Mon Sep 17 00:00:00 2001 From: alojua Date: Thu, 23 Nov 2017 11:13:42 +0100 Subject: [PATCH 1/9] Add argument on app:config:dump to specify which types to dump. That allows to dump only scope and theme while skipping system for easier maintainability. --- .../Command/App/ApplicationDumpCommand.php | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php b/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php index 9d13c97790fa4..c3492019455f2 100644 --- a/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php +++ b/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php @@ -12,6 +12,7 @@ use Magento\Framework\Config\File\ConfigFilePool; use Magento\Framework\Console\Cli; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -20,6 +21,18 @@ */ class ApplicationDumpCommand extends Command { + const INPUT_CONFIG_TYPES = 'config-types'; + + /** + * @var array + */ + private $configTypes = [ + \Magento\Store\App\Config\Type\Scopes::CONFIG_TYPE, + \Magento\Deploy\Source\Themes::TYPE, + \Magento\Translation\App\Config\Type\Translation::CONFIG_TYPE, + \Magento\Config\App\Config\Type\System::CONFIG_TYPE, + ]; + /** * @var Writer */ @@ -60,6 +73,12 @@ protected function configure() { $this->setName('app:config:dump'); $this->setDescription('Create dump of application'); + $this->addArgument( + self::INPUT_CONFIG_TYPES, + InputArgument::OPTIONAL | InputArgument::IS_ARRAY, + sprintf('Space-separated list of config types or omit to dump all [%s]', + implode(', ', $this->configTypes)) + ); parent::configure(); } @@ -74,11 +93,14 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { $this->groupSourcesByPool(); - + $dumpedTypes = []; foreach ($this->sources as $pool => $sources) { $dump = []; $comments = []; foreach ($sources as $sourceData) { + if ($this->skipDump($input, $sourceData)) { + continue; + } /** @var ConfigSourceInterface $source */ $source = $sourceData['source']; $namespace = $sourceData['namespace']; @@ -95,15 +117,21 @@ protected function execute(InputInterface $input, OutputInterface $output) null, $comments ); + $dumpedTypes = array_unique($dumpedTypes + array_keys($dump)); if (!empty($comments)) { $output->writeln($comments); } } + if (!$dumpedTypes) { + $output->writeln('Nothing dumped. Check the config types specified and try again'); + return Cli::RETURN_FAILURE; + } + // Generate and save new hash of deployment configuration. $this->configHash->regenerate(); - $output->writeln('Done.'); + $output->writeln(sprintf('Done. Config types dumped: %s', implode(', ', $dumpedTypes))); return Cli::RETURN_SUCCESS; } @@ -127,4 +155,20 @@ private function groupSourcesByPool() $this->sources = $sources; } + + /** + * Check whether the dump source should be skipped + * + * @param InputInterface $input + * @param array $sourceData + * @return bool + */ + private function skipDump(InputInterface $input, array $sourceData): bool + { + $allowedTypes = $input->getArgument(self::INPUT_CONFIG_TYPES); + if ($allowedTypes && !in_array($sourceData['namespace'], $allowedTypes)) { + return true; + } + return false; + } } From 0812ba807e605343d397768199d67a0ecd811482 Mon Sep 17 00:00:00 2001 From: alojua Date: Sat, 25 Nov 2017 11:18:17 +0100 Subject: [PATCH 2/9] Fix failing tests --- .../Deploy/Console/Command/App/ApplicationDumpCommand.php | 3 +-- .../Test/Unit/Console/Command/ApplicationDumpCommandTest.php | 2 +- .../Deploy/Console/Command/App/ApplicationDumpCommandTest.php | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php b/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php index c3492019455f2..e47f534a40793 100644 --- a/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php +++ b/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php @@ -76,8 +76,7 @@ protected function configure() $this->addArgument( self::INPUT_CONFIG_TYPES, InputArgument::OPTIONAL | InputArgument::IS_ARRAY, - sprintf('Space-separated list of config types or omit to dump all [%s]', - implode(', ', $this->configTypes)) + sprintf('Space-separated list of config types or omit to dump all [%s]', implode(', ', $this->configTypes)) ); parent::configure(); } diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/ApplicationDumpCommandTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/ApplicationDumpCommandTest.php index 67c3796e7c6b9..85cae275932fa 100644 --- a/app/code/Magento/Deploy/Test/Unit/Console/Command/ApplicationDumpCommandTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/ApplicationDumpCommandTest.php @@ -130,7 +130,7 @@ public function testExport() ->method('writeln') ->withConsecutive( [['system' => 'Some comment message']], - ['Done.'] + ['Done. Config types dumped: system'] ); $method = new \ReflectionMethod(ApplicationDumpCommand::class, 'execute'); diff --git a/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php b/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php index cb40b110f5fc6..5602e77eb702c 100644 --- a/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php @@ -176,7 +176,7 @@ public function testExecute() ->with(['system' => $comment]); $outputMock->expects($this->at(1)) ->method('writeln') - ->with('Done.'); + ->with('Done. Config types dumped: scopes, themes, system, i18n'); /** @var ApplicationDumpCommand command */ $command = $this->objectManager->create(ApplicationDumpCommand::class); From 6751504cd9f8f2dc7290d802132bffab98a7d745 Mon Sep 17 00:00:00 2001 From: alojua Date: Tue, 28 Nov 2017 09:30:39 +0100 Subject: [PATCH 3/9] Remove hard dependencies to set configTypes and get them dynamically instead --- .../Command/App/ApplicationDumpCommand.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php b/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php index e47f534a40793..4eb965b21d53a 100644 --- a/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php +++ b/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php @@ -23,16 +23,6 @@ class ApplicationDumpCommand extends Command { const INPUT_CONFIG_TYPES = 'config-types'; - /** - * @var array - */ - private $configTypes = [ - \Magento\Store\App\Config\Type\Scopes::CONFIG_TYPE, - \Magento\Deploy\Source\Themes::TYPE, - \Magento\Translation\App\Config\Type\Translation::CONFIG_TYPE, - \Magento\Config\App\Config\Type\System::CONFIG_TYPE, - ]; - /** * @var Writer */ @@ -60,10 +50,10 @@ public function __construct( array $sources, Hash $configHash = null ) { - parent::__construct(); $this->writer = $writer; $this->sources = $sources; $this->configHash = $configHash ?: ObjectManager::getInstance()->get(Hash::class); + parent::__construct(); } /** @@ -73,10 +63,12 @@ protected function configure() { $this->setName('app:config:dump'); $this->setDescription('Create dump of application'); + + $configTypes = array_unique(array_column($this->sources, 'namespace')); $this->addArgument( self::INPUT_CONFIG_TYPES, InputArgument::OPTIONAL | InputArgument::IS_ARRAY, - sprintf('Space-separated list of config types or omit to dump all [%s]', implode(', ', $this->configTypes)) + sprintf('Space-separated list of config types or omit to dump all [%s]', implode(', ', $configTypes)) ); parent::configure(); } From 646de48fdf26ea56a6f102f72dd5d8d829359a22 Mon Sep 17 00:00:00 2001 From: Philipp Sander Date: Mon, 16 Apr 2018 15:43:11 +0200 Subject: [PATCH 4/9] Fixed setting of triggerRecollection falg --- app/code/Magento/Quote/Model/Quote.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Quote/Model/Quote.php b/app/code/Magento/Quote/Model/Quote.php index 7741d3b0f7657..536c58861a253 100644 --- a/app/code/Magento/Quote/Model/Quote.php +++ b/app/code/Magento/Quote/Model/Quote.php @@ -2389,8 +2389,9 @@ protected function _afterLoad() { // collect totals and save me, if required if (1 == $this->getTriggerRecollect()) { - $this->collectTotals()->save(); - $this->setTriggerRecollect(0); + $this->collectTotals() + ->setTriggerRecollect(0) + ->save(); } return parent::_afterLoad(); } From fbc264667994c94747ba43e60baa5ba8d42565e7 Mon Sep 17 00:00:00 2001 From: Julien ANQUETIL Date: Wed, 18 Apr 2018 12:13:11 +0200 Subject: [PATCH 5/9] [Backport] Fix bug with retry connect and custom db port Original Pull Request magento#14435 Fix a bug in the MySQL adapter when using non standard port Manual testing scenarios Use a database config with port, e.g. localhost:3307 On first call to _connect(), the config['host'] parameter is split into config['host'] and config['port'] In the _query() function, a situation happens that is suitable for a retry (e.g. a "MySQL has gone away" error) _connect() is called again Expected result Connection is reestablished and query tried again Actual result "Port must be configured within host parameter" exception --- lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php index b1843717b0565..2274fde82b818 100644 --- a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php +++ b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php @@ -557,6 +557,15 @@ protected function _query($sql, $bind = []) ) { $retry = true; $triesCount++; + + /** + * _connect() function does not allow port parameter, so put the port back with the host + */ + if (!empty($this->_config['port'])) { + $this->_config['host'] = implode(':', [$this->_config['host'], $this->_config['port']]); + unset($this->_config['port']); + } + $this->closeConnection(); $this->_connect(); } From 1690bb2040a9ab7f348c5e962983b782d2f0495b Mon Sep 17 00:00:00 2001 From: nit-it <34954682+nit-it@users.noreply.github.com> Date: Thu, 19 Apr 2018 14:43:31 +0530 Subject: [PATCH 6/9] Update form.phtml --- .../Catalog/view/frontend/templates/product/view/form.phtml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml index 4d7005dfe6cb2..91282ac30af42 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml @@ -22,6 +22,7 @@ + getBlockHtml('formkey') ?> getChildHtml('form_top') ?> hasOptions()):?> From 4f3c9c5346b8897ddd881c0ab55da2d72ff87c0f Mon Sep 17 00:00:00 2001 From: nit-it <34954682+nit-it@users.noreply.github.com> Date: Thu, 19 Apr 2018 15:03:26 +0530 Subject: [PATCH 7/9] Set Product options by checking item id --- .../view/frontend/web/js/options-updater.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js index a355a3f3ac7c7..6eeb61548f92e 100644 --- a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js +++ b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js @@ -7,10 +7,12 @@ define([ var selectors = { formSelector: '#product_addtocart_form', - productIdSelector: '#product_addtocart_form [name="product"]' + productIdSelector: '#product_addtocart_form [name="product"]', + itemIdSelector:'#product_addtocart_form [name="item"]' }, cartData = customerData.get('cart'), productId = $(selectors.productIdSelector).val(), + itemId= $(selectors.itemIdSelector).val(), /** * set productOptions according to cart data from customer-data @@ -24,8 +26,10 @@ define([ if (!(data && data.items && data.items.length && productId)) { return false; } - changedProductOptions = _.find(data.items, function (item) { - return item['product_id'] === productId; + changedProductOptions = data.items.find(function (item) { + if (item['item_id'] == itemId) { + return item['product_id'] === productId; + } }); changedProductOptions = changedProductOptions && changedProductOptions.options && changedProductOptions.options.reduce(function (obj, val) { From 3b636d678bb3103845ad1ef39a9505a2e835ac75 Mon Sep 17 00:00:00 2001 From: nit-it <34954682+nit-it@users.noreply.github.com> Date: Thu, 19 Apr 2018 15:05:31 +0530 Subject: [PATCH 8/9] Set Quantity by checking item id --- .../web/js/view/configure/product-customer-data.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js b/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js index d7a81decbadef..cf7e73338766d 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js @@ -7,10 +7,12 @@ require([ var selectors = { qtySelector: '#product_addtocart_form [name="qty"]', - productIdSelector: '#product_addtocart_form [name="product"]' + productIdSelector: '#product_addtocart_form [name="product"]', + itemIdSelector: '#product_addtocart_form [name="item"]' }, cartData = customerData.get('cart'), productId = $(selectors.productIdSelector).val(), + itemId = $(selectors.itemIdSelector).val(), productQty, productQtyInput, @@ -40,8 +42,10 @@ require([ return; } product = data.items.find(function (item) { - return item['product_id'] === productId || - item['item_id'] === productId; + if (item['item_id'] == itemId) { + return item['product_id'] === productId || + item['item_id'] === productId; + } }); if (!product) { From d8d51e92c0443d841746b7fc43e099d215d46332 Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets Date: Thu, 19 Apr 2018 16:05:29 +0300 Subject: [PATCH 9/9] Display Wrong Data On Cart Update Page --- .../Catalog/view/frontend/templates/product/view/form.phtml | 2 +- .../frontend/web/js/view/configure/product-customer-data.js | 2 +- .../view/frontend/web/js/options-updater.js | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml index 91282ac30af42..9c5cce7865532 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml @@ -22,7 +22,7 @@ - + getBlockHtml('formkey') ?> getChildHtml('form_top') ?> hasOptions()):?> diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js b/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js index cf7e73338766d..9af5201c267e8 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js @@ -42,7 +42,7 @@ require([ return; } product = data.items.find(function (item) { - if (item['item_id'] == itemId) { + if (item['item_id'] === itemId) { return item['product_id'] === productId || item['item_id'] === productId; } diff --git a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js index 6eeb61548f92e..37b7c7c41b216 100644 --- a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js +++ b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js @@ -8,11 +8,11 @@ define([ var selectors = { formSelector: '#product_addtocart_form', productIdSelector: '#product_addtocart_form [name="product"]', - itemIdSelector:'#product_addtocart_form [name="item"]' + itemIdSelector: '#product_addtocart_form [name="item"]' }, cartData = customerData.get('cart'), productId = $(selectors.productIdSelector).val(), - itemId= $(selectors.itemIdSelector).val(), + itemId = $(selectors.itemIdSelector).val(), /** * set productOptions according to cart data from customer-data @@ -27,7 +27,7 @@ define([ return false; } changedProductOptions = data.items.find(function (item) { - if (item['item_id'] == itemId) { + if (item['item_id'] === itemId) { return item['product_id'] === productId; } });