Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/2.3-develop' into fix-issue-21177
Browse files Browse the repository at this point in the history
  • Loading branch information
nmalevanec committed Feb 15, 2019
2 parents e434bb1 + 741e610 commit 5328404
Show file tree
Hide file tree
Showing 197 changed files with 4,435 additions and 949 deletions.
18 changes: 16 additions & 2 deletions app/code/Magento/AsynchronousOperations/Model/MassConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Magento\AsynchronousOperations\Model;

use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Registry;
use Psr\Log\LoggerInterface;
use Magento\Framework\MessageQueue\MessageLockException;
use Magento\Framework\MessageQueue\ConnectionLostException;
Expand Down Expand Up @@ -58,6 +59,11 @@ class MassConsumer implements ConsumerInterface
*/
private $operationProcessor;

/**
* @var Registry
*/
private $registry;

/**
* Initialize dependencies.
*
Expand All @@ -67,14 +73,16 @@ class MassConsumer implements ConsumerInterface
* @param ConsumerConfigurationInterface $configuration
* @param OperationProcessorFactory $operationProcessorFactory
* @param LoggerInterface $logger
* @param Registry $registry
*/
public function __construct(
CallbackInvoker $invoker,
ResourceConnection $resource,
MessageController $messageController,
ConsumerConfigurationInterface $configuration,
OperationProcessorFactory $operationProcessorFactory,
LoggerInterface $logger
LoggerInterface $logger,
Registry $registry = null
) {
$this->invoker = $invoker;
$this->resource = $resource;
Expand All @@ -84,20 +92,26 @@ public function __construct(
'configuration' => $configuration
]);
$this->logger = $logger;
$this->registry = $registry ?? \Magento\Framework\App\ObjectManager::getInstance()
->get(Registry::class);
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function process($maxNumberOfMessages = null)
{
$this->registry->register('isSecureArea', true, true);

$queue = $this->configuration->getQueue();

if (!isset($maxNumberOfMessages)) {
$queue->subscribe($this->getTransactionCallback($queue));
} else {
$this->invoker->invoke($queue, $maxNumberOfMessages, $this->getTransactionCallback($queue));
}

$this->registry->unregister('isSecureArea');
}

/**
Expand Down
11 changes: 10 additions & 1 deletion app/code/Magento/Backend/Block/Template/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* the classes they were introduced for.
*
* @api
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
*/
Expand Down Expand Up @@ -173,6 +174,8 @@ public function getAuthorization()
}

/**
* Get Backend Session
*
* @return \Magento\Backend\Model\Session
*/
public function getBackendSession()
Expand All @@ -181,6 +184,8 @@ public function getBackendSession()
}

/**
* Get Math Random
*
* @return \Magento\Framework\Math\Random
*/
public function getMathRandom()
Expand All @@ -189,6 +194,8 @@ public function getMathRandom()
}

/**
* Get Form Key
*
* @return \Magento\Framework\Data\Form\FormKey
*/
public function getFormKey()
Expand All @@ -197,7 +204,9 @@ public function getFormKey()
}

/**
* @return \Magento\Framework\Data\Form\FormKey
* Get Class Name Builder
*
* @return \Magento\Framework\Code\NameBuilder
*/
public function getNameBuilder()
{
Expand Down
15 changes: 13 additions & 2 deletions app/code/Magento/Backup/Model/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @method string getPath()
* @method string getName()
* @method string getTime()
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @api
* @since 100.0.2
Expand Down Expand Up @@ -80,6 +81,7 @@ class Backup extends \Magento\Framework\DataObject implements \Magento\Framework
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Magento\Framework\Filesystem $filesystem
* @param array $data
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function __construct(
\Magento\Backup\Helper\Data $helper,
Expand Down Expand Up @@ -242,7 +244,7 @@ public function setFile(&$content)
/**
* Return content of backup file
*
* @return string
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function &getFile()
Expand Down Expand Up @@ -275,8 +277,9 @@ public function deleteFile()
*
* @param bool $write
* @return $this
* @throws \Magento\Framework\Exception\InputException
* @throws \Magento\Framework\Backup\Exception\NotEnoughPermissions
* @throws \Magento\Framework\Exception\FileSystemException
* @throws \Magento\Framework\Exception\InputException
*/
public function open($write = false)
{
Expand Down Expand Up @@ -330,6 +333,7 @@ protected function _getStream()
*
* @param int $length
* @return string
* @throws \Magento\Framework\Exception\InputException
*/
public function read($length)
{
Expand All @@ -340,6 +344,7 @@ public function read($length)
* Check end of file.
*
* @return bool
* @throws \Magento\Framework\Exception\InputException
*/
public function eof()
{
Expand Down Expand Up @@ -370,6 +375,7 @@ public function write($string)
* Close open backup file
*
* @return $this
* @throws \Magento\Framework\Exception\InputException
*/
public function close()
{
Expand All @@ -383,6 +389,8 @@ public function close()
* Print output
*
* @return string
* @return \Magento\Framework\Filesystem\Directory\ReadInterface|string|void
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function output()
{
Expand All @@ -398,6 +406,8 @@ public function output()
}

/**
* Get Size
*
* @return int|mixed
*/
public function getSize()
Expand All @@ -419,6 +429,7 @@ public function getSize()
*
* @param string $password
* @return bool
* @throws \Exception
*/
public function validateUserPassword($password)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ $isElementReadonly = $block->getElement()
->getReadonly();
?>

<?php if (!($attributeCode === 'price' && $block->getCanReadPrice() === false)) { ?>
<?php if (!($attributeCode === 'price' && $block->getCanReadPrice() === false)): ?>
<div class="<?= /* @escapeNotVerified */ $attributeCode ?> "><?= /* @escapeNotVerified */ $elementHtml ?></div>
<?php } ?>
<?php endif; ?>

<?= $block->getExtendedElement($switchAttributeCode)->toHtml() ?>

Expand All @@ -43,13 +43,13 @@ $isElementReadonly = $block->getElement()
} else {
if ($attribute) {
<?php if ($attributeCode === 'price' && !$block->getCanEditPrice() && $block->getCanReadPrice()
&& $block->getProduct()->isObjectNew()) { ?>
&& $block->getProduct()->isObjectNew()): ?>
<?php $defaultProductPrice = $block->getDefaultProductPrice() ?: "''"; ?>
$attribute.value = <?= /* @escapeNotVerified */ $defaultProductPrice ?>;
<?php } else { ?>
<?php else: ?>
$attribute.disabled = false;
$attribute.addClassName('required-entry');
<?php } ?>
<?php endif; ?>
}
if ($('dynamic-price-warning')) {
$('dynamic-price-warning').hide();
Expand All @@ -58,9 +58,9 @@ $isElementReadonly = $block->getElement()
}

<?php if (!($attributeCode === 'price' && !$block->getCanEditPrice()
&& !$block->getProduct()->isObjectNew())) { ?>
&& !$block->getProduct()->isObjectNew())): ?>
$('<?= /* @escapeNotVerified */ $switchAttributeCode ?>').observe('change', <?= /* @escapeNotVerified */ $switchAttributeCode ?>_change);
<?php } ?>
<?php endif; ?>
Event.observe(window, 'load', function(){
<?= /* @escapeNotVerified */ $switchAttributeCode ?>_change();
});
Expand Down
23 changes: 22 additions & 1 deletion app/code/Magento/CacheInvalidate/Model/PurgeCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ private function splitTags($tagsPattern)
private function sendPurgeRequestToServers($socketAdapter, $servers, $formattedTagsChunk)
{
$headers = [self::HEADER_X_MAGENTO_TAGS_PATTERN => $formattedTagsChunk];
$unresponsiveServerError = [];
foreach ($servers as $server) {
$headers['Host'] = $server->getHost();
try {
Expand All @@ -131,10 +132,30 @@ private function sendPurgeRequestToServers($socketAdapter, $servers, $formattedT
$socketAdapter->read();
$socketAdapter->close();
} catch (\Exception $e) {
$this->logger->critical($e->getMessage(), compact('server', 'formattedTagsChunk'));
$unresponsiveServerError[] = "Cache host: " . $server->getHost() . ":" . $server->getPort() .
"resulted in error message: " . $e->getMessage();
}
}

$errorCount = count($unresponsiveServerError);

if ($errorCount > 0) {
$loggerMessage = implode(" ", $unresponsiveServerError);

if ($errorCount == count($servers)) {
$this->logger->critical(
'No cache server(s) could be purged ' . $loggerMessage,
compact('server', 'formattedTagsChunk')
);
return false;
}

$this->logger->warning(
'Unresponsive cache server(s) hit' . $loggerMessage,
compact('server', 'formattedTagsChunk')
);
}

$this->logger->execute(compact('servers', 'formattedTagsChunk'));
return true;
}
Expand Down
6 changes: 5 additions & 1 deletion app/code/Magento/Catalog/Block/Product/View/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use Magento\Framework\Pricing\PriceCurrencyInterface;

/**
* Attributes attributes block
*
* @api
* @since 100.0.2
*/
Expand Down Expand Up @@ -56,6 +58,8 @@ public function __construct(
}

/**
* Returns a Product
*
* @return Product
*/
public function getProduct()
Expand Down Expand Up @@ -88,7 +92,7 @@ public function getAdditionalData(array $excludeAttr = [])
$value = $this->priceCurrency->convertAndFormat($value);
}

if (is_string($value) && strlen($value)) {
if (is_string($value) && strlen(trim($value))) {
$data[$attribute->getAttributeCode()] = [
'label' => __($attribute->getStoreLabel()),
'value' => $value,
Expand Down
22 changes: 14 additions & 8 deletions app/code/Magento/Catalog/Block/Product/View/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
* See COPYING.txt for license details.
*/

/**
* Product options block
*
* @author Magento Core Team <core@magentocommerce.com>
*/
namespace Magento\Catalog\Block\Product\View;

use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Option\Value;

/**
* Product options block
*
* @author Magento Core Team <core@magentocommerce.com>
* @api
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
Expand Down Expand Up @@ -121,6 +120,8 @@ public function setProduct(Product $product = null)
}

/**
* Get group of option.
*
* @param string $type
* @return string
*/
Expand All @@ -142,6 +143,8 @@ public function getOptions()
}

/**
* Check if block has options.
*
* @return bool
*/
public function hasOptions()
Expand All @@ -160,7 +163,10 @@ public function hasOptions()
*/
protected function _getPriceConfiguration($option)
{
$optionPrice = $this->pricingHelper->currency($option->getPrice(true), false, false);
$optionPrice = $option->getPrice(true);
if ($option->getPriceType() !== Value::TYPE_PERCENT) {
$optionPrice = $this->pricingHelper->currency($optionPrice, false, false);
}
$data = [
'prices' => [
'oldPrice' => [
Expand Down Expand Up @@ -195,7 +201,7 @@ protected function _getPriceConfiguration($option)
],
],
'type' => $option->getPriceType(),
'name' => $option->getTitle()
'name' => $option->getTitle(),
];
return $data;
}
Expand Down Expand Up @@ -231,7 +237,7 @@ public function getJsonConfig()
//pass the return array encapsulated in an object for the other modules to be able to alter it eg: weee
$this->_eventManager->dispatch('catalog_product_option_price_configuration_after', ['configObj' => $configObj]);

$config=$configObj->getConfig();
$config = $configObj->getConfig();

return $this->_jsonEncoder->encode($config);
}
Expand Down
6 changes: 4 additions & 2 deletions app/code/Magento/Catalog/Block/Ui/ProductViewCounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
/**
* Reports Viewed Products Counter
*
* The main responsilibity of this class is provide necessary data to track viewed products
* by customer on frontend and data to synchornize this tracks with backend
* The main responsibility of this class is provide necessary data to track viewed products
* by customer on frontend and data to synchronize this tracks with backend
*
* @api
* @since 101.1.0
Expand Down Expand Up @@ -109,6 +109,8 @@ public function __construct(
*
* @return string {JSON encoded data}
* @since 101.1.0
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function getCurrentProductData()
{
Expand Down
Loading

0 comments on commit 5328404

Please sign in to comment.