Skip to content

Commit 4ab7f9c

Browse files
Merge branch '2.4-develop' into Arrows-AC-14602
2 parents 9ed2b8b + e3f780b commit 4ab7f9c

File tree

11 files changed

+203
-31
lines changed

11 files changed

+203
-31
lines changed

app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class StorageTest extends TestCase
161161
'jpg' => 'image/jpg',
162162
'jpeg' => 'image/jpeg',
163163
'png' => 'image/png',
164-
'gif' => 'image/png',
164+
'gif' => 'image/gif',
165165
];
166166

167167
/**
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
99
<type name="Magento\LoginAsCustomerApi\Api\AuthenticateCustomerBySecretInterface">
10-
<plugin name="log_authentication"
10+
<plugin name="log_login_as_customer_authentication"
1111
type="Magento\LoginAsCustomerLog\Plugin\LoginAsCustomerApi\LogAuthenticationPlugin"/>
1212
</type>
1313
</config>

app/code/Magento/PageCache/Model/App/Request/Http/IdentifierForSave.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public function getValue()
5252
$this->request->isSecure(),
5353
$baseUrl,
5454
$query,
55-
$this->context->getVaryString()
55+
$this->request->get(\Magento\Framework\App\Response\Http::COOKIE_VARY_STRING)
56+
?: $this->context->getVaryString()
5657
];
5758

5859
$data = $this->identifierStoreReader->getPageTagsWithStoreCacheTags($data);

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,10 +2091,8 @@ public function createOrder()
20912091
private function beforeSubmit(Quote $quote)
20922092
{
20932093
$orderData = [];
2094-
if ($this->getSession()->getReordered() || $this->getSession()->getOrder()->getId()) {
2094+
if ($this->getSession()->getOrder()->getId()) {
20952095
$oldOrder = $this->getSession()->getOrder();
2096-
$oldOrder = $oldOrder->getId() ?
2097-
$oldOrder : $this->orderRepositoryInterface->get($this->getSession()->getReordered());
20982096
$originalId = $oldOrder->getOriginalIncrementId();
20992097
if (!$originalId) {
21002098
$originalId = $oldOrder->getIncrementId();
@@ -2121,16 +2119,12 @@ private function beforeSubmit(Quote $quote)
21212119
*/
21222120
private function afterSubmit(Order $order)
21232121
{
2124-
if ($this->getSession()->getReordered() || $this->getSession()->getOrder()->getId()) {
2122+
if ($this->getSession()->getOrder()->getId()) {
21252123
$oldOrder = $this->getSession()->getOrder();
2126-
$oldOrder = $oldOrder->getId() ?
2127-
$oldOrder : $this->orderRepositoryInterface->get($this->getSession()->getReordered());
21282124
$oldOrder->setRelationChildId($order->getId());
21292125
$oldOrder->setRelationChildRealId($order->getIncrementId());
21302126
$oldOrder->save();
2131-
if ($this->getSession()->getOrder()->getId()) {
2132-
$this->orderManagement->cancel($oldOrder->getEntityId());
2133-
}
2127+
$this->orderManagement->cancel($oldOrder->getEntityId());
21342128
$order->save();
21352129
}
21362130
}

app/code/Magento/Sales/Test/Unit/Model/AdminOrder/CreateTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ protected function setUp(): void
164164

165165
$this->orderMock = $this->getMockBuilder(Order::class)
166166
->disableOriginalConstructor()
167-
->addMethods(['setReordered', 'getReordered'])
168167
->onlyMethods(
169168
[
170169
'getEntityId',
@@ -505,8 +504,6 @@ public function testInitFromOrder()
505504

506505
$this->orderMock->method('getItemsCollection')
507506
->willReturn($itemCollectionMock);
508-
$this->orderMock->method('getReordered')
509-
->willReturn(false);
510507
$this->orderMock->method('getShippingAddress')
511508
->willReturn($address);
512509
$this->orderMock->method('getBillingAddress')

app/code/Magento/Ui/Component/Filters/Type/Input.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 2025 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Ui\Component\Filters\Type;
77

@@ -74,7 +74,7 @@ protected function applyFilter(): void
7474
$valueExpression = $filterConfig['valueExpression'] ?? null;
7575
}
7676
if ($conditionType === self::CONDITION_LIKE) {
77-
$value = str_replace(['%', '_'], ['\%', '\_'], $value);
77+
$value = str_replace(['\\', '%', '_'], ['\\\\', '\%', '\_'], $value);
7878
$valueExpression = $valueExpression ?? '%%%s%%';
7979
}
8080
if ($valueExpression) {

app/code/Magento/Ui/Test/Unit/Component/Filters/Type/InputTest.php

Lines changed: 15 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 2025 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -172,7 +172,10 @@ public function testPrepare(array $data, array $filterData, ?array $expectedCond
172172
}
173173

174174
/**
175+
* SuppressWarnings was added due to the big size of data provider
176+
*
175177
* @return array
178+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
176179
*/
177180
public static function getPrepareDataProvider(): array
178181
{
@@ -221,6 +224,16 @@ public static function getPrepareDataProvider(): array
221224
'setValue' => '%\%%',
222225
],
223226
],
227+
[
228+
[
229+
'name' => 'test_date',
230+
],
231+
['test_date' => 'some\\value'],
232+
[
233+
'setConditionType' => 'like',
234+
'setValue' => '%some\\\\value%',
235+
],
236+
],
224237
[
225238
[
226239
'name' => 'text_attr',
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All rights reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\PageCache\Model\App\Request\Http;
9+
10+
use Magento\Framework\ObjectManagerInterface;
11+
use Magento\TestFramework\Fixture\Config as ConfigFixture;
12+
use Magento\TestFramework\Fixture\DataFixture;
13+
use Magento\TestFramework\Fixture\DataFixtureStorage;
14+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
15+
use Magento\TestFramework\Helper\Bootstrap;
16+
use Magento\Customer\Model\Session;
17+
use Magento\Framework\App\Http\Context;
18+
use Magento\Framework\Stdlib\CookieManagerInterface;
19+
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
20+
use Magento\Customer\Test\Fixture\Customer as CustomerFixture;
21+
use PHPUnit\Framework\TestCase;
22+
23+
/**
24+
* Integration test for \Magento\PageCache\Model\App\Request\Http\IdentifierForSave
25+
*
26+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
27+
*/
28+
class IdentifierForSaveTest extends TestCase
29+
{
30+
/**
31+
* @var ObjectManagerInterface
32+
*/
33+
private $objectManager;
34+
35+
/**
36+
* @var IdentifierForSave
37+
*/
38+
private $identifierForSave;
39+
40+
/**
41+
* @var DataFixtureStorage
42+
*/
43+
private $fixtures;
44+
45+
/**
46+
* @var Context
47+
*/
48+
private $context;
49+
50+
/**
51+
* @var CookieManagerInterface
52+
*/
53+
private $cookieManager;
54+
55+
/**
56+
* @var CookieMetadataFactory
57+
*/
58+
private $cookieMetadataFactory;
59+
60+
/**
61+
* @var string
62+
*/
63+
private const COOKIE_VARY_STRING = 'X-Magento-Vary';
64+
65+
protected function setUp(): void
66+
{
67+
$this->objectManager = Bootstrap::getObjectManager();
68+
$this->identifierForSave = $this->objectManager->get(IdentifierForSave::class);
69+
$this->fixtures = $this->objectManager->get(DataFixtureStorageManager::class)->getStorage();
70+
$this->context = $this->objectManager->get(Context::class);
71+
$this->cookieManager = $this->objectManager->get(CookieManagerInterface::class);
72+
$this->cookieMetadataFactory = $this->objectManager->get(CookieMetadataFactory::class);
73+
}
74+
75+
/**
76+
* Test that cache identifier properly handles logged-in customers
77+
*/
78+
#[
79+
ConfigFixture('system/full_page_cache/caching_application', '1', 'store'),
80+
ConfigFixture('system/full_page_cache/enabled', '1', 'store'),
81+
DataFixture(CustomerFixture::class, as: 'customer')
82+
]
83+
public function testAfterGetValueWithLoggedInCustomer()
84+
{
85+
// Get customer and login
86+
$customer = $this->fixtures->get('customer');
87+
$customerSession = $this->objectManager->get(Session::class);
88+
$customerSession->loginById($customer->getId());
89+
90+
// Get cache identifiers
91+
$result = $this->identifierForSave->getValue();
92+
93+
// Verify that both cache keys are not empty and contain customer context
94+
$this->assertNotEmpty($result, 'Cache identifier for save should not be empty for logged-in user');
95+
96+
// Test scenario: Simulate context vary string being empty but cookie vary string present
97+
// Get the current vary string from context
98+
$originalVaryString = $this->context->getVaryString();
99+
$this->assertNotEmpty($originalVaryString, 'Context vary string should not be empty for logged-in user');
100+
101+
// Set the vary cookie to simulate a previous request
102+
$cookieMetadata = $this->cookieMetadataFactory->createSensitiveCookieMetadata()->setPath('/');
103+
$this->cookieManager->setSensitiveCookie(
104+
self::COOKIE_VARY_STRING,
105+
$originalVaryString,
106+
$cookieMetadata
107+
);
108+
109+
// Clear the context vary string to simulate depersonalization
110+
$this->context->_resetState();
111+
112+
// Verify context vary string is now empty
113+
$this->assertEmpty($this->context->getVaryString(), 'Context vary string should be empty after reset');
114+
115+
// Get cache identifiers again - should still work due to cookie fallback
116+
$resultWithEmptyContext = $this->identifierForSave->getValue();
117+
118+
// Both should still generate valid cache keys due to cookie fallback
119+
$this->assertNotEmpty(
120+
$resultWithEmptyContext,
121+
'Cache identifier for save should work with empty context due to cookie fallback'
122+
);
123+
124+
// Both cache key should be same even after context vary string is empty because it use cookie vary string
125+
$this->assertEquals($result, $resultWithEmptyContext);
126+
127+
// Clean up
128+
$this->cookieManager->deleteCookie(self::COOKIE_VARY_STRING, $cookieMetadata);
129+
}
130+
}

dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public function testInitFromOrderAndCreateOrderFromQuoteWithAdditionalOptions()
9898
$order->loadByIncrementId('100000001');
9999

100100
/** @var $orderCreate \Magento\Sales\Model\AdminOrder\Create */
101-
$order->setReordered(true);
102101
$orderCreate = $this->model->initFromOrder($order);
103102

104103
$quoteItems = $orderCreate->getQuote()->getItemsCollection();

lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/SchemaBuilder.php

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

@@ -16,6 +16,9 @@
1616
use Magento\Framework\Setup\Declaration\Schema\Sharding;
1717
use Magento\Framework\Config\FileResolverByModule;
1818
use Magento\Framework\Setup\Declaration\Schema\Declaration\ReaderComposite;
19+
use Psr\Log\LoggerInterface;
20+
use Magento\Framework\Exception\LocalizedException;
21+
use Magento\Framework\App\ObjectManager;
1922

2023
/**
2124
* This type of builder is responsible for converting ENTIRE data, that comes from db
@@ -27,6 +30,7 @@
2730
*
2831
* @see Schema
2932
* @inheritdoc
33+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3034
*/
3135
class SchemaBuilder
3236
{
@@ -55,30 +59,39 @@ class SchemaBuilder
5559
*/
5660
private $readerComposite;
5761

62+
/**
63+
* @var LoggerInterface
64+
*/
65+
private $logger;
66+
5867
/**
5968
* Constructor.
6069
*
6170
* @param ElementFactory $elementFactory
6271
* @param DbSchemaReaderInterface $dbSchemaReader
6372
* @param Sharding $sharding
6473
* @param ReaderComposite $readerComposite
74+
* @param LoggerInterface $logger
6575
*/
6676
public function __construct(
6777
ElementFactory $elementFactory,
6878
DbSchemaReaderInterface $dbSchemaReader,
6979
Sharding $sharding,
70-
ReaderComposite $readerComposite
80+
ReaderComposite $readerComposite,
81+
?LoggerInterface $logger = null
7182
) {
7283
$this->elementFactory = $elementFactory;
7384
$this->dbSchemaReader = $dbSchemaReader;
7485
$this->sharding = $sharding;
7586
$this->readerComposite = $readerComposite;
87+
$this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class);
7688
}
7789

7890
/**
7991
* @inheritdoc
8092
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
8193
* @SuppressWarnings(PHPMD.NPathComplexity)
94+
* @throws LocalizedException
8295
*/
8396
public function build(Schema $schema)
8497
{
@@ -88,8 +101,22 @@ public function build(Schema $schema)
88101
foreach ($data['table'] as $keyTable => $tableColumns) {
89102
$tableColumns['column'] ??= [];
90103
foreach ($tableColumns['column'] as $keyColumn => $columnData) {
91-
if ($columnData['type'] == 'json') {
92-
$tablesWithJsonTypeField[$keyTable] = $keyColumn;
104+
try {
105+
if ($columnData['type'] == 'json') {
106+
$tablesWithJsonTypeField[$keyTable] = $keyColumn;
107+
}
108+
} catch (\Throwable $e) {
109+
// Create a new exception with extended context message
110+
$errorMessage = sprintf(
111+
"%s\nError processing table %s column %s",
112+
$e->getMessage(),
113+
$keyTable,
114+
$keyColumn
115+
);
116+
$this->logger->error($errorMessage);
117+
// Throw a new exception with the extended message
118+
// This preserves the original error but adds our context
119+
throw new LocalizedException(new Phrase($errorMessage));
93120
}
94121
}
95122
}

0 commit comments

Comments
 (0)