Skip to content

Commit 9187ec1

Browse files
authored
Merge pull request #8216 from magento-l3/MAR212023_PR_sarmistha
[L3 Kings] Bugfix delivery
2 parents f87634a + d52eef3 commit 9187ec1

File tree

21 files changed

+509
-37
lines changed

21 files changed

+509
-37
lines changed

app/code/Magento/AwsS3/Driver/AwsS3.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public function deleteDirectory($path): bool
257257
/**
258258
* @inheritDoc
259259
*/
260-
public function filePutContents($path, $content, $mode = null): int
260+
public function filePutContents($path, $content, $mode = null): bool|int
261261
{
262262
$path = $this->normalizeRelativePath($path, true);
263263
$config = self::CONFIG;
@@ -272,10 +272,11 @@ public function filePutContents($path, $content, $mode = null): int
272272

273273
try {
274274
$this->adapter->write($path, $content, new Config($config));
275-
return $this->adapter->fileSize($path)->fileSize();
275+
return ($this->adapter->fileSize($path)->fileSize() !== null)??true;
276+
276277
} catch (FlysystemFilesystemException | UnableToRetrieveMetadata $e) {
277278
$this->logger->error($e->getMessage());
278-
return 0;
279+
return false;
279280
}
280281
}
281282

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminAwsS3SyncZeroByteFilesTest">
12+
<annotations>
13+
<features value="AwsS3"/>
14+
<stories value="zero byte files are synced"/>
15+
<title value="S3 - Verify zero byte files are synced"/>
16+
<description value="Verifies that zero byte files are synced to AWS S3 with error."/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="AC-8252"/>
19+
<useCaseId value="ACP2E-1608"/>
20+
<group value="remote_storage_aws_s3"/>
21+
<group value="skip_in_cloud_native_s3"/>
22+
<group value="remote_storage_disabled"/>
23+
</annotations>
24+
25+
<before>
26+
<!-- Enable AWS S3 Remote Storage & Sync -->
27+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage"/>
28+
<!-- Copy Images to Import Directory for Product Images -->
29+
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProductBaseImage">
30+
<argument name="source">dev/tests/acceptance/tests/_data/empty.jpg</argument>
31+
<argument name="destination">pub/media/empty.jpg</argument>
32+
</helper>
33+
</before>
34+
35+
<after>
36+
<!-- Delete Images on Local File System -->
37+
<helper class="Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="deleteFileIfExists" stepKey="deleteLocalImage">
38+
<argument name="filePath">pub/media/empty.jpg</argument>
39+
</helper>
40+
<!-- Delete Images on S3 System -->
41+
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteFileIfExists" stepKey="deleteS3Image">
42+
<argument name="filePath">pub/media/empty.jpg</argument>
43+
</helper>
44+
<!-- Disable AWS S3 Remote Storage -->
45+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage"/>
46+
</after>
47+
<magentoCLI command="remote-storage:sync" timeout="120" stepKey="syncRemoteStorage"/>
48+
<assertEquals stepKey="assertConfigTest">
49+
<expectedResult type="string">Uploading media files to remote storage.\n- empty.jpg\nEnd of upload.</expectedResult>
50+
<actualResult type="variable">$syncRemoteStorage</actualResult>
51+
</assertEquals>
52+
53+
</test>
54+
</tests>

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*
1616
* @api
1717
* @deprecated 100.2.0 in favour of UI component implementation
18+
* @see don't recommend this approach in favour of UI component implementation
1819
* @since 100.0.2
1920
*/
2021
class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Text
@@ -132,14 +133,16 @@ protected function _toLinkHtml($action, \Magento\Framework\DataObject $row)
132133
}
133134

134135
if (empty($action['id'])) {
135-
$action['id'] = 'id' .$this->random->getRandomString(10);
136+
$action['id'] = 'id' . $this->random->getRandomString(10);
136137
}
137138
$actionAttributes->setData($action);
138139
$onclick = $actionAttributes->getData('onclick');
139140
$style = $actionAttributes->getData('style');
140141
$actionAttributes->unsetData(['onclick', 'style']);
141142
$html = '<a ' . $actionAttributes->serialize() . '>' . $actionCaption . '</a>';
142143
if ($onclick) {
144+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
145+
$onclick = html_entity_decode($onclick);
143146
$html .= $this->secureHtmlRenderer->renderEventListenerAsTag('onclick', $onclick, "#{$action['id']}");
144147
}
145148
if ($style) {

app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection/StoreFrontCustomerAdvancedAttributesSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<element name="datedAttribute" type="input" selector="//input[@id='{{var}}']" parameterized="true"/>
1616
<element name="dropDownAttribute" type="select" selector="//select[@id='{{var}}']" parameterized="true"/>
1717
<element name="dropDownOptionAttribute" type="text" selector="//*[@id='{{var}}']/option[2]" parameterized="true"/>
18-
<element name="multiSelectFirstOptionAttribute" type="text" selector="//select[@id='{{var}}']/option[3]" parameterized="true"/>
18+
<element name="multiSelectFirstOptionAttribute" type="text" selector="//select[@id='{{var}}']/option[2]" parameterized="true"/>
1919
<element name="yesNoAttribute" type="select" selector="//select[@id='{{var}}']" parameterized="true"/>
2020
<element name="yesNoOptionAttribute" type="select" selector="//select[@id='{{var}}']/option[2]" parameterized="true"/>
2121
<element name="selectedOption" type="text" selector="//select[@id='{{var}}']/option[@selected='selected']" parameterized="true"/>

app/code/Magento/Developer/Model/Setup/Declaration/Schema/WhitelistGenerator.php

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ private function persistModule(Schema $schema, string $moduleName)
136136
. Diff::GENERATED_WHITELIST_FILE_NAME;
137137

138138
//We need to load whitelist file and update it with new revision of code.
139+
// phpcs:disable Magento2.Functions.DiscouragedFunction
139140
if (file_exists($whiteListFileName)) {
140141
$content = json_decode(file_get_contents($whiteListFileName), true);
141142
}
@@ -183,6 +184,7 @@ private function getElementsWithFixedName(array $tableData): array
183184
* @param string $tableName
184185
* @param array $tableData
185186
* @return array
187+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
186188
*/
187189
private function getElementsWithAutogeneratedName(Schema $schema, string $tableName, array $tableData) : array
188190
{
@@ -192,35 +194,42 @@ private function getElementsWithAutogeneratedName(Schema $schema, string $tableN
192194
$elementType = 'index';
193195
if (!empty($tableData[$elementType])) {
194196
foreach ($tableData[$elementType] as $tableElementData) {
195-
$indexName = $this->elementNameResolver->getFullIndexName(
196-
$table,
197-
$tableElementData['column'],
198-
$tableElementData['indexType'] ?? null
199-
);
200-
$declaredStructure[$elementType][$indexName] = true;
197+
if (isset($tableElementData['column'])) {
198+
$indexName = $this->elementNameResolver->getFullIndexName(
199+
$table,
200+
$tableElementData['column'],
201+
$tableElementData['indexType'] ?? null
202+
);
203+
$declaredStructure[$elementType][$indexName] = true;
204+
}
201205
}
202206
}
203207

204208
$elementType = 'constraint';
205209
if (!empty($tableData[$elementType])) {
206210
foreach ($tableData[$elementType] as $tableElementData) {
207-
if ($tableElementData['type'] === 'foreign') {
208-
$referenceTable = $schema->getTableByName($tableElementData['referenceTable']);
209-
$column = $table->getColumnByName($tableElementData['column']);
210-
$referenceColumn = $referenceTable->getColumnByName($tableElementData['referenceColumn']);
211-
$constraintName = ($column !== false && $referenceColumn !== false) ?
212-
$this->elementNameResolver->getFullFKName(
211+
$constraintName = null;
212+
if (isset($tableElementData['type'], $tableElementData['column'])) {
213+
if ($tableElementData['type'] === 'foreign') {
214+
$column = $table->getColumnByName($tableElementData['column']);
215+
$referenceTable = $schema->getTableByName($tableElementData['referenceTable'] ?? null);
216+
$referenceColumn = ($referenceTable !== false)
217+
? $referenceTable->getColumnByName($tableElementData['referenceColumn'] ?? null) : false;
218+
219+
$constraintName = ($column !== false && $referenceColumn !== false) ?
220+
$this->elementNameResolver->getFullFKName(
221+
$table,
222+
$column,
223+
$referenceTable,
224+
$referenceColumn
225+
) : null;
226+
} else {
227+
$constraintName = $this->elementNameResolver->getFullIndexName(
213228
$table,
214-
$column,
215-
$referenceTable,
216-
$referenceColumn
217-
) : null;
218-
} else {
219-
$constraintName = $this->elementNameResolver->getFullIndexName(
220-
$table,
221-
$tableElementData['column'],
222-
$tableElementData['type']
223-
);
229+
$tableElementData['column'],
230+
$tableElementData['type']
231+
);
232+
}
224233
}
225234
if ($constraintName) {
226235
$declaredStructure[$elementType][$constraintName] = true;

app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public function execute()
4040
try {
4141
$data = $this->getRequest()->getPost('history');
4242
if (empty($data['comment']) && $data['status'] == $order->getDataByKey('status')) {
43-
throw new \Magento\Framework\Exception\LocalizedException(
44-
__('The comment is missing. Enter and try again.')
45-
);
43+
$error = 'Please provide a comment text or ' .
44+
'update the order status to be able to submit a comment for this order.';
45+
throw new \Magento\Framework\Exception\LocalizedException(__($error));
4646
}
4747

4848
$orderStatus = $this->getOrderStatus($order->getDataByKey('status'), $data['status']);
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminOrderInformationCommentHintTest">
12+
<annotations>
13+
<features value="Sales"/>
14+
<stories value="Admin order information page"/>
15+
<title value="Dialog box error message when submitting comment in Order Details page"/>
16+
<description value="Check comment hint and dialog box error message visible"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="AC-8374"/>
19+
<useCaseId value="ACP2E-1775"/>
20+
<group value="sales"/>
21+
</annotations>
22+
<before>
23+
<createData entity="_defaultCategory" stepKey="createCategory"/>
24+
<createData entity="SimpleProduct" stepKey="createProduct">
25+
<requiredEntity createDataKey="createCategory"/>
26+
</createData>
27+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
28+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
29+
<!-- Create order -->
30+
<createData entity="CustomerCart" stepKey="createCustomerCart">
31+
<requiredEntity createDataKey="createCustomer"/>
32+
</createData>
33+
<createData entity="CustomerCartItem" stepKey="addCartItem">
34+
<requiredEntity createDataKey="createCustomerCart"/>
35+
<requiredEntity createDataKey="createProduct"/>
36+
</createData>
37+
<createData entity="CustomerAddressInformation" stepKey="addCustomerOrderAddress">
38+
<requiredEntity createDataKey="createCustomerCart"/>
39+
</createData>
40+
<updateData createDataKey="createCustomerCart" entity="CustomerOrderPaymentMethod" stepKey="createFirstOrder">
41+
<requiredEntity createDataKey="createCustomerCart"/>
42+
</updateData>
43+
</before>
44+
<after>
45+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
46+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
47+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
48+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
49+
</after>
50+
51+
<!-- Open Admin Order page -->
52+
<actionGroup ref="AdminOpenOrderViewPageByOrderIdActionGroup" stepKey="openOrder">
53+
<argument name="orderId" value="$createCustomerCart.return$"/>
54+
</actionGroup>
55+
56+
<!--Go to submit comment section and verify the comment hint text-->
57+
<scrollTo selector="#order_history_block" stepKey="scrollToSection"/>
58+
<see userInput="A status change or comment text is required to submit a comment." stepKey="seeMessageNotesForThisOrder"/>
59+
</test>
60+
</tests>

app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/AddCommentTest.php

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Magento\Backend\Model\View\Result\RedirectFactory;
1313
use Magento\Framework\App\Request\Http;
1414
use Magento\Framework\AuthorizationInterface;
15+
use Magento\Framework\Controller\Result\Json;
16+
use Magento\Framework\Controller\Result\JsonFactory;
1517
use Magento\Framework\ObjectManagerInterface;
1618
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1719
use Magento\Sales\Api\OrderRepositoryInterface;
@@ -77,6 +79,12 @@ class AddCommentTest extends TestCase
7779
*/
7880
private $objectManagerMock;
7981

82+
/** @var JsonFactory|MockObject */
83+
private $jsonFactory;
84+
85+
/** @var Json|MockObject */
86+
private $resultJson;
87+
8088
/**
8189
* Test setup
8290
*/
@@ -94,14 +102,22 @@ protected function setUp(): void
94102

95103
$this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
96104

105+
$this->resultJson = $this->getMockBuilder(Json::class)
106+
->disableOriginalConstructor()
107+
->getMock();
108+
$this->jsonFactory = $this->getMockBuilder(JsonFactory::class)
109+
->disableOriginalConstructor()
110+
->getMock();
111+
97112
$objectManagerHelper = new ObjectManager($this);
98113
$this->addCommentController = $objectManagerHelper->getObject(
99114
AddComment::class,
100115
[
101116
'context' => $this->contextMock,
102117
'orderRepository' => $this->orderRepositoryMock,
103118
'_authorization' => $this->authorizationMock,
104-
'_objectManager' => $this->objectManagerMock
119+
'_objectManager' => $this->objectManagerMock,
120+
'resultJsonFactory' => $this->jsonFactory
105121
]
106122
);
107123
}
@@ -205,4 +221,44 @@ public function executeWillNotifyCustomerDataProvider()
205221
],
206222
];
207223
}
224+
225+
/**
226+
* Assert error message for empty comment value
227+
*
228+
* @return void
229+
*/
230+
public function testExecuteForEmptyCommentMessage(): void
231+
{
232+
$orderId = 30;
233+
$orderStatus = 'processing';
234+
$historyData = [
235+
'comment' => '',
236+
'is_customer_notified' => false,
237+
'status' => 'processing'
238+
];
239+
240+
$this->requestMock->expects($this->once())->method('getParam')->with('order_id')->willReturn($orderId);
241+
$this->orderMock->expects($this->atLeastOnce())->method('getDataByKey')
242+
->with('status')->willReturn($orderStatus);
243+
$this->orderRepositoryMock->expects($this->once())
244+
->method('get')
245+
->willReturn($this->orderMock);
246+
$this->requestMock->expects($this->once())->method('getPost')->with('history')->willReturn($historyData);
247+
248+
$this->resultJson->expects($this->once())
249+
->method('setData')
250+
->with(
251+
[
252+
'error' => true,
253+
'message' => 'Please provide a comment text or ' .
254+
'update the order status to be able to submit a comment for this order.'
255+
]
256+
)
257+
->willReturnSelf();
258+
$this->jsonFactory->expects($this->once())
259+
->method('create')
260+
->willReturn($this->resultJson);
261+
262+
$this->assertSame($this->resultJson, $this->addCommentController->execute());
263+
}
208264
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,3 +808,5 @@ If set YES Email field will be required during Admin order creation for new Cust
808808
"This creditmemo no longer exists.","This creditmemo no longer exists."
809809
"Add to address book","Add to address book"
810810
"Logo for PDF Print-outs","Logo for PDF Print-outs"
811+
"Please provide a comment text or update the order status to be able to submit a comment for this order.", "Please provide a comment text or update the order status to be able to submit a comment for this order."
812+
"A status change or comment text is required to submit a comment.", "A status change or comment text is required to submit a comment."

app/code/Magento/Sales/view/adminhtml/templates/order/view/history.phtml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636
cols="5"
3737
id="history_comment"
3838
class="admin__control-textarea"></textarea>
39+
<div class="admin__field-note">
40+
<span>
41+
<?= $block->escapeHtml(
42+
__('A status change or comment text is required to submit a comment.')
43+
)?>
44+
</span>
45+
</div>
3946
</div>
4047
</div>
4148

0 commit comments

Comments
 (0)