Skip to content

Commit bb8c85b

Browse files
committed
Merge remote-tracking branch 'mainline/2.2-develop' into 2.2-develop-pr32
2 parents 6759709 + 308b9c0 commit bb8c85b

File tree

55 files changed

+888
-730
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+888
-730
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Magento\Framework\Exception\FileSystemException;
2020
use Magento\Framework\App\ObjectManager;
2121
use Magento\Backend\Block\DataProviders\UploadConfig as ImageUploadConfigDataProvider;
22+
use Magento\MediaStorage\Helper\File\Storage\Database;
2223

2324
class Content extends \Magento\Backend\Block\Widget
2425
{
@@ -47,25 +48,34 @@ class Content extends \Magento\Backend\Block\Widget
4748
*/
4849
private $imageHelper;
4950

51+
/**
52+
* @var Database
53+
*/
54+
private $fileStorageDatabase;
55+
5056
/**
5157
* @param \Magento\Backend\Block\Template\Context $context
5258
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
5359
* @param \Magento\Catalog\Model\Product\Media\Config $mediaConfig
5460
* @param array $data
5561
* @param ImageUploadConfigDataProvider $imageUploadConfigDataProvider
62+
* @param Database $fileStorageDatabase
5663
*/
5764
public function __construct(
5865
\Magento\Backend\Block\Template\Context $context,
5966
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
6067
\Magento\Catalog\Model\Product\Media\Config $mediaConfig,
6168
array $data = [],
62-
ImageUploadConfigDataProvider $imageUploadConfigDataProvider = null
69+
ImageUploadConfigDataProvider $imageUploadConfigDataProvider = null,
70+
Database $fileStorageDatabase = null
6371
) {
6472
$this->_jsonEncoder = $jsonEncoder;
6573
$this->_mediaConfig = $mediaConfig;
6674
parent::__construct($context, $data);
6775
$this->imageUploadConfigDataProvider = $imageUploadConfigDataProvider
6876
?: ObjectManager::getInstance()->get(ImageUploadConfigDataProvider::class);
77+
$this->fileStorageDatabase = $fileStorageDatabase
78+
?: ObjectManager::getInstance()->get(Database::class);
6979
}
7080

7181
/**
@@ -153,6 +163,13 @@ public function getImagesJson()
153163
$images = $this->sortImagesByPosition($value['images']);
154164
foreach ($images as &$image) {
155165
$image['url'] = $this->_mediaConfig->getMediaUrl($image['file']);
166+
if ($this->fileStorageDatabase->checkDbUsage() &&
167+
!$mediaDir->isFile($this->_mediaConfig->getMediaPath($image['file']))
168+
) {
169+
$this->fileStorageDatabase->saveFileToFilesystem(
170+
$this->_mediaConfig->getMediaPath($image['file'])
171+
);
172+
}
156173
try {
157174
$fileHandler = $mediaDir->stat($this->_mediaConfig->getMediaPath($image['file']));
158175
$image['size'] = $fileHandler['size'];

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Catalog\Model\Entity\Attribute;
1010
use Magento\Catalog\Model\Product;
1111
use Magento\Framework\Phrase;
12+
use Magento\MediaStorage\Helper\File\Storage\Database;
1213

1314
/**
1415
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -50,6 +51,11 @@ class ContentTest extends \PHPUnit\Framework\TestCase
5051
*/
5152
protected $imageHelper;
5253

54+
/**
55+
* @var \Magento\MediaStorage\Helper\File\Storage\Database|\PHPUnit_Framework_MockObject_MockObject
56+
*/
57+
protected $databaseMock;
58+
5359
/**
5460
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
5561
*/
@@ -71,13 +77,18 @@ public function setUp()
7177
->disableOriginalConstructor()
7278
->getMock();
7379

80+
$this->databaseMock = $this->getMockBuilder(Database::class)
81+
->disableOriginalConstructor()
82+
->getMock();
83+
7484
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
7585
$this->content = $this->objectManager->getObject(
7686
\Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery\Content::class,
7787
[
7888
'mediaConfig' => $this->mediaConfigMock,
7989
'jsonEncoder' => $this->jsonEncoderMock,
80-
'filesystem' => $this->fileSystemMock
90+
'filesystem' => $this->fileSystemMock,
91+
'fileStorageDatabase' => $this->databaseMock
8192
]
8293
);
8394
}
@@ -143,6 +154,13 @@ public function testGetImagesJson()
143154
$this->readMock->expects($this->any())->method('stat')->willReturnMap($sizeMap);
144155
$this->jsonEncoderMock->expects($this->once())->method('encode')->willReturnCallback('json_encode');
145156

157+
$this->readMock->expects($this->any())
158+
->method('isFile')
159+
->will($this->returnValue(true));
160+
$this->databaseMock->expects($this->any())
161+
->method('checkDbUsage')
162+
->will($this->returnValue(false));
163+
146164
$this->assertSame(json_encode($imagesResult), $this->content->getImagesJson());
147165
}
148166

@@ -221,6 +239,13 @@ public function testGetImagesJsonWithException()
221239
$this->imageHelper->expects($this->any())->method('getDefaultPlaceholderUrl')->willReturn($placeholderUrl);
222240
$this->jsonEncoderMock->expects($this->once())->method('encode')->willReturnCallback('json_encode');
223241

242+
$this->readMock->expects($this->any())
243+
->method('isFile')
244+
->will($this->returnValue(true));
245+
$this->databaseMock->expects($this->any())
246+
->method('checkDbUsage')
247+
->will($this->returnValue(false));
248+
224249
$this->assertSame(json_encode($imagesResult), $this->content->getImagesJson());
225250
}
226251

@@ -365,4 +390,52 @@ private function getMediaAttribute(string $label, string $attributeCode)
365390

366391
return $mediaAttribute;
367392
}
393+
394+
/**
395+
* Test GetImagesJson() calls MediaStorage functions to obtain image from DB prior to stat call
396+
*
397+
* @return void
398+
*/
399+
public function testGetImagesJsonMediaStorageMode()
400+
{
401+
$images = [
402+
'images' => [
403+
[
404+
'value_id' => '0',
405+
'file' => 'file_1.jpg',
406+
'media_type' => 'image',
407+
'position' => '0'
408+
]
409+
]
410+
];
411+
412+
$mediaPath = [
413+
['file_1.jpg', 'catalog/product/image_1.jpg']
414+
];
415+
416+
$this->content->setElement($this->galleryMock);
417+
418+
$this->galleryMock->expects($this->once())
419+
->method('getImages')
420+
->willReturn($images);
421+
$this->fileSystemMock->expects($this->once())
422+
->method('getDirectoryRead')
423+
->willReturn($this->readMock);
424+
$this->mediaConfigMock->expects($this->any())
425+
->method('getMediaPath')
426+
->willReturnMap($mediaPath);
427+
428+
$this->readMock->expects($this->any())
429+
->method('isFile')
430+
->will($this->returnValue(false));
431+
$this->databaseMock->expects($this->any())
432+
->method('checkDbUsage')
433+
->will($this->returnValue(true));
434+
435+
$this->databaseMock->expects($this->once())
436+
->method('saveFileToFilesystem')
437+
->with('catalog/product/image_1.jpg');
438+
439+
$this->content->getImagesJson();
440+
}
368441
}

app/code/Magento/Checkout/Model/ShippingInformationManagement.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ public function saveAddressInformation(
178178

179179
$shippingAddress = $quote->getShippingAddress();
180180

181-
if (!$shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod())) {
181+
if (!$quote->getIsVirtual()
182+
&& !$shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod())
183+
) {
182184
throw new NoSuchEntityException(
183185
__('Carrier with such method not found: %1, %2', $carrierCode, $methodCode)
184186
);

app/code/Magento/Customer/view/frontend/layout/customer_account_forgotpassword.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<head>
10-
<title>Forgot Your Password</title>
10+
<title>Forgot Your Password?</title>
1111
</head>
1212
<body>
1313
<referenceBlock name="root">

app/code/Magento/Review/Block/Adminhtml/Edit/Form.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
78
/**
89
* Adminhtml Review Edit Form
910
*/
@@ -69,23 +70,32 @@ public function __construct(
6970
*
7071
* @return $this
7172
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
73+
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
7274
*/
7375
protected function _prepareForm()
7476
{
7577
$review = $this->_coreRegistry->registry('review_data');
7678
$product = $this->_productFactory->create()->load($review->getEntityPkValue());
7779

80+
$formActionParams =[
81+
'id' => $this->getRequest()->getParam('id'),
82+
'ret' => $this->_coreRegistry->registry('ret')
83+
];
84+
if ($this->getRequest()->getParam('productId')) {
85+
$formActionParams['productId'] = $this->getRequest()->getParam('productId');
86+
}
87+
if ($this->getRequest()->getParam('customerId')) {
88+
$formActionParams['customerId'] = $this->getRequest()->getParam('customerId');
89+
}
90+
7891
/** @var \Magento\Framework\Data\Form $form */
7992
$form = $this->_formFactory->create(
8093
[
8194
'data' => [
8295
'id' => 'edit_form',
8396
'action' => $this->getUrl(
8497
'review/*/save',
85-
[
86-
'id' => $this->getRequest()->getParam('id'),
87-
'ret' => $this->_coreRegistry->registry('ret')
88-
]
98+
$formActionParams
8999
),
90100
'method' => 'post',
91101
],

app/code/Magento/Review/Controller/Adminhtml/Product/Save.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ public function execute()
7272
} else {
7373
$resultRedirect->setPath('*/*/');
7474
}
75+
$productId = $this->getRequest()->getParam('productId');
76+
if ($productId) {
77+
$resultRedirect->setPath("catalog/product/edit/id/$productId");
78+
}
79+
$customerId = (int)$this->getRequest()->getParam('customerId');
80+
if ($customerId) {
81+
$resultRedirect->setPath("customer/index/edit/id/$customerId");
82+
}
7583
return $resultRedirect;
7684
}
7785
$resultRedirect->setPath('review/*/');

app/code/Magento/Tax/view/adminhtml/templates/items/price/row.phtml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,27 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
7-
// @codingStandardsIgnoreFile
8-
96
?>
107
<?php
118
/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $block */
129

1310
$_item = $block->getItem();
1411
?>
15-
16-
<?php if ($block->displayBothPrices() || $block->displayPriceExclTax()): ?>
12+
<?php if ($block->displayBothPrices() || $block->displayPriceExclTax()) : ?>
1713
<div class="price-excl-tax">
18-
<?php if ($block->displayBothPrices()): ?>
19-
<span class="label"><?= /* @escapeNotVerified */ __('Excl. Tax') ?>:</span>
14+
<?php if ($block->displayBothPrices()) : ?>
15+
<span class="label"><?= $block->escapeHtml(__('Excl. Tax')) ?>:</span>
2016
<?php endif; ?>
21-
<?= /* @escapeNotVerified */ $block->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?>
17+
<?= /* @noEscape */ $block->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?>
2218
</div>
2319
<?php endif; ?>
24-
<?php if ($block->displayBothPrices() || $block->displayPriceInclTax()): ?>
20+
<?php if ($block->displayBothPrices() || $block->displayPriceInclTax()) : ?>
2521
<div class="price-incl-tax">
26-
<?php if ($block->displayBothPrices()): ?>
27-
<span class="label"><?= /* @escapeNotVerified */ __('Incl. Tax') ?>:</span>
22+
<?php if ($block->displayBothPrices()) : ?>
23+
<span class="label"><?= $block->escapeHtml(__('Incl. Tax')) ?>:</span>
2824
<?php endif; ?>
29-
<?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?>
30-
<?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBaseSubtotalInclTax($_item); ?>
31-
<?= /* @escapeNotVerified */ $block->displayPrices($_baseIncl, $_incl) ?>
25+
<?php $_incl = $this->helper(\Magento\Checkout\Helper\Data::class)->getSubtotalInclTax($_item); ?>
26+
<?php $_baseIncl = $this->helper(\Magento\Checkout\Helper\Data::class)->getBaseSubtotalInclTax($_item); ?>
27+
<?= /* @noEscape */ $block->displayPrices($_baseIncl, $_incl) ?>
3228
</div>
3329
<?php endif; ?>

app/code/Magento/Tax/view/adminhtml/templates/items/price/total.phtml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
7-
// @codingStandardsIgnoreFile
8-
6+
// phpcs:disable PSR2.Files.ClosingTag
97
?>
108
<?php
119
/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $block */
1210

1311
$_item = $block->getItem();
1412
?>
1513

16-
<?= /* @escapeNotVerified */ $block->displayPrices($block->getBaseTotalAmount($_item), $block->getTotalAmount($_item)) ?>
14+
<?= /* @noEscape */ $block->displayPrices($block->getBaseTotalAmount($_item), $block->getTotalAmount($_item)) ?>

app/code/Magento/Tax/view/adminhtml/templates/items/price/unit.phtml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,31 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
7-
// @codingStandardsIgnoreFile
8-
96
?>
107
<?php
118
/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $block */
129

1310
$_item = $block->getItem();
1411
?>
1512

16-
<?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?>
13+
<?php if ($this->helper(\Magento\Tax\Helper\Data::class)->displaySalesBothPrices() || $this->helper(\Magento\Tax\Helper\Data::class)->displaySalesPriceExclTax()) : ?>
1714
<div class="price-excl-tax">
18-
<?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?>
19-
<span class="label"><?= /* @escapeNotVerified */ __('Excl. Tax') ?>:</span>
15+
<?php if ($this->helper(\Magento\Tax\Helper\Data::class)->displaySalesBothPrices()) : ?>
16+
<span class="label"><?= $block->escapeHtml(__('Excl. Tax')) ?>:</span>
2017
<?php endif; ?>
2118

22-
<?= /* @escapeNotVerified */ $block->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?>
19+
<?= /* @noEscape */ $block->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?>
2320
</div>
2421
<?php endif; ?>
25-
<?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?>
22+
<?php if ($this->helper(\Magento\Tax\Helper\Data::class)->displaySalesBothPrices() || $this->helper(\Magento\Tax\Helper\Data::class)->displaySalesPriceInclTax()) : ?>
2623
<div class="price-incl-tax">
27-
<?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?>
28-
<span class="label"><?= /* @escapeNotVerified */ __('Incl. Tax') ?>:</span>
24+
<?php if ($this->helper(\Magento\Tax\Helper\Data::class)->displaySalesBothPrices()) : ?>
25+
<span class="label"><?= $block->escapeHtml(__('Incl. Tax')) ?>:</span>
2926
<?php endif; ?>
30-
<?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?>
31-
<?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBasePriceInclTax($_item); ?>
27+
<?php $_incl = $this->helper(\Magento\Checkout\Helper\Data::class)->getPriceInclTax($_item); ?>
28+
<?php $_baseIncl = $this->helper(\Magento\Checkout\Helper\Data::class)->getBasePriceInclTax($_item); ?>
3229

33-
<?= /* @escapeNotVerified */ $block->displayPrices($_baseIncl, $_incl) ?>
30+
<?= /* @noEscape */ $block->displayPrices($_baseIncl, $_incl) ?>
3431

3532
</div>
3633
<?php endif; ?>

app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/row.phtml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,24 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
7-
// @codingStandardsIgnoreFile
8-
96
?>
107
<?php
118
/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $block */
129

1310
$_item = $block->getItem();
1411
?>
1512

16-
<?php if ($block->displayPriceExclTax() || $block->displayBothPrices()): ?>
17-
<?php if ($block->displayBothPrices($block->getStore())): ?>
18-
<span class="label"><?= /* @escapeNotVerified */ __('Excl. Tax') ?>:</span>
13+
<?php if ($block->displayPriceExclTax() || $block->displayBothPrices()) : ?>
14+
<?php if ($block->displayBothPrices($block->getStore())) : ?>
15+
<span class="label"><?= $block->escapeHtml(__('Excl. Tax')) ?>:</span>
1916
<?php endif; ?>
20-
<?= /* @escapeNotVerified */ $block->formatPrice($_item->getRowTotal()) ?>
17+
<?= /* @noEscape */ $block->formatPrice($_item->getRowTotal()) ?>
2118
<?php endif; ?>
2219

23-
<?php if ($block->displayPriceInclTax() || $block->displayBothPrices()): ?>
24-
<?php if ($block->displayBothPrices()): ?>
25-
<br /><span class="label"><?= /* @escapeNotVerified */ __('Incl. Tax') ?>:</span>
20+
<?php if ($block->displayPriceInclTax() || $block->displayBothPrices()) : ?>
21+
<?php if ($block->displayBothPrices()) : ?>
22+
<br /><span class="label"><?= $block->escapeHtml(__('Incl. Tax')) ?>:</span>
2623
<?php endif; ?>
27-
<?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?>
28-
<?= /* @escapeNotVerified */ $block->formatPrice($_incl) ?>
24+
<?php $_incl = $this->helper(\Magento\Checkout\Helper\Data::class)->getSubtotalInclTax($_item); ?>
25+
<?= /* @noEscape */ $block->formatPrice($_incl) ?>
2926
<?php endif; ?>

0 commit comments

Comments
 (0)