Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit ec5fcb5

Browse files
authored
Merge pull request #3367 from magento-borg/2.3.0-release-sync
Sync 2.3.0-release to 2.3-develop
2 parents fdf16cb + cf99ada commit ec5fcb5

File tree

11 files changed

+301
-155
lines changed

11 files changed

+301
-155
lines changed

app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Full.php

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Catalog\Model\Indexer\Category\Flat\Action;
77

8+
/**
9+
* Class for full reindex flat categories
10+
*/
811
class Full extends \Magento\Catalog\Model\Indexer\Category\Flat\AbstractAction
912
{
1013
/**
@@ -92,6 +95,7 @@ protected function populateFlatTables(array $stores)
9295

9396
/**
9497
* Create table and add attributes as fields for specified store.
98+
*
9599
* This routine assumes that DDL operations are allowed
96100
*
97101
* @param int $store
@@ -109,6 +113,7 @@ protected function createTable($store)
109113

110114
/**
111115
* Create category flat tables and add attributes as fields.
116+
*
112117
* Tables are created only if DDL operations are allowed
113118
*
114119
* @param \Magento\Store\Model\Store[] $stores if empty, create tables for all stores of the application
@@ -167,6 +172,44 @@ protected function switchTables(array $stores = [])
167172
return $this;
168173
}
169174

175+
/**
176+
* Retrieve all actual Catalog Product Flat Table names
177+
*
178+
* @return string[]
179+
*/
180+
private function getActualStoreTablesForCategoryFlat(): array
181+
{
182+
$actualStoreTables = [];
183+
foreach ($this->storeManager->getStores() as $store) {
184+
$actualStoreTables[] = sprintf(
185+
'%s_store_%s',
186+
$this->connection->getTableName('catalog_category_flat'),
187+
$store->getId()
188+
);
189+
}
190+
191+
return $actualStoreTables;
192+
}
193+
194+
/**
195+
* Delete all category flat tables for not existing stores
196+
*
197+
* @return void
198+
*/
199+
private function deleteAbandonedStoreCategoryFlatTables(): void
200+
{
201+
$existentTables = $this->connection->getTables(
202+
$this->connection->getTableName('catalog_category_flat_store_%')
203+
);
204+
$actualStoreTables = $this->getActualStoreTablesForCategoryFlat();
205+
206+
$tablesToDelete = array_diff($existentTables, $actualStoreTables);
207+
208+
foreach ($tablesToDelete as $table) {
209+
$this->connection->dropTable($table);
210+
}
211+
}
212+
170213
/**
171214
* Transactional rebuild flat data from eav
172215
*
@@ -182,7 +225,7 @@ public function reindexAll()
182225
$stores = $this->storeManager->getStores();
183226
$this->populateFlatTables($stores);
184227
$this->switchTables($stores);
185-
228+
$this->deleteAbandonedStoreCategoryFlatTables();
186229
$this->allowTableChanges = true;
187230

188231
return $this;

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76

87
namespace Magento\Catalog\Model\Product\Gallery;
98

109
use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface;
11-
use Magento\Catalog\Api\Data\ProductInterface as Product;
1210
use Magento\Framework\Exception\InputException;
1311
use Magento\Framework\Exception\NoSuchEntityException;
1412
use Magento\Framework\Exception\StateException;
1513
use Magento\Framework\Api\ImageContentValidatorInterface;
1614

1715
/**
16+
* Class GalleryManagement
17+
*
18+
* Provides implementation of api interface ProductAttributeMediaGalleryManagementInterface
19+
*
1820
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1921
*/
2022
class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGalleryManagementInterface
@@ -44,7 +46,7 @@ public function __construct(
4446
}
4547

4648
/**
47-
* {@inheritdoc}
49+
* @inheritdoc
4850
*/
4951
public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry)
5052
{
@@ -54,7 +56,7 @@ public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry)
5456
if (!$this->contentValidator->isValid($entryContent)) {
5557
throw new InputException(__('The image content is invalid. Verify the content and try again.'));
5658
}
57-
$product = $this->productRepository->get($sku);
59+
$product = $this->productRepository->get($sku, true);
5860

5961
$existingMediaGalleryEntries = $product->getMediaGalleryEntries();
6062
$existingEntryIds = [];
@@ -84,11 +86,11 @@ public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry)
8486
}
8587

8688
/**
87-
* {@inheritdoc}
89+
* @inheritdoc
8890
*/
8991
public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry)
9092
{
91-
$product = $this->productRepository->get($sku);
93+
$product = $this->productRepository->get($sku, true);
9294
$existingMediaGalleryEntries = $product->getMediaGalleryEntries();
9395
if ($existingMediaGalleryEntries == null) {
9496
throw new NoSuchEntityException(
@@ -125,11 +127,11 @@ public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry)
125127
}
126128

127129
/**
128-
* {@inheritdoc}
130+
* @inheritdoc
129131
*/
130132
public function remove($sku, $entryId)
131133
{
132-
$product = $this->productRepository->get($sku);
134+
$product = $this->productRepository->get($sku, true);
133135
$existingMediaGalleryEntries = $product->getMediaGalleryEntries();
134136
if ($existingMediaGalleryEntries == null) {
135137
throw new NoSuchEntityException(
@@ -155,7 +157,7 @@ public function remove($sku, $entryId)
155157
}
156158

157159
/**
158-
* {@inheritdoc}
160+
* @inheritdoc
159161
*/
160162
public function get($sku, $entryId)
161163
{
@@ -176,7 +178,7 @@ public function get($sku, $entryId)
176178
}
177179

178180
/**
179-
* {@inheritdoc}
181+
* @inheritdoc
180182
*/
181183
public function getList($sku)
182184
{

app/code/Magento/Cms/Test/Mftf/Test/AdminAddImageToCMSPageTinyMCE3Test.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<description value="Verify that admin is able to upload image to CMS Page with TinyMCE3 enabled"/>
1818
<severity value="MAJOR"/>
1919
<testCaseId value="MAGETWO-95725"/>
20+
<skip>
21+
<issueId value="MC-5371" />
22+
</skip>
2023
</annotations>
2124
<before>
2225
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>

app/code/Magento/Config/App/Config/Type/System.php

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*
2323
* @api
2424
* @since 100.1.2
25+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2526
*/
2627
class System implements ConfigTypeInterface
2728
{
@@ -131,6 +132,32 @@ public function get($path = '')
131132
return $this->getWithParts($path);
132133
}
133134

135+
/**
136+
* Merge newly loaded config data into already loaded.
137+
*
138+
* @param array $newData
139+
* @return void
140+
*/
141+
private function mergeData(array $newData): void
142+
{
143+
if (array_key_exists(ScopeInterface::SCOPE_DEFAULT, $newData)) {
144+
//Sometimes new data may contain links to arrays and we don't want that.
145+
$this->data[ScopeInterface::SCOPE_DEFAULT] = (array)$newData[ScopeInterface::SCOPE_DEFAULT];
146+
unset($newData[ScopeInterface::SCOPE_DEFAULT]);
147+
}
148+
foreach ($newData as $scopeType => $scopeTypeData) {
149+
if (!array_key_exists($scopeType, $this->data)) {
150+
//Sometimes new data may contain links to arrays and we don't want that.
151+
$this->data[$scopeType] = (array)$scopeTypeData;
152+
} else {
153+
foreach ($scopeTypeData as $scopeId => $scopeData) {
154+
//Sometimes new data may contain links to arrays and we don't want that.
155+
$this->data[$scopeType][$scopeId] = (array)$scopeData;
156+
}
157+
}
158+
}
159+
}
160+
134161
/**
135162
* Proceed with parts extraction from path.
136163
*
@@ -143,8 +170,10 @@ private function getWithParts($path)
143170

144171
if (count($pathParts) === 1 && $pathParts[0] !== ScopeInterface::SCOPE_DEFAULT) {
145172
if (!isset($this->data[$pathParts[0]])) {
173+
//First filling data property with unprocessed data for post-processors to be able to use.
146174
$data = $this->readData();
147-
$this->data = array_replace_recursive($this->data, $this->postProcessor->process($data));
175+
//Post-processing only the data we know is not yet processed.
176+
$this->mergeData($this->postProcessor->process($data));
148177
}
149178

150179
return $this->data[$pathParts[0]];
@@ -154,12 +183,11 @@ private function getWithParts($path)
154183

155184
if ($scopeType === ScopeInterface::SCOPE_DEFAULT) {
156185
if (!isset($this->data[$scopeType])) {
157-
$this->data = array_replace_recursive(
158-
$this->data,
159-
$scopeData = $this->loadDefaultScopeData($scopeType)
160-
);
186+
//Adding unprocessed data to the data property so it can be used in post-processing.
187+
$this->mergeData($scopeData = $this->loadDefaultScopeData($scopeType));
188+
//Only post-processing the data we know is raw.
161189
$scopeData = $this->postProcessor->process($scopeData);
162-
$this->data = array_replace_recursive($this->data, $scopeData);
190+
$this->mergeData($scopeData);
163191
}
164192

165193
return $this->getDataByPathParts($this->data[$scopeType], $pathParts);
@@ -169,9 +197,11 @@ private function getWithParts($path)
169197

170198
if (!isset($this->data[$scopeType][$scopeId])) {
171199
$scopeData = $this->loadScopeData($scopeType, $scopeId);
172-
$this->data = array_replace_recursive($this->data, $scopeData);
200+
//Adding unprocessed data to the data property so it can be used in post-processing.
201+
$this->mergeData($scopeData);
202+
//Only post-processing the data we know is raw.
173203
$scopeData = $this->postProcessor->process($scopeData);
174-
$this->data = array_replace_recursive($this->data, $scopeData);
204+
$this->mergeData($scopeData);
175205
}
176206

177207
return isset($this->data[$scopeType][$scopeId])

app/code/Magento/Review/Model/ResourceModel/Review/Product/Collection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Review\Model\ResourceModel\Review\Product;
87

98
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"require-dev": {
8585
"friendsofphp/php-cs-fixer": "~2.13.0",
8686
"lusitanian/oauth": "~0.8.10",
87-
"magento/magento2-functional-testing-framework": "2.3.6",
87+
"magento/magento2-functional-testing-framework": "2.3.9",
8888
"pdepend/pdepend": "2.5.2",
8989
"phpmd/phpmd": "@stable",
9090
"phpunit/phpunit": "~6.5.0",

0 commit comments

Comments
 (0)