Skip to content

Commit 8ff539b

Browse files
author
Dmytro Voskoboinikov
committed
Merge branch '2.1-develop' into MAGETWO-71515
2 parents 6b86996 + 1d083d4 commit 8ff539b

File tree

12 files changed

+60
-21
lines changed

12 files changed

+60
-21
lines changed

app/code/Magento/Catalog/Model/ImageExtractor.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
*/
66
namespace Magento\Catalog\Model;
77

8-
use Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter;
98
use Magento\Catalog\Helper\Image;
9+
use Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter;
10+
use Magento\Framework\View\Xsd\Media\TypeDataExtractorInterface;
1011

11-
class ImageExtractor implements \Magento\Framework\View\Xsd\Media\TypeDataExtractorInterface
12+
class ImageExtractor implements TypeDataExtractorInterface
1213
{
1314
/**
1415
* Extract configuration data of images from the DOM structure
@@ -30,8 +31,11 @@ public function process(\DOMElement $mediaNode, $mediaParentTag)
3031
if ($attribute->nodeType != XML_ELEMENT_NODE) {
3132
continue;
3233
}
33-
if ($attribute->tagName == 'background') {
34+
$attributeTagName = $attribute->tagName;
35+
if ($attributeTagName === 'background') {
3436
$nodeValue = $this->processImageBackground($attribute->nodeValue);
37+
} elseif ($attributeTagName === 'width' || $attributeTagName === 'height') {
38+
$nodeValue = intval($attribute->nodeValue);
3539
} else {
3640
$nodeValue = $attribute->nodeValue;
3741
}
@@ -55,6 +59,7 @@ private function processImageBackground($backgroundString)
5559
$backgroundArray = [];
5660
if (preg_match($pattern, $backgroundString, $backgroundArray)) {
5761
array_shift($backgroundArray);
62+
$backgroundArray = array_map('intval', $backgroundArray);
5863
}
5964
return $backgroundArray;
6065
}

app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ public function getItems($attributeCode)
4040
*/
4141
public function add($attributeCode, $option)
4242
{
43+
/** @var \Magento\Eav\Api\Data\AttributeOptionInterface[] $currentOptions */
44+
$currentOptions = $this->getItems($attributeCode);
45+
if (is_array($currentOptions)) {
46+
array_walk($currentOptions, function (&$attributeOption) {
47+
/** @var \Magento\Eav\Api\Data\AttributeOptionInterface $attributeOption */
48+
$attributeOption = $attributeOption->getLabel();
49+
});
50+
if (in_array($option->getLabel(), $currentOptions)) {
51+
return false;
52+
}
53+
}
4354
return $this->eavOptionManagement->add(
4455
\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
4556
$attributeCode,

app/code/Magento/Catalog/Test/Unit/Model/ImageExtractorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected function setUp()
2323
public function testProcess()
2424
{
2525
$expectedArray = include(__DIR__ . '/_files/converted_view.php');
26-
$this->assertEquals($expectedArray, $this->model->process($this->getDomElement(), 'media'));
26+
$this->assertSame($expectedArray, $this->model->process($this->getDomElement(), 'media'));
2727
}
2828

2929
/**

app/code/Magento/Cms/Model/ResourceModel/Block.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ public function getIsUniqueBlockToStores(AbstractModel $object)
183183
$entityMetadata = $this->metadataPool->getMetadata(BlockInterface::class);
184184
$linkField = $entityMetadata->getLinkField();
185185

186-
if ($this->_storeManager->hasSingleStore()) {
186+
if ($this->_storeManager->isSingleStoreMode()) {
187187
$stores = [Store::DEFAULT_STORE_ID];
188188
} else {
189-
$stores = (array)$object->getData('stores');
189+
$stores = (array)$object->getData('store_id');
190190
}
191191

192192
$select = $this->getConnection()->select()
@@ -230,7 +230,7 @@ public function lookupStoreIds($id)
230230
'cbs.' . $linkField . ' = cb.' . $linkField,
231231
[]
232232
)
233-
->where('cb.' . $entityMetadata->getIdentifierField() . ' = :block_id');
233+
->where('cb.' . $entityMetadata->getIdentifierField() . ' = :block_id');
234234

235235
return $connection->fetchCol($select, ['block_id' => (int)$id]);
236236
}

app/code/Magento/Customer/etc/adminhtml/system.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@
194194
<field id="street_lines" translate="label comment" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
195195
<label>Number of Lines in a Street Address</label>
196196
<backend_model>Magento\Customer\Model\Config\Backend\Address\Street</backend_model>
197-
<comment>Leave empty for default (2). Valid range: 1-4</comment>
197+
<comment>Valid range: 1-4</comment>
198+
<validate>required-entry validate-digits validate-digits-range digits-range-1-4</validate>
198199
</field>
199200
<field id="prefix_show" translate="label comment" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
200201
<label>Show Prefix</label>

app/code/Magento/Customer/etc/webapi.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@
188188
<resource ref="anonymous"/>
189189
</resources>
190190
</route>
191+
<route url="/V1/customers/resetPassword" method="POST">
192+
<service class="Magento\Customer\Api\AccountManagementInterface" method="resetPassword"/>
193+
<resources>
194+
<resource ref="anonymous"/>
195+
</resources>
196+
</route>
191197
<route url="/V1/customers/:customerId/confirm" method="GET">
192198
<service class="Magento\Customer\Api\AccountManagementInterface" method="getConfirmationStatus"/>
193199
<resources>

app/code/Magento/Directory/etc/zip_codes.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@
318318
</zip>
319319
<zip countryCode="NL">
320320
<codes>
321-
<code id="pattern_1" active="true" example="1234 AB">^[0-9]{4}\s[a-zA-Z]{2}$</code>
321+
<code id="pattern_1" active="true" example="1234 AB/1234AB">^[1-9][0-9]{3}\s?[a-zA-Z]{2}$</code>
322322
</codes>
323323
</zip>
324324
<zip countryCode="NO">

app/code/Magento/Eav/Model/Entity/AbstractEntity.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -928,28 +928,33 @@ public function checkAttributeUniqueValue(AbstractAttribute $attribute, $object)
928928
{
929929
$connection = $this->getConnection();
930930
$select = $connection->select();
931-
if ($attribute->getBackend()->getType() === 'static') {
931+
932+
$entityIdField = $this->getEntityIdField();
933+
$attributeBackend = $attribute->getBackend();
934+
if ($attributeBackend->getType() === 'static') {
932935
$value = $object->getData($attribute->getAttributeCode());
933936
$bind = ['value' => trim($value)];
934937

935938
$select->from(
936939
$this->getEntityTable(),
937-
$this->getEntityIdField()
940+
$entityIdField
938941
)->where(
939942
$attribute->getAttributeCode() . ' = :value'
940943
);
941944
} else {
942945
$value = $object->getData($attribute->getAttributeCode());
943-
if ($attribute->getBackend()->getType() == 'datetime') {
946+
if ($attributeBackend->getType() == 'datetime') {
944947
$value = (new \DateTime($value))->format('Y-m-d H:i:s');
945948
}
946949
$bind = [
947950
'attribute_id' => $attribute->getId(),
948951
'value' => trim($value),
949952
];
953+
954+
$entityIdField = $object->getResource()->getLinkField();
950955
$select->from(
951-
$attribute->getBackend()->getTable(),
952-
$object->getResource()->getLinkField()
956+
$attributeBackend->getTable(),
957+
$entityIdField
953958
)->where(
954959
'attribute_id = :attribute_id'
955960
)->where(
@@ -964,9 +969,10 @@ public function checkAttributeUniqueValue(AbstractAttribute $attribute, $object)
964969

965970
$data = $connection->fetchCol($select, $bind);
966971

967-
if ($object->getId()) {
972+
$objectId = $object->getData($entityIdField);
973+
if ($objectId) {
968974
if (isset($data[0])) {
969-
return $data[0] == $object->getId();
975+
return $data[0] == $objectId;
970976
}
971977
return true;
972978
}

app/code/Magento/Newsletter/Model/Subscriber.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ public function subscribe($email)
395395
{
396396
$this->loadByEmail($email);
397397

398+
if ($this->getId() && $this->getStatus() == self::STATUS_SUBSCRIBED) {
399+
return $this->getStatus();
400+
}
401+
398402
if (!$this->getId()) {
399403
$this->setSubscriberConfirmCode($this->randomSequence());
400404
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function readAllWebsites()
4747
->select()
4848
->from($this->getTable('store_website'));
4949

50-
foreach($this->getConnection()->fetchAll($select) as $websiteData) {
50+
foreach ($this->getConnection()->fetchAll($select) as $websiteData) {
5151
$websites[$websiteData['code']] = $websiteData;
5252
}
5353

@@ -63,7 +63,7 @@ public function readAllWebsites()
6363
*/
6464
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
6565
{
66-
if (!preg_match('/^[a-z]+[a-z0-9_]*$/', $object->getCode())) {
66+
if (!preg_match('/^[a-z]+[a-z0-9_]*$/i', $object->getCode())) {
6767
throw new \Magento\Framework\Exception\LocalizedException(
6868
__(
6969
'Website code may only contain letters (a-z), numbers (0-9) or underscore (_),'

0 commit comments

Comments
 (0)