Skip to content

Commit 7aeb858

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into aprilrelease
2 parents df33d05 + 7d69f6d commit 7aeb858

File tree

19 files changed

+885
-585
lines changed

19 files changed

+885
-585
lines changed

app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace Magento\Catalog\Model\Product\Option\Type\File;
99

10-
use Laminas\Filter\File\Rename;
11-
use Laminas\File\Transfer\Exception\PhpEnvironmentException;
1210
use Magento\Catalog\Model\Product;
1311
use Magento\Catalog\Model\Product\Exception as ProductException;
1412
use Magento\Framework\App\Filesystem\DirectoryList;
@@ -126,7 +124,6 @@ public function setProduct(Product $product)
126124
* @throws \Exception
127125
* @throws \Magento\Framework\Exception\InputException
128126
* @throws \Magento\Framework\Validator\Exception
129-
* @throws PhpEnvironmentException
130127
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
131128
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
132129
*/
@@ -184,8 +181,6 @@ public function validate($processingParams, $option)
184181
$filePath = $dispersion . '/' . $fileName;
185182
$fileFullPath = $this->mediaDirectory->getAbsolutePath($this->quotePath . $filePath);
186183

187-
$upload->addFilter(new Rename(['target' => $fileFullPath, 'overwrite' => true]));
188-
189184
if ($this->product !== null) {
190185
$this->product->getTypeInstance()->addFileQueue(
191186
[
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Catalog\Plugin\Model;
10+
11+
use Magento\Catalog\Api\Data\CategoryInterface;
12+
use Magento\Catalog\Model\CategoryRepository;
13+
14+
/**
15+
* Plugin for category repository
16+
*/
17+
class CategoryRepositoryPlugin
18+
{
19+
private const ATTRIBUTES_TO_PROCESS = [
20+
'url_key',
21+
'url_path'
22+
];
23+
24+
/**
25+
* Formats category url key and path using the default formatter.
26+
*
27+
* @param CategoryRepository $subject
28+
* @param CategoryInterface $category
29+
* @return array
30+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
31+
*/
32+
public function beforeSave(CategoryRepository $subject, CategoryInterface $category): array
33+
{
34+
foreach (self::ATTRIBUTES_TO_PROCESS as $attributeKey) {
35+
$attribute = $category->getCustomAttribute($attributeKey);
36+
if ($attribute !== null) {
37+
$value = $category->getData($attributeKey);
38+
$formattedValue = $category->formatUrlKey($value);
39+
$attribute->setValue($formattedValue);
40+
}
41+
}
42+
return [$category];
43+
}
44+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Test\Unit\Plugin\Model;
9+
10+
use Magento\Catalog\Plugin\Model\CategoryRepositoryPlugin;
11+
use Magento\Catalog\Model\CategoryRepository;
12+
use PHPUnit\Framework\TestCase;
13+
use PHPUnit\Framework\MockObject\MockObject;
14+
use Magento\Framework\Api\AttributeInterface;
15+
use Magento\Catalog\Model\Category;
16+
17+
class CategoryRepositoryPluginTest extends TestCase
18+
{
19+
/**
20+
* @var CategoryRepositoryPlugin
21+
*/
22+
private $categoryRepositoryPluginMock;
23+
24+
/**
25+
* @var CategoryRepository|MockObject
26+
*/
27+
private $categoryRepositoryMock;
28+
29+
/**
30+
* @var Category|MockObject
31+
*/
32+
private $categoryMock;
33+
34+
protected function setUp(): void
35+
{
36+
$this->categoryRepositoryMock = $this->createMock(CategoryRepository::class);
37+
$this->categoryMock = $this->createMock(Category::class);
38+
$this->categoryRepositoryPluginMock = new CategoryRepositoryPlugin();
39+
}
40+
41+
/**
42+
* Test beforeSave method
43+
*/
44+
public function testBeforeSave()
45+
{
46+
$attributeMock = $this->createMock(AttributeInterface::class);
47+
$urlKey = 'new test Cat (1)!';
48+
$formattedUrlKey = 'new-test-cat-1';
49+
$this->categoryMock->method('getCustomAttribute')
50+
->willReturnMap([
51+
['url_key', $attributeMock],
52+
['url_path', $attributeMock],
53+
]);
54+
55+
$this->categoryMock->method('getData')
56+
->willReturn($urlKey);
57+
58+
$this->categoryMock->method('formatUrlKey')
59+
->willReturn($formattedUrlKey);
60+
61+
$result = $this->categoryRepositoryPluginMock->beforeSave($this->categoryRepositoryMock, $this->categoryMock);
62+
$this->assertSame([$this->categoryMock], $result);
63+
}
64+
}

app/code/Magento/Catalog/etc/webapi_rest/di.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2014 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88

@@ -44,4 +44,7 @@
4444
<plugin name="reindex_after_save_product_links" type="Magento\Catalog\Plugin\Api\ProductLinkRepositoryInterface\ReindexAfterSaveProductLinksPlugin"/>
4545
<plugin name="reindex_after_delete_by_id_product_links" type="Magento\Catalog\Plugin\Api\ProductLinkRepositoryInterface\ReindexAfterDeleteByIdProductLinksPlugin"/>
4646
</type>
47+
<type name="Magento\Catalog\Model\CategoryRepository">
48+
<plugin name="format_category_url_key_rest_api" type="Magento\Catalog\Plugin\Model\CategoryRepositoryPlugin" />
49+
</type>
4750
</config>

app/code/Magento/CatalogGraphQl/Model/Resolver/Product/ProductName.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public function resolve(
3434
Field $field,
3535
$context,
3636
ResolveInfo $info,
37-
array $value = null,
38-
array $args = null
37+
?array $value = null,
38+
?array $args = null
3939
): string {
4040
if (!isset($value['model'])) {
4141
throw new LocalizedException(__('"model" value should be specified'));

app/code/Magento/ImportExport/Model/Source/Upload.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\ImportExport\Model\Source;
99

10-
use Laminas\File\Transfer\Adapter\Http;
10+
use Magento\Framework\File\HttpInterface as Http;
1111
use Laminas\Validator\File\Upload as FileUploadValidator;
1212
use Magento\Framework\App\Filesystem\DirectoryList;
1313
use Magento\Framework\Exception\LocalizedException;

app/code/Magento/ImportExport/Test/Unit/Model/Source/UploadTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\ImportExport\Test\Unit\Model\Source;
99

10-
use Laminas\File\Transfer\Adapter\Http;
10+
use Magento\Framework\File\Http;
1111
use Magento\Framework\Filesystem;
1212
use Magento\Framework\Filesystem\Directory\WriteInterface;
1313
use Magento\Framework\HTTP\Adapter\FileTransferFactory;

app/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
<preference for="Magento\Framework\App\Route\ConfigInterface" type="Magento\Framework\App\Route\Config" />
7676
<preference for="Magento\Framework\App\ResourceConnection\ConfigInterface" type="Magento\Framework\App\ResourceConnection\Config\Proxy" />
7777
<preference for="Magento\Framework\Oauth\OauthInterface" type="Magento\Framework\Oauth\Oauth"/>
78+
<preference for="Magento\Framework\Oauth\Helper\Signature\HmacInterface" type="Magento\Framework\Oauth\Helper\Signature\Hmac" />
7879
<preference for="Magento\Framework\View\Design\Theme\Domain\PhysicalInterface" type="Magento\Theme\Model\Theme\Domain\Physical" />
7980
<preference for="Magento\Framework\View\Design\Theme\Domain\VirtualInterface" type="Magento\Theme\Model\Theme\Domain\Virtual" />
8081
<preference for="Magento\Framework\View\Design\Theme\Domain\StagingInterface" type="Magento\Theme\Model\Theme\Domain\Staging" />

composer.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,11 @@
5959
"laminas/laminas-escaper": "^2.13",
6060
"laminas/laminas-eventmanager": "^3.11",
6161
"laminas/laminas-feed": "^2.22",
62-
"magento/laminas-file": "^1.0.0",
6362
"laminas/laminas-filter": "^2.33",
6463
"laminas/laminas-http": "^2.15",
6564
"laminas/laminas-i18n": "^2.17",
6665
"laminas/laminas-modulemanager": "^2.11",
6766
"laminas/laminas-mvc": "^3.6",
68-
"magento/laminas-oauth": "^1.0.0",
6967
"laminas/laminas-permissions-acl": "^2.10",
7068
"laminas/laminas-servicemanager": "^3.16",
7169
"laminas/laminas-soap": "^2.10",

0 commit comments

Comments
 (0)