Skip to content

Commit f112a05

Browse files
[EngCom] Public Pull Requests - 2.3-develop
- merged latest code from mainline branch
2 parents f804b7c + 250045e commit f112a05

File tree

20 files changed

+139
-50
lines changed

20 files changed

+139
-50
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/GridOnly.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Catalog\Controller\Adminhtml\Product;
87

9-
class GridOnly extends \Magento\Catalog\Controller\Adminhtml\Product
8+
use Magento\Framework\App\Action\HttpGetActionInterface;
9+
10+
/**
11+
* Get specified tab grid controller.
12+
*/
13+
class GridOnly extends \Magento\Catalog\Controller\Adminhtml\Product implements HttpGetActionInterface
1014
{
1115
/**
1216
* @var \Magento\Framework\Controller\Result\RawFactory
@@ -47,7 +51,7 @@ public function execute()
4751
$this->productBuilder->build($this->getRequest());
4852

4953
$block = $this->getRequest()->getParam('gridOnlyBlock');
50-
$blockClassSuffix = str_replace(' ', '_', ucwords(str_replace('_', ' ', $block)));
54+
$blockClassSuffix = ucwords($block, '_');
5155

5256
/** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
5357
$resultRaw = $this->resultRawFactory->create();

app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CurrentUrlRewritesRegeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ protected function getCurrentRewritesMocks($currentRewrites)
252252
->disableOriginalConstructor()->getMock();
253253
foreach ($urlRewrite as $key => $value) {
254254
$url->expects($this->any())
255-
->method('get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))))
255+
->method('get' . str_replace('_', '', ucwords($key, '_')))
256256
->will($this->returnValue($value));
257257
}
258258
$rewrites[] = $url;

app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CurrentUrlRewritesRegeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ protected function getCurrentRewritesMocks($currentRewrites)
294294
->disableOriginalConstructor()->getMock();
295295
foreach ($urlRewrite as $key => $value) {
296296
$url->expects($this->any())
297-
->method('get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))))
297+
->method('get' . str_replace('_', '', ucwords($key, '_')))
298298
->will($this->returnValue($value));
299299
}
300300
$rewrites[] = $url;

app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/AfterImportDataObserverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ protected function currentUrlRewritesRegeneratorGetCurrentRewritesMocks($current
694694
->disableOriginalConstructor()->getMock();
695695
foreach ($urlRewrite as $key => $value) {
696696
$url->expects($this->any())
697-
->method('get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))))
697+
->method('get' . str_replace('_', '', ucwords($key, '_')))
698698
->will($this->returnValue($value));
699699
}
700700
$rewrites[] = $url;

app/code/Magento/Config/Model/Config.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@ protected function _processGroup(
424424
if (!isset($fieldData['value'])) {
425425
$fieldData['value'] = null;
426426
}
427+
428+
if ($field->getType() == 'multiline' && is_array($fieldData['value'])) {
429+
$fieldData['value'] = trim(implode(PHP_EOL, $fieldData['value']));
430+
}
431+
427432
$data = [
428433
'field' => $fieldId,
429434
'groups' => $groups,

app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected function configureEmailTemplate()
106106
$this->transportBuilder->setTemplateIdentifier($this->templateContainer->getTemplateId());
107107
$this->transportBuilder->setTemplateOptions($this->templateContainer->getTemplateOptions());
108108
$this->transportBuilder->setTemplateVars($this->templateContainer->getTemplateVars());
109-
$this->transportBuilder->setFromByStore(
109+
$this->transportBuilder->setFromByScope(
110110
$this->identityContainer->getEmailIdentity(),
111111
$this->identityContainer->getStore()->getId()
112112
);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function setUp()
7676
'setTemplateIdentifier',
7777
'setTemplateOptions',
7878
'setTemplateVars',
79-
'setFromByStore',
79+
'setFromByScope',
8080
]
8181
);
8282

@@ -103,7 +103,7 @@ protected function setUp()
103103
->method('getEmailIdentity')
104104
->will($this->returnValue($emailIdentity));
105105
$this->transportBuilder->expects($this->once())
106-
->method('setFromByStore')
106+
->method('setFromByScope')
107107
->with($this->equalTo($emailIdentity), 1);
108108

109109
$this->identityContainerMock->expects($this->once())
@@ -146,7 +146,7 @@ public function testSend()
146146
->method('getId')
147147
->willReturn(1);
148148
$this->transportBuilder->expects($this->once())
149-
->method('setFromByStore')
149+
->method('setFromByScope')
150150
->with($identity, 1);
151151
$this->transportBuilder->expects($this->once())
152152
->method('addTo')
@@ -176,7 +176,7 @@ public function testSendCopyTo()
176176
->method('addTo')
177177
->with($this->equalTo('example@mail.com'));
178178
$this->transportBuilder->expects($this->once())
179-
->method('setFromByStore')
179+
->method('setFromByScope')
180180
->with($identity, 1);
181181
$this->identityContainerMock->expects($this->once())
182182
->method('getStore')

app/code/Magento/Tax/Test/Unit/Model/Calculation/RateRepositoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ private function getTaxRateMock(array $taxRateData)
252252
foreach ($taxRateData as $key => $value) {
253253
// convert key from snake case to upper case
254254
$taxRateMock->expects($this->any())
255-
->method('get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))))
255+
->method('get' . str_replace('_', '', ucwords($key, '_')))
256256
->will($this->returnValue($value));
257257
}
258258

app/code/Magento/Tax/Test/Unit/Model/Sales/Total/Quote/ShippingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private function getMockObject($className, array $objectState)
133133
$getterValueMap = [];
134134
$methods = ['__wakeup'];
135135
foreach ($objectState as $key => $value) {
136-
$getterName = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key)));
136+
$getterName = 'get' . str_replace('_', '', ucwords($key, '_'));
137137
$getterValueMap[$getterName] = $value;
138138
$methods[] = $getterName;
139139
}

dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Fixture/CatalogSearchQuery/QueryText.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private function createProducts(FixtureFactory $fixtureFactory, $productsData)
6161
$searchValue = isset($productData[2]) ? $productData[2] : $productData[1];
6262
if ($this->data === null) {
6363
if ($product->hasData($searchValue)) {
64-
$getProperty = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $searchValue)));
64+
$getProperty = 'get' . str_replace('_', '', ucwords($searchValue, '_'));
6565
$this->data = $product->$getProperty();
6666
} else {
6767
$this->data = $searchValue;

dev/tests/functional/tests/app/Magento/Widget/Test/Handler/Widget/Curl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ protected function prepareWidgetInstance(array $data)
172172
$widgetInstances = [];
173173
foreach ($data['widget_instance'] as $key => $widgetInstance) {
174174
$pageGroup = $widgetInstance['page_group'];
175-
$method = 'prepare' . str_replace(' ', '', ucwords(str_replace('_', ' ', $pageGroup))) . 'Group';
175+
$method = 'prepare' . str_replace('_', '', ucwords($pageGroup, '_')) . 'Group';
176176
if (!method_exists(__CLASS__, $method)) {
177177
throw new \Exception('Method for prepare page group "' . $method . '" is not exist.');
178178
}

lib/internal/Magento/Framework/Api/SimpleDataObjectConverter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function convertKeysToCamelCase(array $dataArray)
5858
if (is_array($fieldValue) && !$this->_isSimpleSequentialArray($fieldValue)) {
5959
$fieldValue = $this->convertKeysToCamelCase($fieldValue);
6060
}
61-
$fieldName = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $fieldName))));
61+
$fieldName = lcfirst(str_replace('_', '', ucwords($fieldName, '_')));
6262
$response[$fieldName] = $fieldValue;
6363
}
6464
return $response;
@@ -148,7 +148,7 @@ protected function _unpackAssociativeArray($data)
148148
*/
149149
public static function snakeCaseToUpperCamelCase($input)
150150
{
151-
return str_replace(' ', '', ucwords(str_replace('_', ' ', $input)));
151+
return str_replace('_', '', ucwords($input, '_'));
152152
}
153153

154154
/**

lib/internal/Magento/Framework/Code/NameBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function buildClassName($parts)
2626
$separator = '\\';
2727
$string = join($separator, $parts);
2828
$string = str_replace('_', $separator, $string);
29-
$className = str_replace(' ', $separator, ucwords(str_replace($separator, ' ', $string)));
29+
$className = ucwords($string, $separator);
3030
return $className;
3131
}
3232
}

lib/internal/Magento/Framework/DataObject.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public function addData(array $arr)
6464
*
6565
* If $key is an array, it will overwrite all the data in the object.
6666
*
67-
* @param string|array $key
68-
* @param mixed $value
67+
* @param string|array $key
68+
* @param mixed $value
6969
* @return $this
7070
*/
7171
public function setData($key, $value = null)
@@ -111,7 +111,7 @@ public function unsetData($key = null)
111111
* and retrieve corresponding member. If data is the string - it will be explode
112112
* by new line character and converted to array.
113113
*
114-
* @param string $key
114+
* @param string $key
115115
* @param string|int $index
116116
* @return mixed
117117
*/
@@ -202,7 +202,7 @@ protected function _getData($key)
202202
*/
203203
public function setDataUsingMethod($key, $args = [])
204204
{
205-
$method = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key)));
205+
$method = 'set' . str_replace('_', '', ucwords($key, '_'));
206206
$this->{$method}($args);
207207
return $this;
208208
}
@@ -216,12 +216,13 @@ public function setDataUsingMethod($key, $args = [])
216216
*/
217217
public function getDataUsingMethod($key, $args = null)
218218
{
219-
$method = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key)));
219+
$method = 'get' . str_replace('_', '', ucwords($key, '_'));
220220
return $this->{$method}($args);
221221
}
222222

223223
/**
224224
* If $key is empty, checks whether there's any data in the object
225+
*
225226
* Otherwise checks if the specified attribute is set.
226227
*
227228
* @param string $key
@@ -272,8 +273,8 @@ public function convertToArray(array $keys = [])
272273
/**
273274
* Convert object data into XML string
274275
*
275-
* @param array $keys array of keys that must be represented
276-
* @param string $rootName root node name
276+
* @param array $keys array of keys that must be represented
277+
* @param string $rootName root node name
277278
* @param bool $addOpenTag flag that allow to add initial xml node
278279
* @param bool $addCdata flag that require wrap all values in CDATA
279280
* @return string
@@ -436,7 +437,7 @@ protected function _underscore($name)
436437
*
437438
* Example: key1="value1" key2="value2" ...
438439
*
439-
* @param array $keys array of accepted keys
440+
* @param array $keys array of accepted keys
440441
* @param string $valueSeparator separator between key and value
441442
* @param string $fieldSeparator separator between key/value pairs
442443
* @param string $quote quoting sign

lib/internal/Magento/Framework/DataObject/Copy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ protected function _setFieldsetFieldValue($target, $targetCode, $value)
239239
*/
240240
protected function getAttributeValueFromExtensibleDataObject($source, $code)
241241
{
242-
$method = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $code)));
242+
$method = 'get' . str_replace('_', '', ucwords($code, '_'));
243243

244244
$methodExists = method_exists($source, $method);
245245
if ($methodExists == true) {
@@ -273,7 +273,7 @@ protected function getAttributeValueFromExtensibleDataObject($source, $code)
273273
*/
274274
protected function setAttributeValueFromExtensibleDataObject($target, $code, $value)
275275
{
276-
$method = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $code)));
276+
$method = 'set' . str_replace('_', '', ucwords($code, '_'));
277277

278278
$methodExists = method_exists($target, $method);
279279
if ($methodExists == true) {

lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,29 +177,30 @@ public function setReplyTo($email, $name = null)
177177
/**
178178
* Set mail from address
179179
*
180-
* @deprecated This function sets the from address for the first store only.
181-
* new function setFromByStore introduced to allow setting of from address
182-
* based on store.
183-
* @see setFromByStore()
180+
* @deprecated This function sets the from address but does not provide
181+
* a way of setting the correct from addresses based on the scope.
182+
* @see setFromByScope()
184183
*
185184
* @param string|array $from
186185
* @return $this
186+
* @throws \Magento\Framework\Exception\MailException
187187
*/
188188
public function setFrom($from)
189189
{
190-
return $this->setFromByStore($from, null);
190+
return $this->setFromByScope($from, null);
191191
}
192192

193193
/**
194-
* Set mail from address by store
194+
* Set mail from address by scopeId
195195
*
196196
* @param string|array $from
197-
* @param string|int $store
197+
* @param string|int $scopeId
198198
* @return $this
199+
* @throws \Magento\Framework\Exception\MailException
199200
*/
200-
public function setFromByStore($from, $store = null)
201+
public function setFromByScope($from, $scopeId = null)
201202
{
202-
$result = $this->_senderResolver->resolve($from, $store);
203+
$result = $this->_senderResolver->resolve($from, $scopeId);
203204
$this->message->setFromAddress($result['email'], $result['name']);
204205
return $this;
205206
}
@@ -256,6 +257,7 @@ public function setTemplateOptions($templateOptions)
256257
* Get mail transport
257258
*
258259
* @return \Magento\Framework\Mail\TransportInterface
260+
* @throws LocalizedException
259261
*/
260262
public function getTransport()
261263
{

lib/internal/Magento/Framework/Mail/Test/Unit/Template/TransportBuilderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,20 @@ public function getTransportDataProvider()
167167
/**
168168
* @return void
169169
*/
170-
public function testSetFromByStore()
170+
public function testSetFromByScope()
171171
{
172172
$sender = ['email' => 'from@example.com', 'name' => 'name'];
173-
$store = 1;
173+
$scopeId = 1;
174174
$this->senderResolverMock->expects($this->once())
175175
->method('resolve')
176-
->with($sender, $store)
176+
->with($sender, $scopeId)
177177
->willReturn($sender);
178178
$this->messageMock->expects($this->once())
179179
->method('setFromAddress')
180180
->with($sender['email'], $sender['name'])
181181
->willReturnSelf();
182182

183-
$this->builder->setFromByStore($sender, $store);
183+
$this->builder->setFromByScope($sender, $scopeId);
184184
}
185185

186186
/**

lib/internal/Magento/Framework/Module/ModuleList/Loader.php

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,29 @@ private function getModuleConfigs()
126126
*
127127
* @param array $origList
128128
* @return array
129-
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
129+
* @throws \Exception
130130
*/
131-
private function sortBySequence($origList)
131+
private function sortBySequence(array $origList): array
132132
{
133133
ksort($origList);
134+
$modules = $this->prearrangeModules($origList);
135+
134136
$expanded = [];
135-
foreach ($origList as $moduleName => $value) {
137+
foreach (array_keys($modules) as $moduleName) {
138+
$sequence = $this->expandSequence($origList, $moduleName);
139+
asort($sequence);
140+
136141
$expanded[] = [
137142
'name' => $moduleName,
138-
'sequence' => $this->expandSequence($origList, $moduleName),
143+
'sequence' => $sequence,
139144
];
140145
}
141146

142147
// Use "bubble sorting" because usort does not check each pair of elements and in this case it is important
143148
$total = count($expanded);
144149
for ($i = 0; $i < $total - 1; $i++) {
145150
for ($j = $i; $j < $total; $j++) {
146-
if (in_array($expanded[$j]['name'], $expanded[$i]['sequence'])) {
151+
if (in_array($expanded[$j]['name'], $expanded[$i]['sequence'], true)) {
147152
$temp = $expanded[$i];
148153
$expanded[$i] = $expanded[$j];
149154
$expanded[$j] = $temp;
@@ -159,6 +164,27 @@ private function sortBySequence($origList)
159164
return $result;
160165
}
161166

167+
/**
168+
* Prearrange all modules by putting those from Magento before the others
169+
*
170+
* @param array $modules
171+
* @return array
172+
*/
173+
private function prearrangeModules(array $modules): array
174+
{
175+
$breakdown = ['magento' => [], 'others' => []];
176+
177+
foreach ($modules as $moduleName => $moduleDetails) {
178+
if (strpos($moduleName, 'Magento_') !== false) {
179+
$breakdown['magento'][$moduleName] = $moduleDetails;
180+
} else {
181+
$breakdown['others'][$moduleName] = $moduleDetails;
182+
}
183+
}
184+
185+
return array_merge($breakdown['magento'], $breakdown['others']);
186+
}
187+
162188
/**
163189
* Accumulate information about all transitive "sequence" references
164190
*

0 commit comments

Comments
 (0)