Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.2-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - #12410: Add argument on app:config:dump to skip dumping all system settings. (by @jalogut)
 - #14765: Display Wrong Data On Cart Update Page (by @nit-it)
 - #14753: [Backport] Fix bug with retry connect and custom db port (by @julienanquetil)
 - #14719: Fixed setting of triggerRecollection flag (by @philippsander)


Fixed GitHub Issues:
 - #11396: app:config:dump locks every configuration setting no alternative to dump specific setting only (reported by @gulshan-streammarket) has been fixed in #12410 by @jalogut in 2.2-develop branch
   Related commits:
     1. 3202e94
     2. 0812ba8
     3. 6751504

 - #9580: Quote Attribute trigger_recollect causes a timeout (reported by @bh-ref) has been fixed in #14719 by @philippsander in 2.2-develop branch
   Related commits:
     1. 646de48
  • Loading branch information
magento-engcom-team authored Apr 22, 2018
2 parents b39852c + 549ff7e commit 199272b
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<input type="hidden" name="product" value="<?= /* @escapeNotVerified */ $_product->getId() ?>" />
<input type="hidden" name="selected_configurable_option" value="" />
<input type="hidden" name="related_product" id="related-products-field" value="" />
<input type="hidden" name="item" value="<?= /* @noEscape */ $block->getRequest()->getParam('id') ?>" />
<?= $block->getBlockHtml('formkey') ?>
<?= $block->getChildHtml('form_top') ?>
<?php if (!$block->hasOptions()):?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -20,6 +21,8 @@
*/
class ApplicationDumpCommand extends Command
{
const INPUT_CONFIG_TYPES = 'config-types';

/**
* @var Writer
*/
Expand Down Expand Up @@ -47,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();
}

/**
Expand All @@ -60,6 +63,13 @@ 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(', ', $configTypes))
);
parent::configure();
}

Expand All @@ -74,11 +84,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'];
Expand All @@ -95,15 +108,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('<error>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('<info>Done.</info>');
$output->writeln(sprintf('<info>Done. Config types dumped: %s</info>', implode(', ', $dumpedTypes)));
return Cli::RETURN_SUCCESS;
}

Expand All @@ -127,4 +146,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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function testExport()
->method('writeln')
->withConsecutive(
[['system' => 'Some comment message']],
['<info>Done.</info>']
['<info>Done. Config types dumped: system</info>']
);

$method = new \ReflectionMethod(ApplicationDumpCommand::class, 'execute');
Expand Down
5 changes: 3 additions & 2 deletions app/code/Magento/Quote/Model/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function testExecute()
->with(['system' => $comment]);
$outputMock->expects($this->at(1))
->method('writeln')
->with('<info>Done.</info>');
->with('<info>Done. Config types dumped: scopes, themes, system, i18n</info>');

/** @var ApplicationDumpCommand command */
$command = $this->objectManager->create(ApplicationDumpCommand::class);
Expand Down
9 changes: 9 additions & 0 deletions lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 199272b

Please sign in to comment.