Skip to content

Commit e7d6678

Browse files
author
Oleksii Korshenko
authored
Merge pull request #99 from magento-api/pull-request
[API-Ext-Ogre] P0-P1 Bugs
2 parents 1ea57c2 + 76f3706 commit e7d6678

File tree

21 files changed

+499
-106
lines changed

21 files changed

+499
-106
lines changed

app/code/Magento/Backend/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,3 +456,4 @@ Pagination,Pagination
456456
"Anchor Text for Next","Anchor Text for Next"
457457
"Alternative text for the next pages link in the pagination menu. If empty, default arrow image is used.","Alternative text for the next pages link in the pagination menu. If empty, default arrow image is used."
458458
"Theme Name","Theme Name"
459+
"Deployment config file %1 is not writable.","Deployment config file %1 is not writable."

app/code/Magento/PageCache/etc/varnish3.vcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ sub vcl_recv {
4949
return (pass);
5050
}
5151

52-
# Bypass shopping cart and checkout requests
53-
if (req.url ~ "/checkout") {
52+
# Bypass shopping cart, checkout and search requests
53+
if (req.url ~ "/checkout" || req.url ~ "/catalogsearch") {
5454
return (pass);
5555
}
5656

app/code/Magento/PageCache/etc/varnish4.vcl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ sub vcl_recv {
4141
return (pass);
4242
}
4343

44-
# Bypass shopping cart and checkout requests
45-
if (req.url ~ "/checkout") {
44+
# Bypass shopping cart, checkout and search requests
45+
if (req.url ~ "/checkout" || req.url ~ "/catalogsearch") {
4646
return (pass);
4747
}
4848

@@ -136,6 +136,16 @@ sub vcl_backend_response {
136136
set beresp.grace = 1m;
137137
}
138138
}
139+
140+
# If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass
141+
if (beresp.ttl <= 0s ||
142+
beresp.http.Surrogate-control ~ "no-store" ||
143+
(!beresp.http.Surrogate-Control && beresp.http.Vary == "*")) {
144+
# Mark as Hit-For-Pass for the next 2 minutes
145+
set beresp.ttl = 120s;
146+
set beresp.uncacheable = true;
147+
}
148+
return (deliver);
139149
}
140150

141151
sub vcl_deliver {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,12 @@ private function _prepareTagAttributesForContent(&$content)
436436
$tagHtml = str_replace($matches[0], '', $tagHtml);
437437
$trAttr = ' ' . $this->_getHtmlAttribute(
438438
self::DATA_TRANSLATE,
439-
'[' . htmlspecialchars($matches[1]) . ',' . join(',', $trArr) . ']'
439+
'[' . htmlspecialchars($matches[1]) . ',' . str_replace("\"", "'", join(',', $trArr)) . ']'
440440
);
441441
} else {
442442
$trAttr = ' ' . $this->_getHtmlAttribute(
443443
self::DATA_TRANSLATE,
444-
'[' . join(',', $trArr) . ']'
444+
'[' . str_replace("\"", "'", join(',', $trArr)) . ']'
445445
);
446446
}
447447
$trAttr = $this->_addTranslateAttribute($trAttr);
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Translation\Test\Unit\Model\Inline;
7+
8+
/**
9+
* Class ParserTest to test \Magento\Translation\Model\Inline\Parser
10+
*/
11+
class ParserTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var \Magento\Translation\Model\Inline\Parser|\PHPUnit_Framework_MockObject_MockObject
15+
*/
16+
private $model;
17+
18+
/**
19+
* @var \Magento\Translation\Model\ResourceModel\StringUtilsFactory|\PHPUnit_Framework_MockObject_MockObject
20+
*/
21+
private $resourceMock;
22+
23+
/**
24+
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
private $storeManagerMock;
27+
28+
/**
29+
* @var \Zend_Filter_Interface|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $inputFilterMock;
32+
33+
/**
34+
* @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject
35+
*/
36+
private $appStateMock;
37+
38+
/**
39+
* @var \Magento\Framework\App\Cache\TypeListInterface|\PHPUnit_Framework_MockObject_MockObject
40+
*/
41+
private $appCacheMock;
42+
43+
/**
44+
* @var \Magento\Framework\Translate\InlineInterface|\PHPUnit_Framework_MockObject_MockObject
45+
*/
46+
private $translateInlineMock;
47+
48+
protected function setUp()
49+
{
50+
$this->resourceMock = $this->getMockBuilder('Magento\Translation\Model\ResourceModel\StringUtilsFactory')
51+
->disableOriginalConstructor()
52+
->setMethods([])
53+
->getMock();
54+
55+
$this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface')
56+
->disableOriginalConstructor()
57+
->setMethods([])
58+
->getMock();
59+
60+
$this->inputFilterMock = $this->getMockBuilder('Zend_Filter_Interface')
61+
->disableOriginalConstructor()
62+
->setMethods([])
63+
->getMock();
64+
65+
$this->appStateMock = $this->getMockBuilder('Magento\Framework\App\State')
66+
->disableOriginalConstructor()
67+
->setMethods([])
68+
->getMock();
69+
70+
$this->appCacheMock = $this->getMockBuilder('Magento\Framework\App\Cache\TypeListInterface')
71+
->disableOriginalConstructor()
72+
->setMethods([])
73+
->getMock();
74+
75+
$this->translateInlineMock= $this->getMockBuilder('Magento\Framework\Translate\InlineInterface')
76+
->disableOriginalConstructor()
77+
->setMethods([])
78+
->getMock();
79+
80+
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
81+
$this->model = $objectManagerHelper->getObject(
82+
'Magento\Translation\Model\Inline\Parser',
83+
[
84+
"_resourceFactory" => $this->resourceMock,
85+
"_storeManager" => $this->storeManagerMock,
86+
"_inputFilter" => $this->inputFilterMock,
87+
"_appState" => $this->appStateMock,
88+
"_appCache" => $this->appCacheMock,
89+
"_translateInline" => $this->translateInlineMock
90+
]
91+
);
92+
}
93+
94+
public function testProcessResponseBodyStringProcessingAttributesCorrectly()
95+
{
96+
$testContent = file_get_contents(__DIR__ . '/_files/datatranslate_fixture.html');
97+
$processedAttributes = [
98+
"data-translate=\"[{'shown':'* Required Fields','translated':'* Required Fields',"
99+
. "'original':'* Required Fields','location':'Tag attribute (ALT, TITLE, etc.)'}]\"",
100+
"data-translate=\"[{'shown':'Email','translated':'Email','original':'Email',"
101+
. "'location':'Tag attribute (ALT, TITLE, etc.)'}]\"",
102+
"data-translate=\"[{'shown':'Password','translated':'Password','original':'Password',"
103+
. "'location':'Tag attribute (ALT, TITLE, etc.)'}]\""
104+
];
105+
$this->translateInlineMock->expects($this->any())->method('getAdditionalHtmlAttribute')->willReturn(null);
106+
107+
$processedContent = $this->model->processResponseBodyString($testContent);
108+
foreach ($processedAttributes as $attribute) {
109+
$this->assertContains($attribute, $processedContent, "data-translate attribute not processed correctly");
110+
}
111+
}
112+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<div class="login-container">
2+
<div class="block block-customer-login">
3+
<div class="block-content" aria-labelledby="block-customer-login-heading">
4+
<form class="form form-login"
5+
action=""
6+
method="post"
7+
id="login-form"
8+
data-mage-init='{"validation":{}}'>
9+
<input name="form_key" type="hidden" value="" />
10+
<fieldset class="fieldset login" data-hasrequired="{{{* Required Fields}}{{* Required Fields}}{{* Required Fields}}{{theme3}}}">
11+
<div class="field note">{{{If you have an account, sign in with your email address.}}{{If you have an account, sign in with your email address.}}{{If you have an account, sign in with your email address.}}{{theme3}}}</div>
12+
<div class="field email required">
13+
<label class="label" for="email"><span>{{{Email}}{{Email}}{{Email}}{{theme3}}}</span></label>
14+
<div class="control">
15+
<input name="login[username]" value="" autocomplete="off" id="email" type="email" class="input-text" title="{{{Email}}{{Email}}{{Email}}{{theme3}}}" data-validate="{required:true, 'validate-email':true}">
16+
</div>
17+
</div>
18+
<div class="field password required">
19+
<label for="pass" class="label"><span>{{{Password}}{{Password}}{{Password}}{{theme3}}}</span></label>
20+
<div class="control">
21+
<input name="login[password]" type="password" autocomplete="off" class="input-text" id="pass" title="{{{Password}}{{Password}}{{Password}}{{theme3}}}" data-validate="{required:true}">
22+
</div>
23+
</div>
24+
<div class="actions-toolbar">
25+
<div class="primary"><button type="submit" class="action login primary" name="send" id="send2"><span>{{{Sign In}}{{Sign In}}{{Sign In}}{{theme3}}}</span></button></div>
26+
<div class="secondary"><a class="action remind" href=""><span>{{{Forgot Your Password?}}{{Forgot Your Password?}}{{Forgot Your Password?}}{{theme3}}}</span></a></div>
27+
</div>
28+
</fieldset>
29+
</form>
30+
</div>
31+
</div>
32+
</div>

app/code/Magento/User/Model/ResourceModel/User.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ protected function _afterSave(\Magento\Framework\Model\AbstractModel $user)
186186
*/
187187
public function _clearUserRoles(ModelUser $user)
188188
{
189-
$conditions = ['user_id = ?' => (int)$user->getId()];
189+
$conditions = ['user_id = ?' => (int)$user->getId(), 'user_type = ?' => UserContextInterface::USER_TYPE_ADMIN];
190190
$this->getConnection()->delete($this->getTable('authorization_role'), $conditions);
191191
}
192192

@@ -255,13 +255,13 @@ public function delete(\Magento\Framework\Model\AbstractModel $user)
255255
$uid = $user->getId();
256256
$connection->beginTransaction();
257257
try {
258-
$conditions = ['user_id = ?' => $uid];
259-
260-
$connection->delete($this->getMainTable(), $conditions);
261-
$connection->delete($this->getTable('authorization_role'), $conditions);
258+
$connection->delete($this->getMainTable(), ['user_id = ?' => $uid]);
259+
$connection->delete(
260+
$this->getTable('authorization_role'),
261+
['user_id = ?' => $uid, 'user_type = ?' => UserContextInterface::USER_TYPE_ADMIN]
262+
);
262263
} catch (\Magento\Framework\Exception\LocalizedException $e) {
263264
throw $e;
264-
return false;
265265
} catch (\Exception $e) {
266266
$connection->rollBack();
267267
return false;
@@ -329,7 +329,11 @@ public function deleteFromRole(\Magento\Framework\Model\AbstractModel $user)
329329

330330
$dbh = $this->getConnection();
331331

332-
$condition = ['user_id = ?' => (int)$user->getId(), 'parent_id = ?' => (int)$user->getRoleId()];
332+
$condition = [
333+
'user_id = ?' => (int)$user->getId(),
334+
'parent_id = ?' => (int)$user->getRoleId(),
335+
'user_type = ?' => UserContextInterface::USER_TYPE_ADMIN
336+
];
333337

334338
$dbh->delete($this->getTable('authorization_role'), $condition);
335339
return $this;
@@ -348,9 +352,16 @@ public function roleUserExists(\Magento\Framework\Model\AbstractModel $user)
348352

349353
$dbh = $this->getConnection();
350354

351-
$binds = ['parent_id' => $user->getRoleId(), 'user_id' => $user->getUserId()];
355+
$binds = [
356+
'parent_id' => $user->getRoleId(),
357+
'user_id' => $user->getUserId(),
358+
'user_type' => UserContextInterface::USER_TYPE_ADMIN
359+
];
352360

353-
$select = $dbh->select()->from($roleTable)->where('parent_id = :parent_id')->where('user_id = :user_id');
361+
$select = $dbh->select()->from($roleTable)
362+
->where('parent_id = :parent_id')
363+
->where('user_type = :user_type')
364+
->where('user_id = :user_id');
354365

355366
return $dbh->fetchCol($select, $binds);
356367
} else {

app/code/Magento/Webapi/Model/Rest/Swagger/Generator.php

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Magento\Framework\Exception\NoSuchEntityException;
2020
use Magento\Framework\Phrase;
2121
use Magento\Framework\App\ProductMetadataInterface;
22+
use \Magento\Framework\Api\SimpleDataObjectConverter;
2223

2324
/**
2425
* REST Swagger schema generator.
@@ -541,10 +542,52 @@ protected function getDefinitions()
541542
],
542543
],
543544
],
544-
$this->definitions
545+
$this->snakeCaseDefinitions($this->definitions)
545546
);
546547
}
547548

549+
/**
550+
* Converts definitions' properties array to snake_case.
551+
*
552+
* @param array $definitions
553+
* @return array
554+
*/
555+
private function snakeCaseDefinitions($definitions)
556+
{
557+
foreach ($definitions as $name => $vals) {
558+
if (!empty($vals['properties'])) {
559+
$definitions[$name]['properties'] = $this->convertArrayToSnakeCase($vals['properties']);
560+
}
561+
if (!empty($vals['required'])) {
562+
$snakeCaseRequired = [];
563+
foreach ($vals['required'] as $requiredProperty) {
564+
$snakeCaseRequired[] = SimpleDataObjectConverter::camelCaseToSnakeCase($requiredProperty);
565+
}
566+
$definitions[$name]['required'] = $snakeCaseRequired;
567+
}
568+
}
569+
return $definitions;
570+
}
571+
572+
/**
573+
* Converts associative array's key names from camelCase to snake_case, recursively.
574+
*
575+
* @param array $properties
576+
* @return array
577+
*/
578+
private function convertArrayToSnakeCase($properties)
579+
{
580+
foreach ($properties as $name => $value) {
581+
$snakeCaseName = SimpleDataObjectConverter::camelCaseToSnakeCase($name);
582+
if (is_array($value)) {
583+
$value = $this->convertArrayToSnakeCase($value);
584+
}
585+
unset($properties[$name]);
586+
$properties[$snakeCaseName] = $value;
587+
}
588+
return $properties;
589+
}
590+
548591
/**
549592
* Get definition reference
550593
*

dev/tests/api-functional/testsuite/Magento/Webapi/JsonGenerationFromDataObjectTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public function getExpectedMultiServiceData()
240240
'type' => 'object',
241241
'description' => 'Interface for custom attribute value.',
242242
'properties' => [
243-
'attributeCode' => [
243+
'attribute_code' => [
244244
'type' => 'string',
245245
'description' => 'Attribute code',
246246
],
@@ -250,15 +250,15 @@ public function getExpectedMultiServiceData()
250250
],
251251
],
252252
'required' => [
253-
'attributeCode',
253+
'attribute_code',
254254
'value',
255255
],
256256
],
257257
'test-module5-v1-entity-all-soap-and-rest' => [
258258
'type' => 'object',
259259
'description' => 'Some Data Object short description. Data Object long multi line description.',
260260
'properties' => [
261-
'entityId' => [
261+
'entity_id' => [
262262
'type' => 'integer',
263263
'description' => 'Item ID',
264264
],
@@ -274,7 +274,7 @@ public function getExpectedMultiServiceData()
274274
'type' => 'boolean',
275275
'description' => 'If current entity has a property defined',
276276
],
277-
'customAttributes' => [
277+
'custom_attributes' => [
278278
'type' => 'array',
279279
'description' => 'Custom attributes values.',
280280
'items' => [
@@ -283,7 +283,7 @@ public function getExpectedMultiServiceData()
283283
],
284284
],
285285
'required' => [
286-
'entityId',
286+
'entity_id',
287287
'enabled',
288288
'orders',
289289
],

dev/tests/functional/tests/app/Magento/Upgrade/Test/Block/SelectVersion.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,15 @@ public function fill(FixtureInterface $fixture, SimpleElement $element = null)
5252
$this->waitForElementVisible($this->firstField);
5353
return parent::fill($fixture, $element);
5454
}
55+
56+
/**
57+
* Choose 'yes' for upgrade option called 'Other components'
58+
*
59+
* @return void
60+
*/
61+
public function chooseUpgradeOtherComponents()
62+
{
63+
$this->_rootElement->find("[for=yesUpdateComponents]", Locator::SELECTOR_CSS)->click();
64+
$this->waitForElementVisible("[ng-show='componentsProcessed']");
65+
}
5566
}

dev/tests/functional/tests/app/Magento/Upgrade/Test/TestCase/UpgradeSystemTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ public function test(
106106
// Select upgrade to version
107107
$this->setupWizard->getSystemUpgradeHome()->clickSystemUpgrade();
108108
$this->setupWizard->getSelectVersion()->fill($upgradeFixture);
109+
if ($upgrade['otherComponents'] === 'Yes') {
110+
$this->setupWizard->getSelectVersion()->chooseUpgradeOtherComponents();
111+
}
109112
$this->setupWizard->getSelectVersion()->clickNext();
110113

111114
// Readiness Check

0 commit comments

Comments
 (0)