Skip to content

Commit edb0ea3

Browse files
authored
Merge pull request #1442 from magento-okapis/pr-aug29
[okapis] Bugs
2 parents 4d9d6b0 + 17cc643 commit edb0ea3

File tree

13 files changed

+899
-19
lines changed

13 files changed

+899
-19
lines changed

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public function beforeSave(
5656
) {
5757
$this->saveIsNew = $attribute->isObjectNew();
5858
$this->saveNeedInvalidation = (
59-
$attribute->dataHasChangedFor('is_searchable')
60-
|| $attribute->dataHasChangedFor('is_filterable')
61-
|| $attribute->dataHasChangedFor('is_visible_in_advanced_search')
62-
) && ! $this->saveIsNew;
59+
$attribute->dataHasChangedFor('is_searchable')
60+
|| $attribute->dataHasChangedFor('is_filterable')
61+
|| $attribute->dataHasChangedFor('is_visible_in_advanced_search')
62+
);
6363
}
6464

6565
/**

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ public function getEntityIdField()
767767
*/
768768
public function getValueEntityIdField()
769769
{
770-
return $this->getEntityIdField();
770+
return $this->getLinkField();
771771
}
772772

773773
/**
@@ -885,28 +885,33 @@ public function checkAttributeUniqueValue(AbstractAttribute $attribute, $object)
885885
{
886886
$connection = $this->getConnection();
887887
$select = $connection->select();
888-
if ($attribute->getBackend()->getType() === 'static') {
888+
889+
$entityIdField = $this->getEntityIdField();
890+
$attributeBackend = $attribute->getBackend();
891+
if ($attributeBackend->getType() === 'static') {
889892
$value = $object->getData($attribute->getAttributeCode());
890893
$bind = ['value' => trim($value)];
891894

892895
$select->from(
893896
$this->getEntityTable(),
894-
$this->getEntityIdField()
897+
$entityIdField
895898
)->where(
896899
$attribute->getAttributeCode() . ' = :value'
897900
);
898901
} else {
899902
$value = $object->getData($attribute->getAttributeCode());
900-
if ($attribute->getBackend()->getType() == 'datetime') {
903+
if ($attributeBackend->getType() == 'datetime') {
901904
$value = (new \DateTime($value))->format('Y-m-d H:i:s');
902905
}
903906
$bind = [
904907
'attribute_id' => $attribute->getId(),
905908
'value' => trim($value),
906909
];
910+
911+
$entityIdField = $attributeBackend->getEntityIdField();
907912
$select->from(
908-
$attribute->getBackend()->getTable(),
909-
$object->getResource()->getLinkField()
913+
$attributeBackend->getTable(),
914+
$entityIdField
910915
)->where(
911916
'attribute_id = :attribute_id'
912917
)->where(
@@ -921,9 +926,10 @@ public function checkAttributeUniqueValue(AbstractAttribute $attribute, $object)
921926

922927
$data = $connection->fetchCol($select, $bind);
923928

924-
if ($object->getId()) {
929+
$objectId = $object->getData($entityIdField);
930+
if ($objectId) {
925931
if (isset($data[0])) {
926-
return $data[0] == $object->getId();
932+
return $data[0] == $objectId;
927933
}
928934
return true;
929935
}

app/code/Magento/Email/Model/Template/Filter.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,15 @@ class Filter extends \Magento\Framework\Filter\Template
150150

151151
/**
152152
* @var \Pelago\Emogrifier
153+
* @deprecated
153154
*/
154155
protected $emogrifier;
155156

157+
/**
158+
* @var \Magento\Framework\Css\PreProcessor\Adapter\CssInliner
159+
*/
160+
private $cssInliner;
161+
156162
/**
157163
* @var \Magento\Email\Model\Source\Variables
158164
*/
@@ -183,6 +189,7 @@ class Filter extends \Magento\Framework\Filter\Template
183189
* @param \Pelago\Emogrifier $emogrifier
184190
* @param \Magento\Email\Model\Source\Variables $configVariables
185191
* @param array $variables
192+
* @param \Magento\Framework\Css\PreProcessor\Adapter\CssInliner|null $cssInliner
186193
*
187194
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
188195
*/
@@ -200,7 +207,8 @@ public function __construct(
200207
\Magento\Framework\UrlInterface $urlModel,
201208
\Pelago\Emogrifier $emogrifier,
202209
\Magento\Email\Model\Source\Variables $configVariables,
203-
$variables = []
210+
$variables = [],
211+
\Magento\Framework\Css\PreProcessor\Adapter\CssInliner $cssInliner = null
204212
) {
205213
$this->_escaper = $escaper;
206214
$this->_assetRepo = $assetRepo;
@@ -214,6 +222,8 @@ public function __construct(
214222
$this->_appState = $appState;
215223
$this->urlModel = $urlModel;
216224
$this->emogrifier = $emogrifier;
225+
$this->cssInliner = $cssInliner ?: \Magento\Framework\App\ObjectManager::getInstance()
226+
->get(\Magento\Framework\Css\PreProcessor\Adapter\CssInliner::class);
217227
$this->configVariables = $configVariables;
218228
parent::__construct($string, $variables);
219229
}
@@ -975,14 +985,14 @@ public function applyInlineCss($html)
975985
);
976986
}
977987

978-
$emogrifier = $this->emogrifier;
979-
$emogrifier->setHtml($html);
980-
$emogrifier->setCss($cssToInline);
988+
$this->cssInliner->setHtml($html);
989+
990+
$this->cssInliner->setCss($cssToInline);
981991

982992
// Don't parse inline <style> tags, since existing tag is intentionally for non-inline styles
983-
$emogrifier->disableStyleBlocksParsing();
993+
$this->cssInliner->disableStyleBlocksParsing();
984994

985-
$processedHtml = $emogrifier->emogrify();
995+
$processedHtml = $this->cssInliner->process();
986996
} catch (\Exception $e) {
987997
if ($this->_appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
988998
$processedHtml = __('CSS inlining error:') . PHP_EOL . $e->getMessage()

app/code/Magento/Email/Test/Unit/Model/Template/FilterTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ class FilterTest extends \PHPUnit\Framework\TestCase
8787
*/
8888
private $emogrifier;
8989

90+
/**
91+
* @var \Magento\Framework\Css\PreProcessor\Adapter\CssInliner
92+
*/
93+
private $cssInliner;
94+
9095
protected function setUp()
9196
{
9297
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -140,6 +145,10 @@ protected function setUp()
140145
$this->configVariables = $this->getMockBuilder(\Magento\Email\Model\Source\Variables::class)
141146
->disableOriginalConstructor()
142147
->getMock();
148+
149+
$this->cssInliner = $this->objectManager->getObject(
150+
\Magento\Framework\Css\PreProcessor\Adapter\CssInliner::class
151+
);
143152
}
144153

145154
/**
@@ -164,6 +173,7 @@ protected function getModel($mockedMethods = null)
164173
$this->emogrifier,
165174
$this->configVariables,
166175
[],
176+
$this->cssInliner,
167177
])
168178
->setMethods($mockedMethods)
169179
->getMock();

app/code/Magento/Ui/Component/MassAction/Filter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ private function getFilterIds()
223223
// Use collection's getAllIds for optimization purposes.
224224
$idsArray = $this->getDataProvider()->getAllIds();
225225
} else {
226-
$searchResult = $this->getDataProvider()->getSearchResult();
226+
$dataProvider = $this->getDataProvider();
227+
$dataProvider->setLimit(0, false);
228+
$searchResult = $dataProvider->getSearchResult();
227229
// Use compatible search api getItems when searchResult is not a collection.
228230
foreach ($searchResult->getItems() as $item) {
229231
/** @var $item \Magento\Framework\Api\Search\DocumentInterface */

dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,47 @@ public function testValidateUniqueInputAttributeValue()
487487
);
488488
}
489489

490+
/**
491+
* @magentoDbIsolation enabled
492+
* @magentoDataFixture Magento/Catalog/_files/products_with_unique_input_attribute.php
493+
*/
494+
public function testValidateUniqueInputAttributeOnTheSameProduct()
495+
{
496+
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
497+
$attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
498+
->get(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
499+
->loadByCode(\Magento\Catalog\Model\Product::ENTITY, 'unique_input_attribute');
500+
$this->_model = $this->_model->loadByAttribute(
501+
'sku',
502+
'simple product with unique input attribute'
503+
);
504+
$this->_model->setTypeId(
505+
'simple'
506+
)->setAttributeSetId(
507+
4
508+
)->setName(
509+
'Simple Product with non-unique value'
510+
)->setSku(
511+
'some product SKU'
512+
)->setPrice(
513+
10
514+
)->setMetaTitle(
515+
'meta title'
516+
)->setData(
517+
$attribute->getAttributeCode(),
518+
'unique value'
519+
)->setVisibility(
520+
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
521+
)->setStatus(
522+
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
523+
)->setCollectExceptionMessages(
524+
true
525+
);
526+
527+
$validationResult = $this->_model->validate();
528+
$this->assertTrue($validationResult);
529+
}
530+
490531
/**
491532
* @magentoDataFixture Magento/Catalog/_files/product_simple_with_custom_options.php
492533
* @magentoAppIsolation enabled

dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassAssignGroupTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,33 @@ public function testMassAssignGroupAction()
6969
$this->assertEquals(0, $customer->getGroupId());
7070
}
7171

72+
/**
73+
* @magentoDataFixture Magento/Customer/_files/twenty_one_customers.php
74+
*/
75+
public function testLargeGroupMassAssignGroupAction()
76+
{
77+
78+
for ($i = 1; $i < 22; $i++) {
79+
$customer = $this->customerRepository->getById($i);
80+
$this->assertEquals(1, $customer->getGroupId());
81+
}
82+
83+
$this->getRequest()
84+
->setParam('group', 0)
85+
->setPostValue('namespace', 'customer_listing')
86+
->setPostValue('selected', [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]);
87+
$this->dispatch('backend/customer/index/massAssignGroup');
88+
$this->assertSessionMessages(
89+
$this->equalTo(['A total of 21 record(s) were updated.']),
90+
\Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
91+
);
92+
$this->assertRedirect($this->stringStartsWith($this->baseControllerUrl));
93+
for ($i = 1; $i < 22; $i++) {
94+
$customer = $this->customerRepository->getById($i);
95+
$this->assertEquals(0, $customer->getGroupId());
96+
}
97+
}
98+
7299
/**
73100
* Valid group Id but no customer Ids specified
74101
* @magentoDbIsolation enabled

0 commit comments

Comments
 (0)