Skip to content

Commit 55885eb

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - magento-engcom/magento2ce#1031: #8168: Configurable product on wishlist shows parent image instead variation image (by @RomaKis) - #12893: Improvement: Magento\Sales\Helper\Guest refactoring and bugfix (by @coderimus) - #14128: ISSUE-14109: Allow modification of cookies via extension (by @brideo) - #13653: Update Store getConfig() to respect valid false return value (by @JeroenVanLeusden) - #14091: Remove sjparkinson/static-review and other obsolete tools (by @orlangur) Fixed GitHub Issues: - #8168: Configurable product on wishlist shows parent image instead variation image (reported by @anebi) has been fixed in magento-engcom/magento2ce#1031 by @RomaKis in 2.2-develop branch Related commits: 1. 93a5c39 - #14109: `MAX_NUM_COOKIES` doesn't follow the open-closed principle (reported by @brideo) has been fixed in #14128 by @brideo in 2.2-develop branch Related commits: 1. 9b34bf9 - #14138: Outdated package after upgrade sjparkinson/static-review is abandoned (reported by @woshka) has been fixed in #14091 by @orlangur in 2.2-develop branch Related commits: 1. 9cd24a1
2 parents 6030506 + cd95c4c commit 55885eb

File tree

22 files changed

+93
-930
lines changed

22 files changed

+93
-930
lines changed

.php_cs.dist

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

7-
/**
8-
* Pre-commit hook installation:
9-
* vendor/bin/static-review.php hook:install dev/tools/Magento/Tools/StaticReview/pre-commit .git/hooks/pre-commit
10-
*/
117
$finder = PhpCsFixer\Finder::create()
128
->name('*.phtml')
139
->exclude('dev/tests/functional/generated')

app/code/Magento/Catalog/Block/Product/ImageBuilder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ protected function getRatio(\Magento\Catalog\Helper\Image $helper)
121121
*/
122122
public function create()
123123
{
124+
/** @var \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface $simpleOption */
125+
$simpleOption = $this->product->getCustomOption('simple_product');
126+
127+
if ($simpleOption !== null) {
128+
$optionProduct = $simpleOption->getProduct();
129+
$this->setProduct($optionProduct);
130+
}
131+
124132
/** @var \Magento\Catalog\Helper\Image $helper */
125133
$helper = $this->helperFactory->create()
126134
->init($this->product, $this->imageId);

app/code/Magento/Catalog/Test/Unit/Block/Product/ImageBuilderTest.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,64 @@ private function getTestDataWithAttributes(): array
290290
],
291291
];
292292
}
293+
294+
/**
295+
* @param array $data
296+
* @param array $expected
297+
* @dataProvider createDataProvider
298+
*/
299+
public function testCreateWithSimpleProduct($data, $expected)
300+
{
301+
$imageId = 'test_image_id';
302+
303+
$productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
304+
$simpleOptionMock = $this->createMock(\Magento\Wishlist\Model\Item\Option::class);
305+
$simpleProductMock = $this->createMock(\Magento\Catalog\Model\Product::class);
306+
307+
$productMock->expects($this->once())->method('getCustomOption')
308+
->with('simple_product')->willReturn($simpleOptionMock);
309+
310+
$simpleOptionMock->expects($this->once())->method('getProduct')->willReturn($simpleProductMock);
311+
312+
$helperMock = $this->createMock(\Magento\Catalog\Helper\Image::class);
313+
$helperMock->expects($this->once())
314+
->method('init')
315+
->with($simpleProductMock, $imageId)
316+
->willReturnSelf();
317+
$helperMock->expects($this->once())
318+
->method('getFrame')
319+
->willReturn($data['frame']);
320+
$helperMock->expects($this->once())
321+
->method('getUrl')
322+
->willReturn($data['url']);
323+
$helperMock->expects($this->exactly(2))
324+
->method('getWidth')
325+
->willReturn($data['width']);
326+
$helperMock->expects($this->exactly(2))
327+
->method('getHeight')
328+
->willReturn($data['height']);
329+
$helperMock->expects($this->once())
330+
->method('getLabel')
331+
->willReturn($data['label']);
332+
$helperMock->expects($this->once())
333+
->method('getResizedImageInfo')
334+
->willReturn($data['imagesize']);
335+
336+
$this->helperFactory->expects($this->once())
337+
->method('create')
338+
->willReturn($helperMock);
339+
340+
$imageMock = $this->createMock(\Magento\Catalog\Block\Product\Image::class);
341+
342+
$this->imageFactory->expects($this->once())
343+
->method('create')
344+
->with($expected)
345+
->willReturn($imageMock);
346+
347+
$this->model->setProduct($productMock);
348+
$this->model->setImageId($imageId);
349+
$this->model->setAttributes($data['custom_attributes']);
350+
351+
$this->assertInstanceOf(\Magento\Catalog\Block\Product\Image::class, $this->model->create());
352+
}
293353
}

app/code/Magento/Sales/Helper/Guest.php

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Guest extends \Magento\Framework\App\Helper\AbstractHelper
8383
/**
8484
* @var \Magento\Store\Model\StoreManagerInterface
8585
*/
86-
private $_storeManager;
86+
private $storeManager;
8787

8888
/**
8989
* @var string
@@ -119,7 +119,7 @@ public function __construct(
119119
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteria = null
120120
) {
121121
$this->coreRegistry = $coreRegistry;
122-
$this->_storeManager = $storeManager;
122+
$this->storeManager = $storeManager;
123123
$this->customerSession = $customerSession;
124124
$this->cookieManager = $cookieManager;
125125
$this->cookieMetadataFactory = $cookieMetadataFactory;
@@ -158,9 +158,10 @@ public function loadValidOrder(App\RequestInterface $request)
158158
// It is unique place in the class that process exception and only InputException. It is need because by
159159
// input data we found order and one more InputException could be throws deeper in stack trace
160160
try {
161-
$order = (!empty($post) && isset($post['oar_order_id'], $post['oar_type']))
161+
$order = (!empty($post)
162+
&& isset($post['oar_order_id'], $post['oar_type'])
163+
&& !$this->hasPostDataEmptyFields($post))
162164
? $this->loadFromPost($post) : $this->loadFromCookie($fromCookie);
163-
$this->validateOrderStoreId($order->getStoreId());
164165
$this->coreRegistry->register('current_order', $order);
165166
return true;
166167
} catch (InputException $e) {
@@ -186,7 +187,7 @@ public function getBreadcrumbs(\Magento\Framework\View\Result\Page $resultPage)
186187
[
187188
'label' => __('Home'),
188189
'title' => __('Go to Home Page'),
189-
'link' => $this->_storeManager->getStore()->getBaseUrl()
190+
'link' => $this->storeManager->getStore()->getBaseUrl()
190191
]
191192
);
192193
$breadcrumbs->addCrumb(
@@ -247,12 +248,9 @@ private function loadFromCookie($fromCookie)
247248
*/
248249
private function loadFromPost(array $postData)
249250
{
250-
if ($this->hasPostDataEmptyFields($postData)) {
251-
throw new InputException();
252-
}
253251
/** @var $order \Magento\Sales\Model\Order */
254252
$order = $this->getOrderRecord($postData['oar_order_id']);
255-
if (!$this->compareSoredBillingDataWithInput($order, $postData)) {
253+
if (!$this->compareStoredBillingDataWithInput($order, $postData)) {
256254
throw new InputException(__('You entered incorrect data. Please try again.'));
257255
}
258256
$toCookie = base64_encode($order->getProtectCode() . ':' . $postData['oar_order_id']);
@@ -267,7 +265,7 @@ private function loadFromPost(array $postData)
267265
* @param array $postData
268266
* @return bool
269267
*/
270-
private function compareSoredBillingDataWithInput(Order $order, array $postData)
268+
private function compareStoredBillingDataWithInput(Order $order, array $postData)
271269
{
272270
$type = $postData['oar_type'];
273271
$email = $postData['oar_email'];
@@ -288,7 +286,7 @@ private function compareSoredBillingDataWithInput(Order $order, array $postData)
288286
private function hasPostDataEmptyFields(array $postData)
289287
{
290288
return empty($postData['oar_order_id']) || empty($postData['oar_billing_lastname']) ||
291-
empty($postData['oar_type']) || empty($this->_storeManager->getStore()->getId()) ||
289+
empty($postData['oar_type']) || empty($this->storeManager->getStore()->getId()) ||
292290
!in_array($postData['oar_type'], ['email', 'zip'], true) ||
293291
('email' === $postData['oar_type'] && empty($postData['oar_email'])) ||
294292
('zip' === $postData['oar_type'] && empty($postData['oar_zip']));
@@ -306,26 +304,15 @@ private function getOrderRecord($incrementId)
306304
$records = $this->orderRepository->getList(
307305
$this->searchCriteriaBuilder
308306
->addFilter('increment_id', $incrementId)
307+
->addFilter('store_id', $this->storeManager->getStore()->getId())
309308
->create()
310309
);
311-
if ($records->getTotalCount() < 1) {
312-
throw new InputException(__($this->inputExceptionMessage));
313-
}
314-
$items = $records->getItems();
315-
return array_shift($items);
316-
}
317310

318-
/**
319-
* Check that store_id from order are equals with system
320-
*
321-
* @param int $orderStoreId
322-
* @return void
323-
* @throws InputException
324-
*/
325-
private function validateOrderStoreId($orderStoreId)
326-
{
327-
if ($orderStoreId != $this->_storeManager->getStore()->getId()) {
311+
$items = $records->getItems();
312+
if (empty($items)) {
328313
throw new InputException(__($this->inputExceptionMessage));
329314
}
315+
316+
return array_shift($items);
330317
}
331318
}

app/code/Magento/Store/Model/Store.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,8 @@ public function setName($name)
535535
public function getConfig($path)
536536
{
537537
$data = $this->_config->getValue($path, ScopeInterface::SCOPE_STORE, $this->getCode());
538-
if (!$data) {
539-
$data = $this->_config->getValue($path, ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
538+
if ($data === null) {
539+
$data = $this->_config->getValue($path);
540540
}
541541
return $data === false ? null : $data;
542542
}

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
"ext-zip": "*",
7171
"ext-pdo_mysql": "*",
7272
"ext-soap": "*",
73-
"sjparkinson/static-review": "~4.1",
7473
"ramsey/uuid": "~3.7.3"
7574
},
7675
"require-dev": {

composer.lock

Lines changed: 1 addition & 104 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Format: <componentType=module|library|theme|language|*> <componentName> <globPattern> or simply <globPattern>
22
* * /
3-
dev/tools/Magento
43
dev/tests
54
phpserver
65
pub

dev/tools/Magento/Tools/Layout/processors/addItemRenderer.xsl

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)