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:
 - magento#20328: [Backport] Fix issue 20232 : Backend order credit card detail check box misaligned (by @GovindaSharma)
 - magento#20325: [Backport] issus fixed magento#20158 Store switcher not aligned proper in tab view (by @shikhamis11)
 - magento#20353: Fixed#20352: displaying html content for file type option on order view admin area (by @maheshWebkul721)
 - magento#20329: [Backport]  Product image failure when importing through CSV magento#20098 (by @irajneeshgupta)
 - magento#20298: ISSUE-20296: "@magentoDataIsolation" is used instead of "@magentoDbIsolation" in some integration tests. (by @p-bystritsky)
 - magento#20185: [Backport] Move website_name column into columnSet (by @mage2pratik)
 - magento#20286: [Backport] Don't return categoryId from registry if the product doesn't belong in the current category (by @GovindaSharma)
 - magento#20271: [Backport] Use the new json serializer which throws an error when failing (by @quisse)
 - magento#20183: 2.2 develop pr port 18888 (by @saphaljha)
 - magento#20178: magento#16198: Category image remain after deleted. (by @p-bystritsky)


Fixed GitHub Issues:
 - magento#20232: Backend order credit card detail check box misaligned (reported by @speedy008) has been fixed in magento#20328 by @GovindaSharma in 2.2-develop branch
   Related commits:
     1. 6c5cba7

 - magento#20158: Store switcher not aligned proper in tab view (reported by @cedarvinda) has been fixed in magento#20325 by @shikhamis11 in 2.2-develop branch
   Related commits:
     1. f9a03d8
     2. 82ad1ca

 - magento#20352: File type option value shows html content in admin order view. (reported by @maheshWebkul721) has been fixed in magento#20353 by @maheshWebkul721 in 2.2-develop branch
   Related commits:
     1. c0730dc

 - magento#20098: Product image failure when importing through CSV (reported by @flytomek) has been fixed in magento#20329 by @irajneeshgupta in 2.2-develop branch
   Related commits:
     1. 40f64f9

 - magento#20296: "@magentoDataIsolation" is used instead of "@magentoDbIsolation" in some integration tests. (reported by @p-bystritsky) has been fixed in magento#20298 by @p-bystritsky in 2.2-develop branch
   Related commits:
     1. de64b09

 - magento#17819: Wrong product url from getProductUrl when current category has not product object (reported by @OleksiiBulba) has been fixed in magento#20286 by @GovindaSharma in 2.2-develop branch
   Related commits:
     1. 0247fc3

 - magento#14937: Javascript error thrown from uiComponent 'notification_area' if messages are malformed (reported by @sylvainraye) has been fixed in magento#20271 by @quisse in 2.2-develop branch
   Related commits:
     1. 7e3ea1b
     2. f72fb42
     3. dbb905c
     4. c3f4d5d
     5. 31bf4b2

 - magento#18192: Backend issue : "ratings isn't  available" website wise (reported by @hardik-krish) has been fixed in magento#20183 by @saphaljha in 2.2-develop branch
   Related commits:
     1. 06443f9
     2. cb6ff7e
     3. 56a0f11
     4. 9c59356
     5. fd4dd39
     6. a26b9bd
     7. 30a6d5a

 - magento#16198: Category image remain after deleted (reported by @vincent2090311) has been fixed in magento#20178 by @p-bystritsky in 2.2-develop branch
   Related commits:
     1. 3b4581c
     2. 979e552
  • Loading branch information
magento-engcom-team authored Jan 18, 2019
2 parents 530e0d1 + 2e38840 commit 8170336
Show file tree
Hide file tree
Showing 24 changed files with 540 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ $ccType = $block->getInfoData('cc_type');
id="<?= /* @noEscape */ $code ?>_vault"
name="payment[is_active_payment_token_enabler]"
class="admin__control-checkbox"/>
<label class="label" for="<?= /* @noEscape */ $code ?>_vault">
<label class="label admin__field-label" for="<?= /* @noEscape */ $code ?>_vault">
<span><?= $block->escapeHtml(__('Save for later use.')) ?></span>
</label>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ public function getIdBySku($sku)
public function getCategoryId()
{
$category = $this->_registry->registry('current_category');
if ($category) {
if ($category && in_array($category->getId(), $this->getCategoryIds())) {
return $category->getId();
}
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Model\ResourceModel\Category;

use Magento\Catalog\Api\CategoryListInterface;
use Magento\Framework\Api\SearchCriteriaBuilder;

/**
* Check if Image is currently used in any category as Category Image.
*/
class RedundantCategoryImageChecker
{
/**
* @var SearchCriteriaBuilder
*/
private $searchCriteriaBuilder;

/**
* @var CategoryListInterface
*/
private $categoryList;

public function __construct(
CategoryListInterface $categoryList,
SearchCriteriaBuilder $searchCriteriaBuilder
) {
$this->categoryList = $categoryList;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
}

/**
* Checks if Image is currently used in any category as Category Image.
*
* Returns true if not.
*
* @param string $imageName
* @return bool
*/
public function execute(string $imageName): bool
{
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteria = $this->searchCriteriaBuilder->addFilter('image', $imageName)->create();
$categories = $this->categoryList->getList($searchCriteria)->getItems();

return empty($categories);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Plugin\Model\ResourceModel\Category;

use Magento\Catalog\Model\ImageUploader;
use Magento\Catalog\Model\ResourceModel\Category as CategoryResource;
use Magento\Catalog\Model\ResourceModel\Category\RedundantCategoryImageChecker;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
use Magento\Framework\Model\AbstractModel;

/**
* Remove old Category Image file from pub/media/catalog/category directory if such Image is not used anymore.
*/
class RemoveRedundantImagePlugin
{
/**
* @var Filesystem
*/
private $filesystem;

/**
* @var ImageUploader
*/
private $imageUploader;

/**
* @var RedundantCategoryImageChecker
*/
private $redundantCategoryImageChecker;

public function __construct(
Filesystem $filesystem,
ImageUploader $imageUploader,
RedundantCategoryImageChecker $redundantCategoryImageChecker
) {
$this->filesystem = $filesystem;
$this->imageUploader = $imageUploader;
$this->redundantCategoryImageChecker = $redundantCategoryImageChecker;
}

/**
* Removes Image file if it is not used anymore.
*
* @param CategoryResource $subject
* @param CategoryResource $result
* @param AbstractModel $category
* @return CategoryResource
*
* @throws \Magento\Framework\Exception\FileSystemException
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterSave(
CategoryResource $subject,
CategoryResource $result,
AbstractModel $category
): CategoryResource {
$originalImage = $category->getOrigData('image');
if (null !== $originalImage
&& $originalImage !== $category->getImage()
&& $this->redundantCategoryImageChecker->execute($originalImage)
) {
$basePath = $this->imageUploader->getBasePath();
$baseImagePath = $this->imageUploader->getFilePath($basePath, $originalImage);
/** @var \Magento\Framework\Filesystem\Directory\WriteInterface $mediaDirectory */
$mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$mediaDirectory->delete($baseImagePath);
}

return $result;
}
}
12 changes: 11 additions & 1 deletion app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ public function testSetCategoryCollection()

public function testGetCategory()
{
$this->model->setData('category_ids', [10]);
$this->category->expects($this->any())->method('getId')->will($this->returnValue(10));
$this->registry->expects($this->any())->method('registry')->will($this->returnValue($this->category));
$this->categoryRepository->expects($this->any())->method('get')->will($this->returnValue($this->category));
Expand All @@ -551,14 +552,23 @@ public function testGetCategory()

public function testGetCategoryId()
{
$this->category->expects($this->once())->method('getId')->will($this->returnValue(10));
$this->model->setData('category_ids', [10]);
$this->category->expects($this->any())->method('getId')->will($this->returnValue(10));

$this->registry->expects($this->at(0))->method('registry');
$this->registry->expects($this->at(1))->method('registry')->will($this->returnValue($this->category));
$this->assertFalse($this->model->getCategoryId());
$this->assertEquals(10, $this->model->getCategoryId());
}

public function testGetCategoryIdWhenProductNotInCurrentCategory()
{
$this->model->setData('category_ids', [12]);
$this->category->expects($this->once())->method('getId')->will($this->returnValue(10));
$this->registry->expects($this->any())->method('registry')->will($this->returnValue($this->category));
$this->assertFalse($this->model->getCategoryId());
}

public function testGetIdBySku()
{
$this->resource->expects($this->once())->method('getIdBySku')->will($this->returnValue(5));
Expand Down
8 changes: 8 additions & 0 deletions app/code/Magento/Catalog/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,14 @@
<type name="Magento\Quote\Model\Quote\Item\ToOrderItem">
<plugin name="copy_quote_files_to_order" type="Magento\Catalog\Model\Plugin\QuoteItemProductOption"/>
</type>
<type name="Magento\Catalog\Model\ResourceModel\Category">
<plugin name="remove_redundant_image" type="Magento\Catalog\Plugin\Model\ResourceModel\Category\RemoveRedundantImagePlugin"/>
</type>
<type name="Magento\Catalog\Plugin\Model\ResourceModel\Category\RemoveRedundantImagePlugin">
<arguments>
<argument name="imageUploader" xsi:type="object">Magento\Catalog\CategoryImageUpload</argument>
</arguments>
</type>
<preference for="Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface" type="Magento\Catalog\Model\ResourceModel\Product\CompositeWithWebsiteProcessor" />
<type name="Magento\Catalog\Model\ResourceModel\Product\CompositeBaseSelectProcessor">
<arguments>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ public function move($fileName, $renameFileOff = false)
}

$fileName = preg_replace('/[^a-z0-9\._-]+/i', '', $fileName);
$filePath = $this->_directory->getRelativePath($filePath . $fileName);
$relativePath = $this->_directory->getRelativePath($filePath . $fileName);
$this->_directory->writeFile(
$filePath,
$relativePath,
$read->readAll()
);
}
Expand Down
22 changes: 13 additions & 9 deletions app/code/Magento/Checkout/Block/Onepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Onepage extends \Magento\Framework\View\Element\Template
protected $layoutProcessors;

/**
* @var \Magento\Framework\Serialize\Serializer\Json
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;

Expand All @@ -48,37 +48,39 @@ class Onepage extends \Magento\Framework\View\Element\Template
* @param \Magento\Checkout\Model\CompositeConfigProvider $configProvider
* @param array $layoutProcessors
* @param array $data
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
* @throws \RuntimeException
* @param \Magento\Framework\Serialize\Serializer\Json $serializer
* @param \Magento\Framework\Serialize\SerializerInterface $serializerInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\Data\Form\FormKey $formKey,
\Magento\Checkout\Model\CompositeConfigProvider $configProvider,
array $layoutProcessors = [],
array $data = [],
\Magento\Framework\Serialize\Serializer\Json $serializer = null
\Magento\Framework\Serialize\Serializer\Json $serializer = null,
\Magento\Framework\Serialize\SerializerInterface $serializerInterface = null
) {
parent::__construct($context, $data);
$this->formKey = $formKey;
$this->_isScopePrivate = true;
$this->jsLayout = isset($data['jsLayout']) && is_array($data['jsLayout']) ? $data['jsLayout'] : [];
$this->configProvider = $configProvider;
$this->layoutProcessors = $layoutProcessors;
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\Serialize\Serializer\Json::class);
$this->serializer = $serializerInterface ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\Serialize\Serializer\JsonHexTag::class);
}

/**
* @return string
* @inheritdoc
*/
public function getJsLayout()
{
foreach ($this->layoutProcessors as $processor) {
$this->jsLayout = $processor->process($this->jsLayout);
}

return json_encode($this->jsLayout, JSON_HEX_TAG);
return $this->serializer->serialize($this->jsLayout);
}

/**
Expand Down Expand Up @@ -115,11 +117,13 @@ public function getBaseUrl()
}

/**
* Retrieve serialized checkout config.
*
* @return bool|string
* @since 100.2.0
*/
public function getSerializedCheckoutConfig()
{
return json_encode($this->getCheckoutConfig(), JSON_HEX_TAG);
return $this->serializer->serialize($this->getCheckoutConfig());
}
}
9 changes: 6 additions & 3 deletions app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class OnepageTest extends \PHPUnit\Framework\TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $serializer;
private $serializerMock;

protected function setUp()
{
Expand All @@ -49,15 +49,16 @@ protected function setUp()
\Magento\Checkout\Block\Checkout\LayoutProcessorInterface::class
);

$this->serializer = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class);
$this->serializerMock = $this->createMock(\Magento\Framework\Serialize\Serializer\JsonHexTag::class);

$this->model = new \Magento\Checkout\Block\Onepage(
$contextMock,
$this->formKeyMock,
$this->configProviderMock,
[$this->layoutProcessorMock],
[],
$this->serializer
$this->serializerMock,
$this->serializerMock
);
}

Expand Down Expand Up @@ -93,6 +94,7 @@ public function testGetJsLayout()
$processedLayout = ['layout' => ['processed' => true]];
$jsonLayout = '{"layout":{"processed":true}}';
$this->layoutProcessorMock->expects($this->once())->method('process')->with([])->willReturn($processedLayout);
$this->serializerMock->expects($this->once())->method('serialize')->willReturn($jsonLayout);

$this->assertEquals($jsonLayout, $this->model->getJsLayout());
}
Expand All @@ -101,6 +103,7 @@ public function testGetSerializedCheckoutConfig()
{
$checkoutConfig = ['checkout', 'config'];
$this->configProviderMock->expects($this->once())->method('getConfig')->willReturn($checkoutConfig);
$this->serializerMock->expects($this->once())->method('serialize')->willReturn(json_encode($checkoutConfig));

$this->assertEquals(json_encode($checkoutConfig), $this->model->getSerializedCheckoutConfig());
}
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Checkout/etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<item name="totalsSortOrder" xsi:type="object">Magento\Checkout\Block\Checkout\TotalsProcessor</item>
<item name="directoryData" xsi:type="object">Magento\Checkout\Block\Checkout\DirectoryDataProcessor</item>
</argument>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\JsonHexTag</argument>
</arguments>
</type>
<type name="Magento\Checkout\Block\Cart\Totals">
Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/Review/Model/ResourceModel/Rating.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,11 @@ public function getReviewSummary($object, $onlyForCurrentStore = true)

$data = $connection->fetchAll($select, [':review_id' => $object->getReviewId()]);

$currentStore = $this->_storeManager->isSingleStoreMode() ? $this->_storeManager->getStore()->getId() : null;

if ($onlyForCurrentStore) {
foreach ($data as $row) {
if ($row['store_id'] == $this->_storeManager->getStore()->getId()) {
if ($row['store_id'] !== $currentStore) {
$object->addData($row);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@
<argument name="align" xsi:type="string">center</argument>
</arguments>
</block>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.customer.grid.columnSet.website_name" as="website_name">
<arguments>
<argument name="header" xsi:type="string" translate="true">Website</argument>
<argument name="index" xsi:type="string">website_name</argument>
<argument name="align" xsi:type="string">center</argument>
</arguments>
<block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.customer.grid.columnSet.website_name" as="website_name">
<arguments>
<argument name="header" xsi:type="string" translate="true">Website</argument>
<argument name="index" xsi:type="string">website_name</argument>
<argument name="align" xsi:type="string">center</argument>
</arguments>
</block>
</block>
</block>
</referenceBlock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<dt><?= $block->escapeHtml($_option['label']) ?>:</dt>
<dd>
<?php if (isset($_option['custom_view']) && $_option['custom_view']): ?>
<?= $block->escapeHtml($block->getCustomizedOptionValue($_option)) ?>
<?= /* @escapeNotVerified */ $block->getCustomizedOptionValue($_option) ?>
<?php else: ?>
<?php $_option = $block->getFormattedOption($_option['value']); ?>
<?= $block->escapeHtml($_option['value']) ?>
Expand Down
Loading

0 comments on commit 8170336

Please sign in to comment.