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:
 - #17405: [Braintree] Added unit test for instant purchase PayPal token formatter (by @rogyar)
 - #15335: Fixed issue #13480 - Unable to activate logs after switching from production mode to developer (by @jayankaghosh)
 - #15606: Fix #10687 - Product image roles disappearing (by @Scarraban)
 - #15720: Convert to string $option->getValue, in order to be compared with oth� (by @zamboten)
 - #16597: Save configurable product options after validation error (by @swnsma)
 - #16955: fix: remove disabled attribute on region list (by @DanielRuf)
 - #14537: #12250: View.xml is inheriting image sizes from paren� (by @quisse)
 - #17078: MAGETWO-84608: Cannot perform setup:install if Redis needs a password� (by @guillaumegiordana)
 - #15691: Fix #4803: Incorrect return value from Product Attribute Repository (by @cream-julian)
 - #16724: 16544: fixed behaviour when some of JS validation rules making fields� (by @VitaliyBoyko)


Fixed GitHub Issues:
 - #13480: Unable to activate logs after switching from production mode to developer  (reported by @VincentMarmiesse) has been fixed in #15335 by @jayankaghosh in 2.2-develop branch
   Related commits:
     1. 540917e
     2. c6aabf8

 - #10687: Product image roles randomly disappear (reported by @boxyman) has been fixed in #15606 by @Scarraban in 2.2-develop branch
   Related commits:
     1. a99e97e

 - #15028: Configurable product addtocart with restAPI not working as expected (reported by @yspeedwicked) has been fixed in #15720 by @zamboten in 2.2-develop branch
   Related commits:
     1. 03298b3

 - #7372: Product images gets removed from "Images And Videos" after validation alert. (reported by @candia) has been fixed in #16597 by @swnsma in 2.2-develop branch
   Related commits:
     1. d866b18
     2. bc00d8e

 - #13177: Can't save attributes on a configurable product (reported by @bambamboole) has been fixed in #16597 by @swnsma in 2.2-develop branch
   Related commits:
     1. d866b18
     2. bc00d8e

 - #12250: View.xml is inheriting image sizes from parent (so an optional field is replaced by the value of parent) (reported by @quisse) has been fixed in #14537 by @quisse in 2.2-develop branch
   Related commits:
     1. ca47981
     2. 951d5e8
     3. 96c28a6

 - #4803: Incorrect return value from Product Attribute Repository (reported by @samtay) has been fixed in #15691 by @cream-julian in 2.2-develop branch
   Related commits:
     1. 4c1989e
     2. 215be5a
     3. 2639d0e
     4. 43dd85e

 - #16544: Some of JS validation rules making fields required (reported by @VitaliyBoyko) has been fixed in #16724 by @VitaliyBoyko in 2.2-develop branch
   Related commits:
     1. e189fc9
     2. 2ed9af3
     3. e71836b
     4. c6a8fec
  • Loading branch information
magento-engcom-team authored Aug 8, 2018
2 parents daff59a + 589401c commit b62b78b
Show file tree
Hide file tree
Showing 16 changed files with 254 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Braintree\Test\Unit\Model\InstantPurchase\PayPal;

use Magento\Braintree\Model\InstantPurchase\CreditCard\TokenFormatter as PaypalTokenFormatter;
use Magento\Vault\Api\Data\PaymentTokenInterface;

class TokenFormatterTest extends \PHPUnit\Framework\TestCase
{
/**
* @var PaymentTokenInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $paymentTokenMock;

/**
* @var PaypalTokenFormatter
*/
private $paypalTokenFormatter;

/**
* @var array
*/
private $tokenDetails = [
'type' => 'visa',
'maskedCC' => '4444************9999',
'expirationDate' => '07-07-2025'
];

protected function setUp()
{
$this->paymentTokenMock = $this->getMockBuilder(PaymentTokenInterface::class)
->getMockForAbstractClass();

$this->paypalTokenFormatter = new PaypalTokenFormatter();
}

public function testFormatPaymentTokenWithKnownCardType()
{
$this->tokenDetails['type'] = key(PaypalTokenFormatter::$baseCardTypes);
$this->paymentTokenMock->expects($this->once())
->method('getTokenDetails')
->willReturn(json_encode($this->tokenDetails));

$formattedString = sprintf(
'%s: %s, %s: %s (%s: %s)',
__('Credit Card'),
reset(PaypalTokenFormatter::$baseCardTypes),
__('ending'),
$this->tokenDetails['maskedCC'],
__('expires'),
$this->tokenDetails['expirationDate']
);

self::assertEquals($formattedString, $this->paypalTokenFormatter->formatPaymentToken($this->paymentTokenMock));
}

public function testFormatPaymentTokenWithUnknownCardType()
{
$this->paymentTokenMock->expects($this->once())
->method('getTokenDetails')
->willReturn(json_encode($this->tokenDetails));

$formattedString = sprintf(
'%s: %s, %s: %s (%s: %s)',
__('Credit Card'),
$this->tokenDetails['type'],
__('ending'),
$this->tokenDetails['maskedCC'],
__('expires'),
$this->tokenDetails['expirationDate']
);

self::assertEquals($formattedString, $this->paypalTokenFormatter->formatPaymentToken($this->paymentTokenMock));
}

public function testFormatPaymentTokenWithWrongData()
{
unset($this->tokenDetails['type']);

$this->paymentTokenMock->expects($this->once())
->method('getTokenDetails')
->willReturn(json_encode($this->tokenDetails));
self::expectException('\InvalidArgumentException');

$this->paypalTokenFormatter->formatPaymentToken($this->paymentTokenMock);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ public function execute()
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
$this->messageManager->addExceptionMessage($e);
$data = $this->persistMediaData($product, $data);
$data = isset($product) ? $this->persistMediaData($product, $data) : $data;
$this->getDataPersistor()->set('catalog_product', $data);
$redirectBack = $productId ? true : 'new';
} catch (\Exception $e) {
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
$this->messageManager->addErrorMessage($e->getMessage());
$data = $this->persistMediaData($product, $data);
$data = isset($product) ? $this->persistMediaData($product, $data) : $data;
$this->getDataPersistor()->set('catalog_product', $data);
$redirectBack = $productId ? true : 'new';
}
Expand Down
14 changes: 9 additions & 5 deletions app/code/Magento/Catalog/Model/ImageExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ public function process(\DOMElement $mediaNode, $mediaParentTag)
continue;
}
$attributeTagName = $attribute->tagName;
if ($attributeTagName === 'background') {
$nodeValue = $this->processImageBackground($attribute->nodeValue);
} elseif ($attributeTagName === 'width' || $attributeTagName === 'height') {
$nodeValue = intval($attribute->nodeValue);
if ((bool)$attribute->getAttribute('xsi:nil') !== true) {
if ($attributeTagName === 'background') {
$nodeValue = $this->processImageBackground($attribute->nodeValue);
} elseif ($attributeTagName === 'width' || $attributeTagName === 'height') {
$nodeValue = intval($attribute->nodeValue);
} else {
$nodeValue = $attribute->nodeValue;
}
} else {
$nodeValue = $attribute->nodeValue;
$nodeValue = null;
}
$result[$mediaParentTag][$moduleNameImage][Image::MEDIA_TYPE_CONFIG_NODE][$imageId][$attribute->tagName]
= $nodeValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,13 @@ public function processMediaGallery(ProductInterface $product, array $mediaGalle
$newEntries = $mediaGalleryEntries;
}

$this->processor->clearMediaAttribute($product, array_keys($product->getMediaAttributes()));
$images = $product->getMediaGallery('images');

if ($images) {
$images = $this->determineImageRoles($product, $images);
}

$this->processor->clearMediaAttribute($product, array_keys($product->getMediaAttributes()));
if ($images) {
foreach ($images as $image) {
if (!isset($image['removed']) && !empty($image['types'])) {
Expand All @@ -112,6 +117,32 @@ public function processMediaGallery(ProductInterface $product, array $mediaGalle
$this->processEntries($product, $newEntries, $entriesById);
}

/**
* Ascertain image roles, if they are not set against the gallery entries
*
* @param ProductInterface $product
* @param array $images
* @return array
*/
private function determineImageRoles(ProductInterface $product, array $images)
{
$imagesWithRoles = [];
foreach ($images as $image) {
if (!isset($image['types'])) {
$image['types'] = [];
if (isset($image['file'])) {
foreach (array_keys($product->getMediaAttributes()) as $attribute) {
if ($image['file'] == $product->getData($attribute)) {
$image['types'][] = $attribute;
}
}
}
}
$imagesWithRoles[] = $image;
}
return $imagesWithRoles;
}

/**
* Convert entries into product media gallery data and set to product.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ define([

if (!this.options.optionalRegionAllowed) { //eslint-disable-line max-depth
regionList.attr('disabled', 'disabled');
} else {
regionList.removeAttr('disabled');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function convertToBuyRequest(CartItemInterface $cartItem)
if (is_array($options)) {
$requestData = [];
foreach ($options as $option) {
$requestData['super_attribute'][$option->getOptionId()] = $option->getOptionValue();
$requestData['super_attribute'][$option->getOptionId()] = (string) $option->getOptionValue();
}
return $this->objectFactory->create($requestData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,17 @@ define([
* - associated_product_ids_serialized.
*/
serializeData: function () {
this.source.data['configurable-matrix-serialized'] =
JSON.stringify(this.source.data['configurable-matrix']);

delete this.source.data['configurable-matrix'];

this.source.data['associated_product_ids_serialized'] =
JSON.stringify(this.source.data['associated_product_ids']);
if (this.source.data['configurable-matrix']) {
this.source.data['configurable-matrix-serialized'] =
JSON.stringify(this.source.data['configurable-matrix']);
delete this.source.data['configurable-matrix'];
}

delete this.source.data['associated_product_ids'];
if (this.source.data['associated_product_ids']) {
this.source.data['associated_product_ids_serialized'] =
JSON.stringify(this.source.data['associated_product_ids']);
delete this.source.data['associated_product_ids'];
}
},

/**
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Deploy/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
<item name="production" xsi:type="array">
<item name="dev/debug/debug_logging" xsi:type="string">0</item>
</item>
<item name="developer" xsi:type="array">
<item name="dev/debug/debug_logging" xsi:type="null" />
</item>
</item>
</argument>
</arguments>
Expand Down
6 changes: 4 additions & 2 deletions app/code/Magento/Eav/Api/Data/AttributeInterface.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Eav\Api\Data;

use Magento\Framework\Api\CustomAttributesDataInterface;
use Magento\Framework\Api\MetadataObjectInterface;

/**
* Interface AttributeInterface
* @api
* @since 100.0.2
*/
interface AttributeInterface extends \Magento\Framework\Api\CustomAttributesDataInterface
interface AttributeInterface extends CustomAttributesDataInterface, MetadataObjectInterface
{
const ATTRIBUTE_ID = 'attribute_id';

Expand Down
Loading

0 comments on commit b62b78b

Please sign in to comment.