Skip to content

Commit

Permalink
Merge pull request #3367 from magento-borg/2.3.0-release-sync
Browse files Browse the repository at this point in the history
Sync 2.3.0-release to 2.3-develop
  • Loading branch information
joanhe authored Oct 31, 2018
2 parents fdf16cb + cf99ada commit ec5fcb5
Show file tree
Hide file tree
Showing 11 changed files with 301 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/
namespace Magento\Catalog\Model\Indexer\Category\Flat\Action;

/**
* Class for full reindex flat categories
*/
class Full extends \Magento\Catalog\Model\Indexer\Category\Flat\AbstractAction
{
/**
Expand Down Expand Up @@ -92,6 +95,7 @@ protected function populateFlatTables(array $stores)

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

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

/**
* Retrieve all actual Catalog Product Flat Table names
*
* @return string[]
*/
private function getActualStoreTablesForCategoryFlat(): array
{
$actualStoreTables = [];
foreach ($this->storeManager->getStores() as $store) {
$actualStoreTables[] = sprintf(
'%s_store_%s',
$this->connection->getTableName('catalog_category_flat'),
$store->getId()
);
}

return $actualStoreTables;
}

/**
* Delete all category flat tables for not existing stores
*
* @return void
*/
private function deleteAbandonedStoreCategoryFlatTables(): void
{
$existentTables = $this->connection->getTables(
$this->connection->getTableName('catalog_category_flat_store_%')
);
$actualStoreTables = $this->getActualStoreTablesForCategoryFlat();

$tablesToDelete = array_diff($existentTables, $actualStoreTables);

foreach ($tablesToDelete as $table) {
$this->connection->dropTable($table);
}
}

/**
* Transactional rebuild flat data from eav
*
Expand All @@ -182,7 +225,7 @@ public function reindexAll()
$stores = $this->storeManager->getStores();
$this->populateFlatTables($stores);
$this->switchTables($stores);

$this->deleteAbandonedStoreCategoryFlatTables();
$this->allowTableChanges = true;

return $this;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Model\Product\Gallery;

use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface;
use Magento\Catalog\Api\Data\ProductInterface as Product;
use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Exception\StateException;
use Magento\Framework\Api\ImageContentValidatorInterface;

/**
* Class GalleryManagement
*
* Provides implementation of api interface ProductAttributeMediaGalleryManagementInterface
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGalleryManagementInterface
Expand Down Expand Up @@ -44,7 +46,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry)
{
Expand All @@ -54,7 +56,7 @@ public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry)
if (!$this->contentValidator->isValid($entryContent)) {
throw new InputException(__('The image content is invalid. Verify the content and try again.'));
}
$product = $this->productRepository->get($sku);
$product = $this->productRepository->get($sku, true);

$existingMediaGalleryEntries = $product->getMediaGalleryEntries();
$existingEntryIds = [];
Expand Down Expand Up @@ -84,11 +86,11 @@ public function create($sku, ProductAttributeMediaGalleryEntryInterface $entry)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry)
{
$product = $this->productRepository->get($sku);
$product = $this->productRepository->get($sku, true);
$existingMediaGalleryEntries = $product->getMediaGalleryEntries();
if ($existingMediaGalleryEntries == null) {
throw new NoSuchEntityException(
Expand Down Expand Up @@ -125,11 +127,11 @@ public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function remove($sku, $entryId)
{
$product = $this->productRepository->get($sku);
$product = $this->productRepository->get($sku, true);
$existingMediaGalleryEntries = $product->getMediaGalleryEntries();
if ($existingMediaGalleryEntries == null) {
throw new NoSuchEntityException(
Expand All @@ -155,7 +157,7 @@ public function remove($sku, $entryId)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function get($sku, $entryId)
{
Expand All @@ -176,7 +178,7 @@ public function get($sku, $entryId)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getList($sku)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<description value="Verify that admin is able to upload image to CMS Page with TinyMCE3 enabled"/>
<severity value="MAJOR"/>
<testCaseId value="MAGETWO-95725"/>
<skip>
<issueId value="MC-5371" />
</skip>
</annotations>
<before>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
Expand Down
46 changes: 38 additions & 8 deletions app/code/Magento/Config/App/Config/Type/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*
* @api
* @since 100.1.2
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class System implements ConfigTypeInterface
{
Expand Down Expand Up @@ -131,6 +132,32 @@ public function get($path = '')
return $this->getWithParts($path);
}

/**
* Merge newly loaded config data into already loaded.
*
* @param array $newData
* @return void
*/
private function mergeData(array $newData): void
{
if (array_key_exists(ScopeInterface::SCOPE_DEFAULT, $newData)) {
//Sometimes new data may contain links to arrays and we don't want that.
$this->data[ScopeInterface::SCOPE_DEFAULT] = (array)$newData[ScopeInterface::SCOPE_DEFAULT];
unset($newData[ScopeInterface::SCOPE_DEFAULT]);
}
foreach ($newData as $scopeType => $scopeTypeData) {
if (!array_key_exists($scopeType, $this->data)) {
//Sometimes new data may contain links to arrays and we don't want that.
$this->data[$scopeType] = (array)$scopeTypeData;
} else {
foreach ($scopeTypeData as $scopeId => $scopeData) {
//Sometimes new data may contain links to arrays and we don't want that.
$this->data[$scopeType][$scopeId] = (array)$scopeData;
}
}
}
}

/**
* Proceed with parts extraction from path.
*
Expand All @@ -143,8 +170,10 @@ private function getWithParts($path)

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

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

if ($scopeType === ScopeInterface::SCOPE_DEFAULT) {
if (!isset($this->data[$scopeType])) {
$this->data = array_replace_recursive(
$this->data,
$scopeData = $this->loadDefaultScopeData($scopeType)
);
//Adding unprocessed data to the data property so it can be used in post-processing.
$this->mergeData($scopeData = $this->loadDefaultScopeData($scopeType));
//Only post-processing the data we know is raw.
$scopeData = $this->postProcessor->process($scopeData);
$this->data = array_replace_recursive($this->data, $scopeData);
$this->mergeData($scopeData);
}

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

if (!isset($this->data[$scopeType][$scopeId])) {
$scopeData = $this->loadScopeData($scopeType, $scopeId);
$this->data = array_replace_recursive($this->data, $scopeData);
//Adding unprocessed data to the data property so it can be used in post-processing.
$this->mergeData($scopeData);
//Only post-processing the data we know is raw.
$scopeData = $this->postProcessor->process($scopeData);
$this->data = array_replace_recursive($this->data, $scopeData);
$this->mergeData($scopeData);
}

return isset($this->data[$scopeType][$scopeId])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Review\Model\ResourceModel\Review\Product;

use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"require-dev": {
"friendsofphp/php-cs-fixer": "~2.13.0",
"lusitanian/oauth": "~0.8.10",
"magento/magento2-functional-testing-framework": "2.3.6",
"magento/magento2-functional-testing-framework": "2.3.9",
"pdepend/pdepend": "2.5.2",
"phpmd/phpmd": "@stable",
"phpunit/phpunit": "~6.5.0",
Expand Down
Loading

0 comments on commit ec5fcb5

Please sign in to comment.