Skip to content

Commit db7eb7a

Browse files
committed
Merge remote-tracking branch 'mainline-ce/develop' into MAGETWO-52746
2 parents dfd055c + e1bd045 commit db7eb7a

File tree

197 files changed

+4434
-876
lines changed

Some content is hidden

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

197 files changed

+4434
-876
lines changed

.htaccess

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44

55
# SetEnv MAGE_MODE developer
66

7-
############################################
8-
## overrides default umask value to allow using different
9-
## file permissions
10-
11-
# SetEnv MAGE_UMASK 022
12-
137
############################################
148
## uncomment these lines for CGI mode
159
## make sure to specify the correct cgi php binary file name
@@ -281,6 +275,10 @@
281275
order allow,deny
282276
deny from all
283277
</Files>
278+
<Files magento_umask>
279+
order allow,deny
280+
deny from all
281+
</Files>
284282

285283
################################
286284
## If running in cluster environment, uncomment this

.htaccess.sample

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@
274274
order allow,deny
275275
deny from all
276276
</Files>
277+
<Files magento_umask>
278+
order allow,deny
279+
deny from all
280+
</Files>
277281

278282
################################
279283
## If running in cluster environment, uncomment this

app/bootstrap.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
error_reporting(E_ALL);
1111
#ini_set('display_errors', 1);
1212

13-
/* Custom umask value may be provided in MAGE_UMASK environment variable */
14-
$mask = isset($_SERVER['MAGE_UMASK']) ? octdec($_SERVER['MAGE_UMASK']) : 002;
15-
umask($mask);
16-
1713
/* PHP version validation */
1814
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50522) {
1915
if (PHP_SAPI == 'cli') {
@@ -34,6 +30,11 @@
3430
require_once __DIR__ . '/autoload.php';
3531
require_once BP . '/app/functions.php';
3632

33+
/* Custom umask value may be provided in optional mage_umask file in root */
34+
$umaskFile = BP . '/magento_umask';
35+
$mask = file_exists($umaskFile) ? octdec(file_get_contents($umaskFile)) : 002;
36+
umask($mask);
37+
3738
if (!empty($_SERVER['MAGE_PROFILER'])
3839
&& isset($_SERVER['HTTP_ACCEPT'])
3940
&& strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false

app/code/Magento/Bundle/Model/Product/ReadHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ public function __construct(OptionRepository $optionRepository)
2929
}
3030

3131
/**
32-
* @param string $entityType
3332
* @param object $entity
3433
* @param array $arguments
3534
* @return \Magento\Catalog\Api\Data\ProductInterface
3635
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3736
*/
38-
public function execute($entityType, $entity, $arguments = [])
37+
public function execute($entity, $arguments = [])
3938
{
4039
/** @var $entity \Magento\Catalog\Api\Data\ProductInterface */
4140
if ($entity->getTypeId() != \Magento\Bundle\Model\Product\Type::TYPE_CODE) {

app/code/Magento/Bundle/Model/Product/SaveHandler.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Bundle\Model\Product;
87

98
use Magento\Bundle\Api\ProductOptionRepositoryInterface as OptionRepository;
10-
use Magento\Framework\EntityManager\MetadataPool;
119
use Magento\Bundle\Api\ProductLinkManagementInterface;
1210
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
1311

@@ -16,11 +14,6 @@
1614
*/
1715
class SaveHandler implements ExtensionInterface
1816
{
19-
/**
20-
* @var MetadataPool
21-
*/
22-
protected $metadataPool;
23-
2417
/**
2518
* @var OptionRepository
2619
*/
@@ -33,27 +26,23 @@ class SaveHandler implements ExtensionInterface
3326

3427
/**
3528
* @param OptionRepository $optionRepository
36-
* @param MetadataPool $metadataPool
3729
* @param ProductLinkManagementInterface $productLinkManagement
3830
*/
3931
public function __construct(
4032
OptionRepository $optionRepository,
41-
MetadataPool $metadataPool,
4233
ProductLinkManagementInterface $productLinkManagement
4334
) {
4435
$this->optionRepository = $optionRepository;
45-
$this->metadataPool = $metadataPool;
4636
$this->productLinkManagement = $productLinkManagement;
4737
}
4838

4939
/**
50-
* @param string $entityType
5140
* @param object $entity
5241
* @param array $arguments
5342
* @return \Magento\Catalog\Api\Data\ProductInterface|object
5443
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5544
*/
56-
public function execute($entityType, $entity, $arguments = [])
45+
public function execute($entity, $arguments = [])
5746
{
5847
$bundleProductOptions = $entity->getExtensionAttributes()->getBundleProductOptions();
5948
if ($entity->getTypeId() !== 'bundle' || empty($bundleProductOptions)) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
*
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
namespace Magento\Catalog\Api;
8+
9+
interface AttributeSetFinderInterface
10+
{
11+
/**
12+
* Get attribute set ids by product ids
13+
*
14+
* @param array $productIds
15+
* @return array
16+
*/
17+
public function findAttributeSetIdsByProductIds(array $productIds);
18+
}

app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,15 @@ protected function _filterCategoryPostData(array $rawData)
8282
$data = $rawData;
8383
// @todo It is a workaround to prevent saving this data in category model and it has to be refactored in future
8484
if (isset($data['image']) && is_array($data['image'])) {
85-
$data['image_additional_data'] = $data['image'];
86-
unset($data['image']);
85+
if (!empty($data['image']['delete'])) {
86+
$data['image'] = null;
87+
} else {
88+
if (isset($data['image'][0]['name']) && isset($data['image'][0]['tmp_name'])) {
89+
$data['image'] = $data['image'][0]['name'];
90+
} else {
91+
unset($data['image']);
92+
}
93+
}
8794
}
8895
return $data;
8996
}

app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,14 @@ private function getImageUploader()
9494
*/
9595
public function afterSave($object)
9696
{
97-
$value = $object->getData($this->getAttribute()->getName() . '_additional_data');
97+
$image = $object->getData($this->getAttribute()->getName(), null);
9898

99-
if (is_array($value) && !empty($value['delete'])) {
100-
$object->setData($this->getAttribute()->getName(), '');
101-
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
102-
return $this;
103-
}
104-
105-
if (isset($value[0]['name']) && isset($value[0]['tmp_name'])) {
99+
if ($image !== null) {
106100
try {
107-
$result = $this->getImageUploader()->moveFileFromTmp($value[0]['name']);
108-
109-
$object->setData($this->getAttribute()->getName(), $result);
110-
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
101+
$this->getImageUploader()->moveFileFromTmp($image);
111102
} catch (\Exception $e) {
112103
$this->_logger->critical($e);
113104
}
114-
} elseif (isset($value[0]['name'])) {
115-
$object->setData($this->getAttribute()->getName(), $value[0]['name']);
116-
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
117105
}
118106
return $this;
119107
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,15 @@ public function save(\Magento\Catalog\Api\Data\CategoryInterface $category)
9191
);
9292

9393
if (isset($existingData['image']) && is_array($existingData['image'])) {
94-
$existingData['image_additional_data'] = $existingData['image'];
95-
unset($existingData['image']);
94+
if (!empty($existingData['image']['delete'])) {
95+
$existingData['image'] = null;
96+
} else {
97+
if (isset($existingData['image'][0]['name']) && isset($existingData['image'][0]['tmp_name'])) {
98+
$existingData['image'] = $existingData['image'][0]['name'];
99+
} else {
100+
unset($existingData['image']);
101+
}
102+
}
96103
}
97104
} else {
98105
$parentId = $category->getParentId() ?: $this->storeManager->getStore()->getRootCategoryId();

app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ protected function _reindexRows($changedIds = [])
390390
$pairs = $this->_connection->fetchPairs($select);
391391
foreach ($pairs as $productId => $productType) {
392392
if (!in_array($productId, $changedIds)) {
393-
$changedIds[] = $productId;
393+
$changedIds[] = (string) $productId;
394394
$byType[$productType][$productId] = $productId;
395395
$compositeIds[$productId] = $productId;
396396
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Model\Product\Attribute;
7+
8+
use Magento\Catalog\Api\Data\ProductInterface;
9+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
10+
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
11+
use Magento\Catalog\Api\AttributeSetFinderInterface;
12+
use Magento\Framework\DB\Select;
13+
14+
class AttributeSetFinder implements AttributeSetFinderInterface
15+
{
16+
/**
17+
* @var CollectionFactory
18+
*/
19+
private $productCollectionFactory;
20+
21+
/**
22+
* @param CollectionFactory $productCollectionFactory
23+
*/
24+
public function __construct(CollectionFactory $productCollectionFactory)
25+
{
26+
$this->productCollectionFactory = $productCollectionFactory;
27+
}
28+
29+
/**
30+
* {@inheritdoc}
31+
*/
32+
public function findAttributeSetIdsByProductIds(array $productIds)
33+
{
34+
/** @var $collection Collection */
35+
$collection = $this->productCollectionFactory->create();
36+
$select = $collection
37+
->getSelect()
38+
->reset(Select::COLUMNS)
39+
->columns(ProductInterface::ATTRIBUTE_SET_ID)
40+
->where('entity_id IN (?)', $productIds)
41+
->group(ProductInterface::ATTRIBUTE_SET_ID);
42+
$result = $collection->getConnection()->fetchCol($select);
43+
return $result;
44+
}
45+
}

app/code/Magento/Catalog/Model/Product/Copier.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88
namespace Magento\Catalog\Model\Product;
99

10+
use Magento\Catalog\Api\Data\ProductInterface;
11+
1012
class Copier
1113
{
1214
/**
@@ -24,6 +26,11 @@ class Copier
2426
*/
2527
protected $productFactory;
2628

29+
/**
30+
* @var \Magento\Framework\EntityManager\MetadataPool
31+
*/
32+
protected $metadataPool;
33+
2734
/**
2835
* @param CopyConstructorInterface $copyConstructor
2936
* @param \Magento\Catalog\Model\ProductFactory $productFactory
@@ -73,14 +80,18 @@ public function copy(\Magento\Catalog\Model\Product $product)
7380
} catch (\Magento\Framework\Exception\AlreadyExistsException $e) {
7481
}
7582
} while (!$isDuplicateSaved);
76-
7783
$this->getOptionRepository()->duplicate($product, $duplicate);
78-
$product->getResource()->duplicate($product->getEntityId(), $duplicate->getEntityId());
84+
$metadata = $this->getMetadataPool()->getMetadata(ProductInterface::class);
85+
$product->getResource()->duplicate(
86+
$product->getData($metadata->getLinkField()),
87+
$duplicate->getData($metadata->getLinkField())
88+
);
7989
return $duplicate;
8090
}
8191

8292
/**
8393
* @return Option\Repository
94+
* @deprecated
8495
*/
8596
private function getOptionRepository()
8697
{
@@ -90,4 +101,17 @@ private function getOptionRepository()
90101
}
91102
return $this->optionRepository;
92103
}
104+
105+
/**
106+
* @return \Magento\Framework\EntityManager\MetadataPool
107+
* @deprecated
108+
*/
109+
private function getMetadataPool()
110+
{
111+
if (null === $this->metadataPool) {
112+
$this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance()
113+
->get('Magento\Framework\EntityManager\MetadataPool');
114+
}
115+
return $this->metadataPool;
116+
}
93117
}

app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
1111

1212
/**
13-
* Create handler for catalog product gallery.
13+
* Create handler for catalog product gallery
14+
*
1415
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1516
*/
1617
class CreateHandler implements ExtensionInterface
@@ -85,7 +86,6 @@ public function __construct(
8586
}
8687

8788
/**
88-
* @param string $entityType
8989
* @param object $product
9090
* @param array $arguments
9191
* @return object
@@ -94,7 +94,7 @@ public function __construct(
9494
* @SuppressWarnings(PHPMD.NPathComplexity)
9595
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
9696
*/
97-
public function execute($entityType, $product, $arguments = [])
97+
public function execute($product, $arguments = [])
9898
{
9999
$attrCode = $this->getAttribute()->getAttributeCode();
100100

app/code/Magento/Catalog/Model/Product/Gallery/ReadHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ public function __construct(
4040
}
4141

4242
/**
43-
* @param string $entityType
4443
* @param object $entity
4544
* @param array $arguments
4645
* @return object
4746
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4847
*/
49-
public function execute($entityType, $entity, $arguments = [])
48+
public function execute($entity, $arguments = [])
5049
{
5150
$value = [];
5251
$value['images'] = [];

0 commit comments

Comments
 (0)