Skip to content

Commit f553937

Browse files
Merge pull request magento#157 from magento-okapis/API-Bug-Fixes
[Okapis] Bug Fixes
2 parents 63eeefa + 3fe2de0 commit f553937

File tree

31 files changed

+484
-62
lines changed

31 files changed

+484
-62
lines changed

app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ class Notice extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstract
1818
public function render(\Magento\Framework\DataObject $row)
1919
{
2020
return '<span class="grid-row-title">' .
21-
$row->getTitle() .
21+
$this->escapeHtml($row->getTitle()) .
2222
'</span>' .
23-
($row->getDescription() ? '<br />' .
24-
$row->getDescription() : '');
23+
($row->getDescription() ? '<br />' . $this->escapeHtml($row->getDescription()) : '');
2524
}
2625
}

app/code/Magento/Catalog/Model/Layer/FilterList.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ class FilterList
3030
* @var string[]
3131
*/
3232
protected $filterTypes = [
33-
self::CATEGORY_FILTER => 'Magento\Catalog\Model\Layer\Filter\Category',
34-
self::ATTRIBUTE_FILTER => 'Magento\Catalog\Model\Layer\Filter\Attribute',
35-
self::PRICE_FILTER => 'Magento\Catalog\Model\Layer\Filter\Price',
36-
self::DECIMAL_FILTER => 'Magento\Catalog\Model\Layer\Filter\Decimal',
33+
self::CATEGORY_FILTER => \Magento\Catalog\Model\Layer\Filter\Category::class,
34+
self::ATTRIBUTE_FILTER => \Magento\Catalog\Model\Layer\Filter\Attribute::class,
35+
self::PRICE_FILTER => \Magento\Catalog\Model\Layer\Filter\Price::class,
36+
self::DECIMAL_FILTER => \Magento\Catalog\Model\Layer\Filter\Decimal::class,
3737
];
3838

3939
/**

app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ public function getAllOptions()
6363
if ($cache = $this->_configCacheType->load($cacheKey)) {
6464
$options = unserialize($cache);
6565
} else {
66-
$collection = $this->_countryFactory->create()->getResourceCollection()->loadByStore();
67-
$options = $collection->toOptionArray();
66+
/** @var \Magento\Directory\Model\Country $country */
67+
$country = $this->_countryFactory->create();
68+
/** @var \Magento\Directory\Model\ResourceModel\Country\Collection $collection */
69+
$collection = $country->getResourceCollection();
70+
$options = $collection->load()->toOptionArray();
6871
$this->_configCacheType->save(serialize($options), $cacheKey);
6972
}
7073
return $options;

app/code/Magento/Integration/etc/crontab.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
99
<group id="default">
1010
<job name="outdated_authentication_failures_cleanup" instance="Magento\Integration\Cron\CleanExpiredAuthenticationFailures" method="execute">
11-
<schedule>0 1 * * *</schedule>
11+
<schedule>* * * * *</schedule>
1212
</job>
1313
</group>
1414
</config>

app/code/Magento/LayeredNavigation/Block/Navigation.php

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public function __construct(
5959
*/
6060
protected function _prepareLayout()
6161
{
62-
$this->renderer = $this->getChildBlock('renderer');
6362
foreach ($this->filterList->getFilters($this->_catalogLayer) as $filter) {
6463
$filter->apply($this->getRequest());
6564
}

app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php

-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ public function testGetStateHtml()
7171
$stateHtml = 'I feel good';
7272
$this->filterListMock->expects($this->any())->method('getFilters')->will($this->returnValue([]));
7373
$this->layoutMock->expects($this->at(0))->method('getChildName')
74-
->with(null, 'renderer');
75-
$this->layoutMock->expects($this->at(1))->method('getChildName')
7674
->with(null, 'state')
7775
->will($this->returnValue('state block'));
7876

app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php

+3
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ public function send(Creditmemo $creditmemo, $forceSyncMode = false)
126126
$this->creditmemoResource->saveAttribute($creditmemo, ['send_email', 'email_sent']);
127127
return true;
128128
}
129+
} else {
130+
$creditmemo->setEmailSent(null);
131+
$this->creditmemoResource->saveAttribute($creditmemo, 'email_sent');
129132
}
130133

131134
$this->creditmemoResource->saveAttribute($creditmemo, 'send_email');

app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php

+3
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ public function send(Invoice $invoice, $forceSyncMode = false)
126126
$this->invoiceResource->saveAttribute($invoice, ['send_email', 'email_sent']);
127127
return true;
128128
}
129+
} else {
130+
$invoice->setEmailSent(null);
131+
$this->invoiceResource->saveAttribute($invoice, 'email_sent');
129132
}
130133

131134
$this->invoiceResource->saveAttribute($invoice, 'send_email');

app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.php

+3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ public function send(Order $order, $forceSyncMode = false)
104104
$this->orderResource->saveAttribute($order, ['send_email', 'email_sent']);
105105
return true;
106106
}
107+
} else {
108+
$order->setEmailSent(null);
109+
$this->orderResource->saveAttribute($order, 'email_sent');
107110
}
108111

109112
$this->orderResource->saveAttribute($order, 'send_email');

app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php

+3
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ public function send(Shipment $shipment, $forceSyncMode = false)
126126
$this->shipmentResource->saveAttribute($shipment, ['send_email', 'email_sent']);
127127
return true;
128128
}
129+
} else {
130+
$shipment->setEmailSent(null);
131+
$this->shipmentResource->saveAttribute($shipment, 'email_sent');
129132
}
130133

131134
$this->shipmentResource->saveAttribute($shipment, 'send_email');

app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoSenderTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $ema
176176
);
177177
}
178178
} else {
179-
$this->creditmemoResourceMock->expects($this->once())
179+
$this->creditmemoResourceMock->expects($this->at(0))
180+
->method('saveAttribute')
181+
->with($this->creditmemoMock, 'email_sent');
182+
$this->creditmemoResourceMock->expects($this->at(1))
180183
->method('saveAttribute')
181184
->with($this->creditmemoMock, 'send_email');
182185

app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceSenderTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $ema
181181
);
182182
}
183183
} else {
184-
$this->invoiceResourceMock->expects($this->once())
184+
$this->invoiceResourceMock->expects($this->at(0))
185+
->method('saveAttribute')
186+
->with($this->invoiceMock, 'email_sent');
187+
$this->invoiceResourceMock->expects($this->at(1))
185188
->method('saveAttribute')
186189
->with($this->invoiceMock, 'send_email');
187190

app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderSenderTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ public function testSend($configValue, $forceSyncMode, $emailSendingResult)
145145
);
146146
}
147147
} else {
148-
$this->orderResourceMock->expects($this->once())
148+
$this->orderResourceMock->expects($this->at(0))
149+
->method('saveAttribute')
150+
->with($this->orderMock, 'email_sent');
151+
$this->orderResourceMock->expects($this->at(1))
149152
->method('saveAttribute')
150153
->with($this->orderMock, 'send_email');
151154

app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentSenderTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $ema
181181
);
182182
}
183183
} else {
184-
$this->shipmentResourceMock->expects($this->once())
184+
$this->shipmentResourceMock->expects($this->at(0))
185+
->method('saveAttribute')
186+
->with($this->shipmentMock, 'email_sent');
187+
$this->shipmentResourceMock->expects($this->at(1))
185188
->method('saveAttribute')
186189
->with($this->shipmentMock, 'send_email');
187190

app/code/Magento/Translation/Model/Inline/Parser.php

+28-2
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ protected function _applySpecialTagsFormat($tagHtml, $tagName, $trArr)
344344
{
345345
$specialTags = $tagHtml . '<span class="translate-inline-' . $tagName . '" ' . $this->_getHtmlAttribute(
346346
self::DATA_TRANSLATE,
347-
'[' . join(',', $trArr) . ']'
347+
'[' . htmlspecialchars(join(',', $trArr)) . ']'
348348
);
349349
$additionalAttr = $this->_getAdditionalHtmlAttribute($tagName);
350350
if ($additionalAttr !== null) {
@@ -527,10 +527,12 @@ private function _specialTags()
527527
private function _translateTags(&$content, $tagsList, $formatCallback)
528528
{
529529
$nextTag = 0;
530+
$tagRegExpBody = '#<(body)(/?>| \s*[^>]*+/?>)#iSU';
530531

531532
$tags = implode('|', array_keys($tagsList));
532533
$tagRegExp = '#<(' . $tags . ')(/?>| \s*[^>]*+/?>)#iSU';
533534
$tagMatch = [];
535+
$headTranslateTags = '';
534536
while (preg_match($tagRegExp, $content, $tagMatch, PREG_OFFSET_CAPTURE, $nextTag)) {
535537
$tagName = strtolower($tagMatch[1][0]);
536538
if (substr($tagMatch[0][0], -2) == '/>') {
@@ -564,12 +566,36 @@ private function _translateTags(&$content, $tagsList, $formatCallback)
564566

565567
if (!empty($trArr)) {
566568
$trArr = array_unique($trArr);
567-
$tagHtml = call_user_func([$this, $formatCallback], $tagHtml, $tagName, $trArr);
569+
570+
$tagBodyMatch = [];
571+
preg_match($tagRegExpBody, $content, $tagBodyMatch, PREG_OFFSET_CAPTURE);
572+
if (!empty($tagBodyMatch)) {
573+
$tagBodyOpenStartPosition = $tagBodyMatch[0][1];
574+
575+
if (array_key_exists($tagName, $this->_allowedTagsGlobal)
576+
&& $tagBodyOpenStartPosition > $tagMatch[0][1]
577+
) {
578+
$tagHtmlHead = call_user_func([$this, $formatCallback], $tagHtml, $tagName, $trArr);
579+
$headTranslateTags .= substr($tagHtmlHead, strlen($tagHtml));
580+
} else {
581+
$tagHtml = call_user_func([$this, $formatCallback], $tagHtml, $tagName, $trArr);
582+
}
583+
}
584+
568585
$tagClosurePos = $tagMatch[0][1] + strlen($tagHtml);
569586
$content = substr_replace($content, $tagHtml, $tagMatch[0][1], $tagLength);
570587
}
571588
$nextTag = $tagClosurePos;
572589
}
590+
if ($headTranslateTags) {
591+
$tagBodyMatch = [];
592+
preg_match($tagRegExpBody, $content, $tagBodyMatch, PREG_OFFSET_CAPTURE);
593+
$tagBodyOpenStartPosition = $tagBodyMatch[0][1];
594+
$openTagBodyEndPosition = $tagBodyOpenStartPosition + strlen($tagBodyMatch[0][0]);
595+
$content = substr($content, 0, $openTagBodyEndPosition)
596+
. $headTranslateTags
597+
. substr($content, $openTagBodyEndPosition);
598+
}
573599
}
574600

575601
/**

dev/tests/functional/tests/app/Magento/Backend/Test/Repository/ConfigData.xml

+18
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,23 @@
194194
<item name="value" xsi:type="number">0</item>
195195
</field>
196196
</dataset>
197+
198+
<dataset name="custom_allowed_country">
199+
<field name="general/country/allow" xsi:type="array">
200+
<item name="scope" xsi:type="string">default</item>
201+
<item name="scope_id" xsi:type="number">0</item>
202+
<item name="value" xsi:type="array">
203+
<item name="Albania" xsi:type="string">AL</item>
204+
<item name="United States" xsi:type="string">US</item>
205+
</item>
206+
</field>
207+
</dataset>
208+
<dataset name="custom_allowed_country_rollback">
209+
<field name="general/country/allow" xsi:type="array">
210+
<item name="scope" xsi:type="string">default</item>
211+
<item name="scope_id" xsi:type="number">0</item>
212+
<item name="inherit" xsi:type="string">1</item>
213+
</field>
214+
</dataset>
197215
</repository>
198216
</config>

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
<selector>[name="product[news_to_date]"]</selector>
5151
<strategy>css selector</strategy>
5252
</news_to_date>
53+
<country_of_manufacture>
54+
<input>select</input>
55+
</country_of_manufacture>
5356
</fields>
5457
</product-details>
5558
<advanced-pricing>

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.php

+14-4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ class CreateSimpleProductEntityTest extends Injectable
3939
*/
4040
protected $configData;
4141

42+
/**
43+
* Should cache be flushed
44+
*
45+
* @var bool
46+
*/
47+
private $flushCache;
48+
4249
/**
4350
* Prepare data.
4451
*
@@ -62,21 +69,24 @@ public function __prepare(Category $category)
6269
* @param CatalogProductIndex $productGrid
6370
* @param CatalogProductNew $newProductPage
6471
* @param string $configData
72+
* @param bool $flushCache
6573
* @return array
6674
*/
6775
public function testCreate(
6876
CatalogProductSimple $product,
6977
Category $category,
7078
CatalogProductIndex $productGrid,
7179
CatalogProductNew $newProductPage,
80+
$flushCache = false,
7281
$configData = null
7382
) {
7483
$this->configData = $configData;
84+
$this->flushCache = $flushCache;
7585

7686
// Preconditions
7787
$this->objectManager->create(
78-
'Magento\Config\Test\TestStep\SetupConfigurationStep',
79-
['configData' => $this->configData]
88+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
89+
['configData' => $this->configData, 'flushCache' => $this->flushCache]
8090
)->run();
8191

8292
// Steps
@@ -96,8 +106,8 @@ public function testCreate(
96106
public function tearDown()
97107
{
98108
$this->objectManager->create(
99-
'Magento\Config\Test\TestStep\SetupConfigurationStep',
100-
['configData' => $this->configData, 'rollback' => true]
109+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
110+
['configData' => $this->configData, 'rollback' => true, 'flushCache' => $this->flushCache]
101111
)->run();
102112
}
103113
}

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml

+14
Original file line numberDiff line numberDiff line change
@@ -447,5 +447,19 @@
447447
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
448448
<constraint name="Magento\Catalog\Test\Constraint\AssertProductInCategory" />
449449
</variation>
450+
<variation name="CreateSimpleProductEntityTestVariation27" summary="Create Simple Product with custom Country of manufacture" ticketId="MAGETWO-55336">
451+
<data name="configData" xsi:type="string">custom_allowed_country</data>
452+
<data name="flushCache" xsi:type="boolean">true</data>
453+
<data name="product/data/url_key" xsi:type="string">simple-product-%isolation%</data>
454+
<data name="product/data/name" xsi:type="string">Simple Product %isolation%</data>
455+
<data name="product/data/sku" xsi:type="string">simple_sku_%isolation%</data>
456+
<data name="product/data/price/value" xsi:type="string">10000</data>
457+
<data name="product/data/short_description" xsi:type="string">Simple Product short_description %isolation%</data>
458+
<data name="product/data/description" xsi:type="string">Simple Product description %isolation%</data>
459+
<data name="product/data/weight" xsi:type="string">50</data>
460+
<data name="product/data/quantity_and_stock_status/qty" xsi:type="string">657</data>
461+
<data name="product/data/country_of_manufacture" xsi:type="string">Antarctica</data>
462+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
463+
</variation>
450464
</testCase>
451465
</config>

dev/tests/functional/tests/app/Magento/Config/Test/Handler/ConfigData/Curl.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,16 @@ protected function prepareConfigPath(array $input)
8989
}
9090
$resultArray .= '[' . $subPath . ']';
9191
}
92-
$resultArray .= '[value]';
93-
if (is_array($input['value'])) {
92+
$valueCode = isset($input['inherit']) ? 'inherit' : 'value';
93+
$resultArray .= "[$valueCode]";
94+
if (isset($input['value']) && is_array($input['value'])) {
9495
$values = [];
9596
foreach ($input['value'] as $key => $value) {
9697
$values[] = $resultArray . "[$key]=$value";
9798
}
9899
$resultArray = implode('&', $values);
99100
} else {
100-
$resultArray .= '=' . $input['value'];
101+
$resultArray .= '=' . $input[$valueCode];
101102
}
102103
return $resultArray;
103104
}

0 commit comments

Comments
 (0)