Skip to content

Commit

Permalink
Merge pull request #2185 from magento-tango/2.2.4-PR-part-1
Browse files Browse the repository at this point in the history
Bugs:
- MAGETWO-71936 [GitHub] Error: Invalid input datetime format of value "'DD/MM/+********"'.
- MAGETWO-73479 Cart Rules are not excluding Bundle Products
- MAGETWO-84921 Swagger does not render correctly for many POST/PUT operations
- MAGETWO-89045 FATAL error on compiler generation on PHP 7.0.11
  • Loading branch information
VladimirZaets authored Mar 13, 2018
2 parents e314678 + 45eb281 commit f7ebf9d
Show file tree
Hide file tree
Showing 67 changed files with 758 additions and 30,814 deletions.
3 changes: 2 additions & 1 deletion app/code/Magento/Bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
},
"suggest": {
"magento/module-webapi": "100.2.*",
"magento/module-bundle-sample-data": "Sample Data version:100.2.*"
"magento/module-bundle-sample-data": "Sample Data version:100.2.*",
"magento/module-sales-rule": "101.0.*"
},
"type": "magento2-module",
"version": "100.2.2",
Expand Down
7 changes: 7 additions & 0 deletions app/code/Magento/Bundle/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,11 @@
</argument>
</arguments>
</type>
<type name="Magento\SalesRule\Model\Quote\ChildrenValidationLocator">
<arguments>
<argument name="productTypeChildrenValidationMap" xsi:type="array">
<item name="bundle" xsi:type="boolean">false</item>
</argument>
</arguments>
</type>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -264,23 +264,36 @@ protected function customizeNewDateRangeField(array $meta)
if ($fromFieldPath && $toFieldPath) {
$fromContainerPath = $this->arrayManager->slicePath($fromFieldPath, 0, -2);
$toContainerPath = $this->arrayManager->slicePath($toFieldPath, 0, -2);
$commonFieldsMeta = [
'outputDateTimeToISO' => false,
'inputDateTimeFormat' => 'YYYY-MM-DD h:mm',
'options' => [
'showsTime' => true,
]
];

$meta = $this->arrayManager->merge(
$fromFieldPath . self::META_CONFIG_PATH,
$meta,
[
'label' => __('Set Product as New From'),
'additionalClasses' => 'admin__field-date',
]
array_merge(
[
'label' => __('Set Product as New From'),
'additionalClasses' => 'admin__field-date',
],
$commonFieldsMeta
)
);
$meta = $this->arrayManager->merge(
$toFieldPath . self::META_CONFIG_PATH,
$meta,
[
'label' => __('To'),
'scopeLabel' => null,
'additionalClasses' => 'admin__field-date',
]
array_merge(
[
'label' => __('To'),
'scopeLabel' => null,
'additionalClasses' => 'admin__field-date',
],
$commonFieldsMeta
)
);
$meta = $this->arrayManager->merge(
$fromContainerPath . self::META_CONFIG_PATH,
Expand Down
7 changes: 3 additions & 4 deletions app/code/Magento/Payment/Model/Method/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
namespace Magento\Payment\Model\Method;

use Magento\Payment\Gateway\ConfigInterface;
use Psr\Log\LoggerInterface;

/**
Expand All @@ -24,17 +23,17 @@ class Logger
protected $logger;

/**
* @var ConfigInterface
* @var \Magento\Payment\Gateway\ConfigInterface
*/
private $config;

/**
* @param LoggerInterface $logger
* @param ConfigInterface $config
* @param \Magento\Payment\Gateway\ConfigInterface $config
*/
public function __construct(
LoggerInterface $logger,
ConfigInterface $config = null
\Magento\Payment\Gateway\ConfigInterface $config = null
) {
$this->logger = $logger;
$this->config = $config;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\SalesRule\Model\Quote;

use \Magento\Quote\Model\Quote\Item\AbstractItem as QuoteItem;

/**
* Class ChildrenValidationLocator
*
* Used to determine necessity to validate rule on item's children that may depends on product type
*/
class ChildrenValidationLocator
{
/**
* @var array
*/
private $productTypeChildrenValidationMap;

/**
* @param array $productTypeChildrenValidationMap
* <pre>
* [
* 'ProductType1' => true,
* 'ProductType2' => false
* ]
* </pre>
*/
public function __construct(
array $productTypeChildrenValidationMap = []
) {
$this->productTypeChildrenValidationMap = $productTypeChildrenValidationMap;
}

/**
* Checks necessity to validate rule on item's children
*
* @param QuoteItem $item
* @return bool
*/
public function isChildrenValidationRequired(QuoteItem $item): bool
{
$type = $item->getProduct()->getTypeId();
if (isset($this->productTypeChildrenValidationMap[$type])) {
return (bool)$this->productTypeChildrenValidationMap[$type];
}
return true;
}
}
21 changes: 20 additions & 1 deletion app/code/Magento/SalesRule/Model/RulesApplier.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
namespace Magento\SalesRule\Model;

use Magento\Quote\Model\Quote\Address;
use Magento\SalesRule\Model\Quote\ChildrenValidationLocator;
use Magento\Framework\App\ObjectManager;

/**
* Class RulesApplier
Expand All @@ -25,19 +27,33 @@ class RulesApplier
*/
protected $validatorUtility;

/**
* @var ChildrenValidationLocator
*/
private $childrenValidationLocator;

/**
* @var \Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory
*/
private $calculatorFactory;

/**
* @param \Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory $calculatorFactory
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\SalesRule\Model\Utility $utility
* @param ChildrenValidationLocator $childrenValidationLocator
*/
public function __construct(
\Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory $calculatorFactory,
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\SalesRule\Model\Utility $utility
\Magento\SalesRule\Model\Utility $utility,
ChildrenValidationLocator $childrenValidationLocator = null
) {
$this->calculatorFactory = $calculatorFactory;
$this->validatorUtility = $utility;
$this->_eventManager = $eventManager;
$this->childrenValidationLocator = $childrenValidationLocator
?: ObjectManager::getInstance()->get(ChildrenValidationLocator::class);
}

/**
Expand All @@ -61,6 +77,9 @@ public function applyRules($item, $rules, $skipValidation, $couponCode)
}

if (!$skipValidation && !$rule->getActions()->validate($item)) {
if (!$this->childrenValidationLocator->isChildrenValidationRequired($item)) {
continue;
}
$childItems = $item->getChildren();
$isContinue = true;
if (!empty($childItems)) {
Expand Down
20 changes: 18 additions & 2 deletions app/code/Magento/SalesRule/Test/Unit/Model/RulesApplierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace Magento\SalesRule\Test\Unit\Model;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class RulesApplierTest extends \PHPUnit\Framework\TestCase
{
/**
Expand All @@ -28,6 +31,11 @@ class RulesApplierTest extends \PHPUnit\Framework\TestCase
*/
protected $validatorUtility;

/**
* @var \Magento\SalesRule\Model\Quote\ChildrenValidationLocator|\PHPUnit_Framework_MockObject_MockObject
*/
protected $childrenValidationLocator;

protected function setUp()
{
$this->calculatorFactory = $this->createMock(
Expand All @@ -38,11 +46,15 @@ protected function setUp()
\Magento\SalesRule\Model\Utility::class,
['canProcessRule', 'minFix', 'deltaRoundingFix', 'getItemQty']
);

$this->childrenValidationLocator = $this->createPartialMock(
\Magento\SalesRule\Model\Quote\ChildrenValidationLocator::class,
['isChildrenValidationRequired']
);
$this->rulesApplier = new \Magento\SalesRule\Model\RulesApplier(
$this->calculatorFactory,
$this->eventManager,
$this->validatorUtility
$this->validatorUtility,
$this->childrenValidationLocator
);
}

Expand Down Expand Up @@ -84,6 +96,10 @@ public function testApplyRulesWhenRuleWithStopRulesProcessingIsUsed($isChildren,
$item->setDiscountCalculationPrice($positivePrice);
$item->setData('calculation_price', $positivePrice);

$this->childrenValidationLocator->expects($this->any())
->method('isChildrenValidationRequired')
->will($this->returnValue(true));

$this->validatorUtility->expects($this->atLeastOnce())
->method('canProcessRule')
->will($this->returnValue(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,26 @@
<title>Swagger UI</title>

<!--<title>Swagger UI assets</title>-->
<css src='Magento_Swagger::swagger-ui/css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
<css src='Magento_Swagger::swagger-ui/css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
<css src='Magento_Swagger::swagger-ui/css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
<css src='Magento_Swagger::swagger-ui/css/reset.css' media='print' rel='stylesheet' type='text/css'/>
<css src='Magento_Swagger::swagger-ui/css/print.css' media='print' rel='stylesheet' type='text/css'/>
<link src='Magento_Swagger::swagger-ui/js/lib/jquery-1.8.0.min.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lib/jquery.slideto.min.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lib/jquery.wiggle.min.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lib/jquery.ba-bbq.min.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lib/handlebars.min-v4.0.10.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lib/underscore-min.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lib/backbone-min.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lib/jsoneditor.min.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/swagger-ui.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lib/highlight.9.1.0.pack.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lib/highlight.9.1.0.pack_extended.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lib/lodash.min.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lib/object-assign-pollyfill.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lib/marked.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lib/swagger-oauth.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lang/translator.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lang/ru.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/lang/en.js' type='text/javascript'/>
<link src='Magento_Swagger::swagger-ui/js/magento-swagger.js' type='text/javascript'/>
<css src='Magento_Swagger::swagger-ui/css/style.css' media='screen' rel='stylesheet' type='text/css'/>
<css src='Magento_Swagger::swagger-ui/css/swagger-ui.css' media='screen' rel='stylesheet' type='text/css'/>
<link src='Magento_Swagger::swagger-ui/js/lang/translator.js' type='text/javascript' defer="defer"/>
<link src='Magento_Swagger::swagger-ui/js/lang/ru.js' type='text/javascript' defer="defer"/>
<link src='Magento_Swagger::swagger-ui/js/lang/en.js' type='text/javascript' defer="defer"/>
<link src='Magento_Swagger::swagger-ui/js/swagger-ui-bundle.js' type='text/javascript' defer="defer"/>
<link src='Magento_Swagger::swagger-ui/js/swagger-ui-standalone-preset.js' type='text/javascript' defer="defer"/>
<link src='Magento_Swagger::swagger-ui/js/magento-swagger.js' type='text/javascript' defer="defer"/>

<!--Remove require-js assets-->
<remove src="css/styles-m.css"/>
<remove src="css/styles-s.css"/>
<remove src="requirejs/require.js"/>
<remove src="mage/requirejs/mixins.js"/>
<remove src="requirejs-config.js"/>
</head>
<body>
<!--Remove Magento page content-->
<referenceContainer name="page.wrapper" remove="true"/>
<referenceBlock name="translate" remove="true"/>
<referenceBlock name="requirejs-config" remove="true"/>
<referenceContainer name="root">
<block name="swaggerUiContent" class="Magento\Swagger\Block\Index" template="Magento_Swagger::swagger-ui/index.phtml"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,48 @@
* Modified by Magento, Modifications Copyright © Magento, Inc. All rights reserved.
*/

/** @var \Magento\Swagger\Block\Index $block */
/** @var \Magento\Swagger\Block\Index $block
*
* @codingStandardsIgnoreFile
*/

$schemaUrl = $block->getSchemaUrl();
?>

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
<defs>
<symbol viewBox="0 0 20 20" id="unlocked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
</symbol>

<symbol viewBox="0 0 20 20" id="locked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/>
</symbol>

<symbol viewBox="0 0 20 20" id="close">
<path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/>
</symbol>

<symbol viewBox="0 0 20 20" id="large-arrow">
<path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/>
</symbol>

<symbol viewBox="0 0 20 20" id="large-arrow-down">
<path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/>
</symbol>


<symbol viewBox="0 0 24 24" id="jump-to">
<path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
</symbol>

<symbol viewBox="0 0 24 24" id="expand">
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
</symbol>

</defs>
</svg>

<div id='header'>
<div class="swagger-ui-wrap">
<a id="logo" href="http://swagger.io">swagger</a>
Expand Down
Loading

0 comments on commit f7ebf9d

Please sign in to comment.