Skip to content

Commit e8590e7

Browse files
Merge pull request #6555 from magento-borg/2.4.3-2.4.2-sync-012621
Sync of 2.4.2-develop with 2.4.3-develop
2 parents e6c4e28 + 2ea738a commit e8590e7

File tree

18 files changed

+276
-142
lines changed

18 files changed

+276
-142
lines changed

app/code/Magento/Captcha/Cron/DeleteExpiredImages.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Captcha\Cron;
77

88
use Magento\Framework\App\Filesystem\DirectoryList;
9+
use Magento\Framework\Filesystem\DriverPool;
910

1011
/**
1112
* Captcha cron actions
@@ -48,7 +49,7 @@ public function __construct(
4849
) {
4950
$this->_helper = $helper;
5051
$this->_adminHelper = $adminHelper;
51-
$this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
52+
$this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA, DriverPool::FILE);
5253
$this->_storeManager = $storeManager;
5354
}
5455

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class CatalogMediaConfig
1616
{
1717
private const XML_PATH_CATALOG_MEDIA_URL_FORMAT = 'web/url/catalog_media_url_format';
1818

19-
const IMAGE_OPTIMIZATION_PARAMETERS = 'image_optimization_parameters';
20-
const HASH = 'hash';
19+
public const IMAGE_OPTIMIZATION_PARAMETERS = 'image_optimization_parameters';
20+
public const HASH = 'hash';
2121

2222
/**
2323
* @var ScopeConfigInterface
@@ -41,10 +41,16 @@ public function __construct(ScopeConfigInterface $scopeConfig)
4141
*/
4242
public function getMediaUrlFormat($scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null): string
4343
{
44-
return $this->scopeConfig->getValue(
45-
CatalogMediaConfig::XML_PATH_CATALOG_MEDIA_URL_FORMAT,
44+
$value = $this->scopeConfig->getValue(
45+
self::XML_PATH_CATALOG_MEDIA_URL_FORMAT,
4646
$scopeType,
4747
$scopeCode
4848
);
49+
50+
if ($value === null) {
51+
return self::HASH;
52+
}
53+
54+
return (string)$value;
4955
}
5056
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontFillNewShippingAddressFormInCheckoutActionGroup">
12+
<annotations>
13+
<description>Fills in the provided Address details in the New Address form on the Storefront Checkout pages. By default, this works for the Shipping Address but this can be used for Billing Addresses as well if you pass in the correct 'section' argument value</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="address"/>
17+
<argument name="section" defaultValue="StorefrontCheckoutShippingNewAddressModalSection"/>
18+
</arguments>
19+
<fillField stepKey="fillFirstName" selector="{{section.firstName}}" userInput="{{address.firstname}}"/>
20+
<fillField stepKey="fillLastName" selector="{{section.lastName}}" userInput="{{address.lastname}}"/>
21+
<fillField stepKey="fillCompany" selector="{{section.company}}" userInput="{{address.company}}"/>
22+
<fillField stepKey="fillStreetAddress" selector="{{section.street('0')}}" userInput="{{address.street[0]}}"/>
23+
<selectOption stepKey="selectCounty" selector="{{section.country}}" userInput="{{address.country_id}}"/>
24+
<selectOption stepKey="selectRegion" selector="{{section.region}}" userInput="{{address.state}}"/>
25+
<fillField stepKey="fillCityName" selector="{{section.city}}" userInput="{{address.city}}"/>
26+
<fillField stepKey="fillZip" selector="{{section.postcode}}" userInput="{{address.postcode}}"/>
27+
<fillField stepKey="fillPhoneNumber" selector="{{section.telephone}}" userInput="{{address.telephone}}"/>
28+
</actionGroup>
29+
</actionGroups>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="StorefrontCheckoutShippingNewAddressModalSection">
12+
<element name="firstName" type="input" selector="//div[@id='shipping-new-address-form']//input[@name='firstname']"/>
13+
<element name="lastName" type="input" selector="//div[@id='shipping-new-address-form']//input[@name='lastname']"/>
14+
<element name="company" type="input" selector="//div[@id='shipping-new-address-form']//input[@name='company']"/>
15+
<element name="street" type="input" parameterized="true" selector="//div[@id='shipping-new-address-form']//input[@name='street[{{index}}]']"/>
16+
<element name="city" type="input" selector="//div[@id='shipping-new-address-form']//input[@name='city']"/>
17+
<element name="region" type="select" selector="//div[@id='shipping-new-address-form']//select[@name='region_id']"/>
18+
<element name="postcode" type="input" selector="//div[@id='shipping-new-address-form']//input[@name='postcode']"/>
19+
<element name="country" type="select" selector="//div[@id='shipping-new-address-form']//select[@name='country_id']"/>
20+
<element name="telephone" type="input" selector="//div[@id='shipping-new-address-form']//input[@name='telephone']"/>
21+
<element name="saveAddress" type="button" selector="//div[@id='shipping-new-address-form']//button[contains(@class, 'action-save-address')]"/>
22+
<element name="cancelChangeAddress" type="button" selector="//div[@id='shipping-new-address-form']//button[contains(@class, 'action-hide-popup')]"/>
23+
</section>
24+
</sections>

app/code/Magento/Cms/etc/di.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@
287287
<item name="button" xsi:type="string">button</item>
288288
<item name="i" xsi:type="string">i</item>
289289
<item name="u" xsi:type="string">u</item>
290+
<item name="br" xsi:type="string">br</item>
291+
<item name="b" xsi:type="string">b</item>
290292
</argument>
291293
<argument name="allowedAttributes" xsi:type="array">
292294
<item name="class" xsi:type="string">class</item>

app/code/Magento/MediaGalleryRenditions/etc/media_content.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<search>
1010
<patterns>
1111
<pattern name="media_gallery_renditions">/{{media url=(?:"|&amp;quot;)(?:.renditions)?(.*?)(?:"|&amp;quot;)}}/</pattern>
12-
<pattern name="media_gallery">/{{media url="?((?!.*.renditions).*?)"?}}/</pattern>
12+
<pattern name="media_gallery">/{{media url="?(?:.*?\.renditions\/)(.*?)"?}}/</pattern>
1313
<pattern name="wysiwyg">/src=".*\/media\/(?:.renditions\/)*(.*?)"/</pattern>
1414
<pattern name="catalog_image">/^\/?media\/(?:.renditions\/)?(.*)/</pattern>
1515
<pattern name="catalog_image_with_pub">/^\/pub\/?media\/(?:.renditions\/)?(.*)/</pattern>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminEnhancedMediaGalleryUsedInSectionDisplayedActionGroup">
12+
<annotations>
13+
<description>Assert used in section is displayed in view details.</description>
14+
</annotations>
15+
16+
<seeElement selector="{{AdminEnhancedMediaGalleryViewDetailsSection.usedIn}}" stepKey="assertUsedInPresent"/>
17+
</actionGroup>
18+
</actionGroups>

app/code/Magento/Store/Model/StoreSwitcher/HashProcessor.php

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -96,39 +96,41 @@ public function __construct(
9696
*/
9797
public function switch(StoreInterface $fromStore, StoreInterface $targetStore, string $redirectUrl): string
9898
{
99-
$timestamp = (int) $this->request->getParam('time_stamp');
100-
$signature = (string) $this->request->getParam('signature');
101-
$data = (string) $this->request->getParam('data');
102-
$context = $this->contextFactory->create(
103-
[
104-
'fromStore' => $fromStore,
105-
'targetStore' => $targetStore,
106-
'redirectUrl' => $redirectUrl
107-
]
108-
);
109-
$redirectDataObject = $this->dataFactory->create(
110-
[
111-
'signature' => $signature,
112-
'timestamp' => $timestamp,
113-
'data' => $data
114-
]
115-
);
99+
if ($this->request->getParam('data') !== null) {
100+
$timestamp = (int) $this->request->getParam('time_stamp');
101+
$signature = (string) $this->request->getParam('signature');
102+
$data = (string) $this->request->getParam('data');
103+
$context = $this->contextFactory->create(
104+
[
105+
'fromStore' => $fromStore,
106+
'targetStore' => $targetStore,
107+
'redirectUrl' => $redirectUrl
108+
]
109+
);
110+
$redirectDataObject = $this->dataFactory->create(
111+
[
112+
'signature' => $signature,
113+
'timestamp' => $timestamp,
114+
'data' => $data
115+
]
116+
);
116117

117-
try {
118-
if ($redirectUrl && $this->dataValidator->validate($context, $redirectDataObject)) {
119-
$this->postprocessor->process($context, $this->dataSerializer->unserialize($data));
120-
} else {
121-
throw new LocalizedException(
122-
__('The requested store cannot be found. Please check the request and try again.')
118+
try {
119+
if ($redirectUrl && $this->dataValidator->validate($context, $redirectDataObject)) {
120+
$this->postprocessor->process($context, $this->dataSerializer->unserialize($data));
121+
} else {
122+
throw new LocalizedException(
123+
__('The requested store cannot be found. Please check the request and try again.')
124+
);
125+
}
126+
} catch (LocalizedException $exception) {
127+
$this->messageManager->addErrorMessage($exception->getMessage());
128+
} catch (\Throwable $exception) {
129+
$this->logger->error($exception);
130+
$this->messageManager->addErrorMessage(
131+
__('Something went wrong.')
123132
);
124133
}
125-
} catch (LocalizedException $exception) {
126-
$this->messageManager->addErrorMessage($exception->getMessage());
127-
} catch (\Throwable $exception) {
128-
$this->logger->error($exception);
129-
$this->messageManager->addErrorMessage(
130-
__('Something went wrong.')
131-
);
132134
}
133135

134136
return $redirectUrl;

app/code/Magento/Store/Test/Unit/Model/StoreSwitcher/HashProcessorTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,22 @@ function ($arg) {
128128
$this->postprocessor->expects($this->once())
129129
->method('process')
130130
->with($this->isInstanceOf(ContextInterface::class), ['customer_id' => 1]);
131+
$this->messageManager->expects($this->never())
132+
->method('addErrorMessage');
131133
$this->assertEquals($redirectUrl, $this->model->switch($this->store1, $this->store2, $redirectUrl));
132134
}
133135

134136
public function testShouldNotProcessIfDataValidationFailed(): void
135137
{
136138
$redirectUrl = '/category-1/category-1.1.html';
139+
$this->request->method('getParam')
140+
->willReturnMap(
141+
[
142+
['time_stamp', null, time() - 1],
143+
['data', null, '{"customer_id":1}'],
144+
['signature', null, 'randomstring'],
145+
]
146+
);
137147
$this->dataValidator->method('validate')
138148
->willReturn(false);
139149
$this->postprocessor->expects($this->never())
@@ -148,6 +158,14 @@ public function testShouldNotProcessIfDataValidationFailed(): void
148158
public function testShouldNotProcessIfDataUnserializationFailed(): void
149159
{
150160
$redirectUrl = '/category-1/category-1.1.html';
161+
$this->request->method('getParam')
162+
->willReturnMap(
163+
[
164+
['time_stamp', null, time() - 1],
165+
['data', null, '{"customer_id":1}'],
166+
['signature', null, 'randomstring'],
167+
]
168+
);
151169
$this->dataValidator->method('validate')
152170
->willReturn(true);
153171
$this->dataSerializer->method('unserialize')
@@ -160,4 +178,16 @@ public function testShouldNotProcessIfDataUnserializationFailed(): void
160178

161179
$this->assertEquals($redirectUrl, $this->model->switch($this->store1, $this->store2, $redirectUrl));
162180
}
181+
182+
public function testShouldNotProcessIfDataIsNotPresentInTheRequest(): void
183+
{
184+
$redirectUrl = '/category-1/category-1.1.html';
185+
$this->dataValidator->expects($this->never())
186+
->method('validate');
187+
$this->postprocessor->expects($this->never())
188+
->method('process');
189+
$this->messageManager->expects($this->never())
190+
->method('addErrorMessage');
191+
$this->assertEquals($redirectUrl, $this->model->switch($this->store1, $this->store2, $redirectUrl));
192+
}
163193
}

app/code/Magento/Swatches/Helper/Media.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ public function moveImageFromTmp($file)
176176
} else {
177177
$this->mediaDirectory->renameFile(
178178
$this->mediaConfig->getTmpMediaPath($file),
179-
$this->getAttributeSwatchPath($destinationFile)
179+
$this->mediaDirectory->getDriver()->getRealPathSafety(
180+
$this->getAttributeSwatchPath($destinationFile)
181+
)
180182
);
181183
}
182184

@@ -197,7 +199,7 @@ protected function getUniqueFileName($file)
197199
$file
198200
);
199201
} else {
200-
$destFile = rtrim(dirname($file), '/.') . '/' . \Magento\MediaStorage\Model\File\Uploader::getNewFileName(
202+
$destFile = dirname($file) . '/' . \Magento\MediaStorage\Model\File\Uploader::getNewFileName(
201203
$this->getOriginalFilePath($file)
202204
);
203205
}

0 commit comments

Comments
 (0)