Skip to content

Commit 351ef10

Browse files
Merge branch '2.4-develop' into ACQE-functional-deployment-v4
2 parents b804e44 + 7accebf commit 351ef10

File tree

11 files changed

+165
-37
lines changed

11 files changed

+165
-37
lines changed

app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,18 @@ public function execute($product, $arguments = [])
219219
$clearImages[] = $image['file'];
220220
} elseif (empty($image['value_id']) || !empty($image['recreate'])) {
221221
$newFile = $this->moveImageFromTmp($image['file'] ?? '');
222-
$image['new_file'] = $newFile;
223-
$newImages[$image['file']] = $image;
224-
$image['file'] = $newFile;
222+
if (!empty($image['recreate']) && $newFile !== $image['file']) {
223+
//delete old image
224+
$this->mediaDirectory->renameFile(
225+
$this->mediaConfig->getMediaPath($newFile),
226+
$this->mediaConfig->getMediaPath($image['file'])
227+
);
228+
$existImages[$image['file']] = $image;
229+
} else {
230+
$image['new_file'] = $newFile;
231+
$newImages[$image['file']] = $image;
232+
$image['file'] = $newFile;
233+
}
225234
} else {
226235
$existImages[$image['file']] = $image;
227236
}

app/code/Magento/Directory/Model/Currency.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Directory\Model;
@@ -438,10 +438,6 @@ private function formatCurrency(string $price, array $options): string
438438
$this->getCode() ?? $this->numberFormatter->getTextAttribute(\NumberFormatter::CURRENCY_CODE)
439439
);
440440

441-
if ((array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options)
442-
&& $options[LocaleCurrency::CURRENCY_OPTION_DISPLAY] === \Magento\Framework\Currency::NO_SYMBOL)) {
443-
$formattedCurrency = str_replace(' ', '', $formattedCurrency);
444-
}
445441
if (preg_match('/^(\x{200F})/u', $formattedCurrency, $match)) {
446442
$formattedCurrency = preg_replace('/^' . $match[1] . '/u', '', $formattedCurrency);
447443
}
@@ -488,6 +484,8 @@ private function setOptions(array $options): void
488484
if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options)
489485
&& $options[LocaleCurrency::CURRENCY_OPTION_DISPLAY] === \Magento\Framework\Currency::NO_SYMBOL) {
490486
$this->numberFormatter->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, '');
487+
$this->numberFormatter->setTextAttribute(\NumberFormatter::POSITIVE_PREFIX, '');
488+
$this->numberFormatter->setTextAttribute(\NumberFormatter::POSITIVE_SUFFIX, '');
491489
}
492490
if (array_key_exists('precision', $options)) {
493491
$this->numberFormatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $options['precision']);

app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php

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

@@ -241,6 +241,8 @@ public static function getFormatTxtNumberFormatterDataProvider(): array
241241
['precision' => 2, 'symbol' => '#', 'display' => CurrencyData::NO_SYMBOL],
242242
'9,999.99'
243243
],
244+
['he_IL', 'USD', '9999', [], '9,999.00 ‏$'],
245+
['he_IL', 'USD', '9999', ['display' => CurrencyData::NO_SYMBOL], '9,999.00'],
244246
];
245247
}
246248

app/code/Magento/Elasticsearch/Model/Indexer/Fulltext/Plugin/Category/Product/Action/Rows.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ public function afterExecute(
8989
if (!empty($productIds)) {
9090
$indexer = $this->indexerRegistry->get(FulltextIndexer::INDEXER_ID);
9191
if ($indexer->isScheduled()) {
92-
$indexer->getView()->getChangelog()->addList($productIds);
92+
$changelog = $indexer->getView()->getChangelog();
93+
$changelog->create();
94+
$changelog->addList($productIds);
9395
} else {
9496
$indexer->invalidate();
9597
}

app/code/Magento/QuoteGraphQl/Model/Cart/GetCartForCheckout.php

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

@@ -57,7 +57,7 @@ public function execute(string $cartHash, ?int $customerId, int $storeId): Quote
5757
try {
5858
$cart = $this->getCartForUser->execute($cartHash, $customerId, $storeId);
5959
} catch (NoSuchEntityException $e) {
60-
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
60+
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e, $e->getCode());
6161
}
6262
$this->checkoutAllowance->execute($cart);
6363

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\QuoteGraphQl\Test\Unit\Model\Cart;
10+
11+
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
12+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
13+
use Magento\QuoteGraphQl\Model\Cart\GetCartForCheckout;
14+
use Magento\QuoteGraphQl\Model\Cart\GetCartForUser;
15+
use Magento\QuoteGraphQl\Model\Cart\CheckCartCheckoutAllowance;
16+
use Magento\Framework\Exception\NoSuchEntityException;
17+
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
18+
use PHPUnit\Framework\MockObject\Exception;
19+
use PHPUnit\Framework\TestCase;
20+
21+
class GetCartForCheckoutTest extends TestCase
22+
{
23+
/**
24+
* Verifies that when GetCartForUser::execute throws a NoSuchEntityException with a specific code,
25+
* GetCartForCheckout::execute rethrows it as a GraphQlNoSuchEntityException, preserving the original
26+
* exception message and code.
27+
*
28+
* @return void
29+
* @throws GraphQlNoSuchEntityException
30+
* @throws GraphQlAuthorizationException
31+
* @throws GraphQlInputException
32+
* @throws Exception
33+
*/
34+
public function testExecuteThrowsGraphQlNoSuchEntityExceptionWithOriginalCode()
35+
{
36+
$cartHash = 'test_hash';
37+
$customerId = 1;
38+
$storeId = 2;
39+
$originalCode = 1234;
40+
$originalMessage = 'Cart not found';
41+
42+
$getCartForUser = $this->createMock(GetCartForUser::class);
43+
$getCartForUser->method('execute')
44+
->willThrowException(new NoSuchEntityException(__($originalMessage), null, $originalCode));
45+
46+
$checkoutAllowance = $this->createMock(CheckCartCheckoutAllowance::class);
47+
48+
$getCartForCheckout = new GetCartForCheckout($checkoutAllowance, $getCartForUser);
49+
50+
$this->expectException(GraphQlNoSuchEntityException::class);
51+
$this->expectExceptionMessage($originalMessage);
52+
$this->expectExceptionCode($originalCode);
53+
54+
$getCartForCheckout->execute($cartHash, $customerId, $storeId);
55+
}
56+
}

app/code/Magento/Vault/Model/Ui/Adminhtml/TokensConfigProvider.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Vault\Model\Ui\Adminhtml;
@@ -200,15 +200,16 @@ public function getTokensComponents($vaultPaymentCode)
200200
if ($quote) {
201201
$websiteId = $quote->getStore()->getWebsite()->getId();
202202
}
203-
204203
$this->searchCriteriaBuilder->addFilters(
205204
[
206205
$this->filterBuilder->setField(PaymentTokenInterface::WEBSITE_ID)
207206
->setValue($websiteId)
208207
->create(),
208+
$this->filterBuilder->setField(PaymentTokenInterface::WEBSITE_ID)
209+
->setConditionType('null')
210+
->create(),
209211
]
210212
);
211-
212213
$searchCriteria = $this->searchCriteriaBuilder->create();
213214

214215
foreach ($this->paymentTokenRepository->getList($searchCriteria)->getItems() as $token) {

app/code/Magento/Vault/Test/Unit/Model/Ui/Adminhtml/TokensConfigProviderTest.php

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

@@ -581,10 +581,12 @@ private function createExpectedFilter($field, $value, $atIndex)
581581
->method('setField')
582582
->with($field)
583583
->willReturnSelf();
584-
$this->filterBuilder->expects(new MethodInvokedAtIndex($atIndex))
585-
->method('setValue')
586-
->with($value)
587-
->willReturnSelf();
584+
if ($value !== null) {
585+
$this->filterBuilder->expects(new MethodInvokedAtIndex($atIndex))
586+
->method('setValue')
587+
->with($value)
588+
->willReturnSelf();
589+
}
588590
$this->filterBuilder->expects(new MethodInvokedAtIndex($atIndex))
589591
->method('create')
590592
->willReturn($filterObject);
@@ -623,11 +625,11 @@ private function getSearchCriteria($customerId, $entityId, $vaultProviderCode)
623625
);
624626

625627
$isVisibleFilter = $this->createExpectedFilter(PaymentTokenInterface::IS_VISIBLE, 1, 4);
626-
$websiteFilter = $this->createExpectedFilter(PaymentTokenInterface::WEBSITE_ID, 1, 5);
628+
$websiteFilter1 = $this->createExpectedFilter(PaymentTokenInterface::WEBSITE_ID, 1, 5);
629+
$websiteFilter2 = $this->createExpectedFilter(PaymentTokenInterface::WEBSITE_ID, null, 6);
627630

628-
$this->filterBuilder->expects(static::once())
631+
$this->filterBuilder->expects(self::exactly(2))
629632
->method('setConditionType')
630-
->with('gt')
631633
->willReturnSelf();
632634

633635
$this->searchCriteriaBuilder->expects(self::exactly(6))
@@ -639,7 +641,7 @@ private function getSearchCriteria($customerId, $entityId, $vaultProviderCode)
639641
[$expiresAtFilter, $this->searchCriteriaBuilder],
640642
[$isActiveFilter, $this->searchCriteriaBuilder],
641643
[$isVisibleFilter, $this->searchCriteriaBuilder],
642-
[$websiteFilter, $this->searchCriteriaBuilder],
644+
[[$websiteFilter1, $websiteFilter2], $this->searchCriteriaBuilder],
643645
]
644646
);
645647

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
22
/**
3-
*
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
65
*/
76
declare(strict_types=1);
87

@@ -895,4 +894,41 @@ public function testContentAttributeInGet(): void
895894
$response = $this->_webApiCall($serviceInfo, $requestData);
896895
$this->assertArrayHasKey('content', $response);
897896
}
897+
898+
/**
899+
* Test update() method when existing image gets overwritten and name is not changed
900+
*
901+
* @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php
902+
*/
903+
public function testUpdateExistingImage()
904+
{
905+
$productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
906+
/** @var \Magento\Catalog\Api\Data\ProductInterface $product */
907+
$product = $productRepository->get('simple');
908+
$imageId = (int)$product->getMediaGalleryImages()->getFirstItem()->getValueId();
909+
$requestData = [
910+
'sku' => 'simple',
911+
'entry' => [
912+
'id' => $this->getTargetGalleryEntryId(),
913+
'label' => 'Updated Image Text',
914+
'position' => 10,
915+
'types' => ['thumbnail'],
916+
'disabled' => true,
917+
'media_type' => 'image',
918+
'content' => [
919+
'base64_encoded_data' => base64_encode(file_get_contents($this->testImagePath)),
920+
'type' => 'image/jpeg',
921+
'name' => 'magento_image.jpg',
922+
]
923+
]
924+
];
925+
926+
$this->updateServiceInfo['rest']['resourcePath'] = $this->updateServiceInfo['rest']['resourcePath']
927+
. '/' . $this->getTargetGalleryEntryId();
928+
929+
$this->assertTrue($this->_webApiCall($this->updateServiceInfo, $requestData, null, 'all'));
930+
$updatedImage = $this->assertMediaGalleryData($imageId, '/m/a/magento_image.jpg', 'Updated Image Text');
931+
$this->assertEquals(10, $updatedImage['position_default']);
932+
$this->assertEquals(1, $updatedImage['disabled_default']);
933+
}
898934
}

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4225,7 +4225,10 @@ public function dropTrigger($triggerName, $schemaName = null)
42254225
public function __destruct()
42264226
{
42274227
if ($this->_transactionLevel > 0) {
4228-
trigger_error('Some transactions have not been committed or rolled back', E_USER_ERROR);
4228+
while ($this->_transactionLevel) {
4229+
$this->rollBack();
4230+
}
4231+
$this->logger->log('Some transactions have not been committed or rolled back');
42294232
}
42304233
}
42314234

lib/internal/Magento/Framework/DB/Test/Unit/Adapter/Pdo/MysqlTest.php

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

@@ -15,6 +15,7 @@
1515
use Magento\Framework\DB\SelectFactory;
1616
use Magento\Framework\Model\ResourceModel\Type\Db\Pdo\Mysql;
1717
use Magento\Framework\Serialize\SerializerInterface;
18+
use Magento\Framework\Setup\Declaration\Schema\Dto\Factories\Table as DtoFactoriesTable;
1819
use Magento\Framework\Setup\SchemaListener;
1920
use Magento\Framework\Stdlib\DateTime;
2021
use Magento\Framework\Stdlib\StringUtils;
@@ -55,6 +56,11 @@ class MysqlTest extends TestCase
5556
*/
5657
private $connection;
5758

59+
/**
60+
* @var LoggerInterface|MockObject
61+
*/
62+
private $logger;
63+
5864
/**
5965
* Setup
6066
*/
@@ -741,10 +747,11 @@ private function getMysqlPdoAdapterMock(array $methods): MockObject
741747

742748
$string = $this->createMock(StringUtils::class);
743749
$dateTime = $this->createMock(DateTime::class);
744-
$logger = $this->getMockForAbstractClass(LoggerInterface::class);
750+
$this->logger = $this->createMock(LoggerInterface::class);
745751
$selectFactory = $this->getMockBuilder(SelectFactory::class)
746752
->disableOriginalConstructor()
747753
->getMock();
754+
$dtoFactoriesTable = $this->createMock(DtoFactoriesTable::class);
748755

749756
$adapterMock = $this->getMockBuilder(PdoMysqlAdapter::class)
750757
->onlyMethods(
@@ -753,14 +760,15 @@ private function getMysqlPdoAdapterMock(array $methods): MockObject
753760
[
754761
'string' => $string,
755762
'dateTime' => $dateTime,
756-
'logger' => $logger,
763+
'logger' => $this->logger,
757764
'selectFactory' => $selectFactory,
758765
'config' => [
759766
'dbname' => 'not_exists',
760767
'username' => 'not_valid',
761768
'password' => 'not_valid',
762769
],
763770
'serializer' => $this->serializerMock,
771+
'dtoFactoriesTable' => $dtoFactoriesTable,
764772
]
765773
)
766774
->getMock();
@@ -1067,4 +1075,15 @@ public static function exceptionDataProvider(): array
10671075
[new \Exception()],
10681076
];
10691077
}
1078+
1079+
public function testDestruct(): void
1080+
{
1081+
$adapter = $this->getMysqlPdoAdapterMock(['_connect', '_rollBack']);
1082+
$this->addConnectionMock($adapter);
1083+
$adapter->expects($this->once())->method('_rollBack');
1084+
$this->logger->expects($this->once())->method('log');
1085+
$adapter->beginTransaction();
1086+
$adapter->__destruct();
1087+
$this->assertEquals(0, $adapter->getTransactionLevel());
1088+
}
10701089
}

0 commit comments

Comments
 (0)