Skip to content

Commit 79ac476

Browse files
Merge branch '2.4-develop' into fix-for-issue-39861
2 parents cbfe66a + 26cbb2b commit 79ac476

File tree

11 files changed

+246
-36
lines changed

11 files changed

+246
-36
lines changed

app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Index.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\AdminNotification\Controller\Adminhtml\Notification;
77

88
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
9+
use Magento\Framework\View\Result\Page;
910

1011
class Index extends \Magento\AdminNotification\Controller\Adminhtml\Notification implements HttpGetActionInterface
1112
{
@@ -14,14 +15,14 @@ class Index extends \Magento\AdminNotification\Controller\Adminhtml\Notification
1415
*/
1516
public function execute()
1617
{
17-
$this->_view->loadLayout();
18-
$this->_setActiveMenu(
19-
'Magento_AdminNotification::system_adminnotification'
20-
)->_addBreadcrumb(
18+
/** @var Page $resultPage */
19+
$resultPage = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_PAGE);
20+
$resultPage->setActiveMenu('Magento_AdminNotification::system_adminnotification');
21+
$resultPage->addBreadcrumb(
2122
__('Messages Inbox'),
2223
__('Messages Inbox')
2324
);
24-
$this->_view->getPage()->getConfig()->getTitle()->prepend(__('Notifications'));
25-
return $this->_view->renderLayout();
25+
$resultPage->getConfig()->getTitle()->prepend(__('Notifications'));
26+
return $resultPage;
2627
}
2728
}

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
/**

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: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe.
4+
* All rights reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Framework\Console;
9+
10+
use Magento\Framework\App\Filesystem\DirectoryList;
11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\Framework\App\State;
13+
use PHPUnit\Framework\TestCase;
14+
15+
/**
16+
* Integration test for CLI --magento-init-params functionality
17+
*/
18+
class CliStateTest extends TestCase
19+
{
20+
/**
21+
* @var mixed|null
22+
*/
23+
private $originalArgv;
24+
25+
/**
26+
* @inheritDoc
27+
*/
28+
protected function setUp(): void
29+
{
30+
parent::setUp();
31+
32+
// Store original argv
33+
$this->originalArgv = $_SERVER['argv'] ?? null;
34+
}
35+
36+
/**
37+
* @inheritDoc
38+
*/
39+
protected function tearDown(): void
40+
{
41+
// Restore original argv
42+
if ($this->originalArgv !== null) {
43+
$_SERVER['argv'] = $this->originalArgv;
44+
$this->originalArgv = null;
45+
} else {
46+
unset($_SERVER['argv']);
47+
}
48+
49+
parent::tearDown();
50+
}
51+
52+
/**
53+
* Test that State::getMode() when --magento-init-params sets MAGE_MODE
54+
*
55+
* @param string $mode
56+
* @return void
57+
* @dataProvider modeDataProvider
58+
*/
59+
public function testStateGetModeWithMagentoInitParams(string $mode)
60+
{
61+
// Set up test argv with --magento-init-params
62+
$testArgv = [
63+
'php',
64+
'bin/magento',
65+
'setup:upgrade',
66+
'--magento-init-params=MAGE_MODE=' . $mode,
67+
];
68+
$_SERVER['argv'] = $testArgv;
69+
70+
// Get the State object from the ObjectManager
71+
$state = $this->getObjectManager()->get(State::class);
72+
73+
// Assert that State::getMode() returns the correct mode
74+
$this->assertEquals(
75+
$mode,
76+
$state->getMode(),
77+
'State::getMode() should return "' . $mode . '" when MAGE_MODE set via --magento-init-params'
78+
);
79+
}
80+
81+
/**
82+
* Test that multiple --magento-init-params are processed correctly
83+
*
84+
* @return void
85+
*/
86+
public function testMultipleMagentoInitParams()
87+
{
88+
$mode = 'developer';
89+
$cachePath = '/var/tmp/cache';
90+
$varPath = '/var/tmp/var';
91+
92+
// Set up test argv with multiple --magento-init-params
93+
$testArgv = [
94+
'php',
95+
'bin/magento',
96+
'setup:upgrade',
97+
'--magento-init-params=MAGE_MODE=' .$mode .
98+
'&MAGE_DIRS[cache][path]=' . $cachePath . '&MAGE_DIRS[var][path]=' . $varPath,
99+
];
100+
$_SERVER['argv'] = $testArgv;
101+
102+
// Get the ObjectManager
103+
$objectManager = $this->getObjectManager();
104+
105+
// Get the State object from the ObjectManager
106+
$state = $objectManager->get(State::class);
107+
108+
// Assert that State::getMode() returns the correct mode
109+
$this->assertEquals(
110+
$mode,
111+
$state->getMode(),
112+
'State::getMode() should return "' . $mode . '" when MAGE_MODE set via --magento-init-params'
113+
);
114+
115+
// Get the DirectoryList to verify filesystem paths were set
116+
$directoryList = $objectManager->get(DirectoryList::class);
117+
118+
// Assert that custom filesystem paths were applied
119+
$this->assertEquals(
120+
$cachePath,
121+
$directoryList->getPath(DirectoryList::CACHE),
122+
'Custom cache directory path should be set via --magento-init-params'
123+
);
124+
125+
$this->assertEquals(
126+
$varPath,
127+
$directoryList->getPath(DirectoryList::VAR_DIR),
128+
'Custom var directory path should be set via --magento-init-params'
129+
);
130+
}
131+
132+
/**
133+
* Returns magento mode for cli command
134+
*
135+
* @return string[]
136+
*/
137+
public static function modeDataProvider(): array
138+
{
139+
return [
140+
['production'],
141+
['developer'],
142+
['default']
143+
];
144+
}
145+
146+
/**
147+
* Get the ObjectManager from the Cli instance using reflection
148+
*
149+
* @return ObjectManager
150+
*/
151+
private function getObjectManager()
152+
{
153+
// Create a new Cli instance
154+
$cli = new Cli('Magento CLI');
155+
156+
// Get the ObjectManager from the Cli instance using reflection
157+
$reflection = new \ReflectionClass($cli);
158+
$objectManagerProperty = $reflection->getProperty('objectManager');
159+
$objectManagerProperty->setAccessible(true);
160+
return $objectManagerProperty->getValue($cli);
161+
}
162+
}

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/Console/Cli.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\App\DeploymentConfig;
1313
use Magento\Framework\App\Filesystem\DirectoryList;
1414
use Magento\Framework\App\ProductMetadata;
15+
use Magento\Framework\App\State as AppState;
1516
use Magento\Framework\Composer\ComposerJsonFinder;
1617
use Magento\Framework\Config\ConfigOptionsListConstants;
1718
use Magento\Framework\Console\CommandLoader\Aggregate;
@@ -177,10 +178,15 @@ private function initObjectManager()
177178
$params = (new ComplexParameter(self::INPUT_KEY_BOOTSTRAP))->mergeFromArgv($_SERVER, $_SERVER);
178179
$params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null;
179180
$requestParams = $this->serviceManager->get('magento-init-params');
180-
$appBootstrapKey = Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS;
181+
$appBootstrapKeys = [
182+
Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS,
183+
AppState::PARAM_MODE,
184+
];
181185

182-
if (isset($requestParams[$appBootstrapKey]) && !isset($params[$appBootstrapKey])) {
183-
$params[$appBootstrapKey] = $requestParams[$appBootstrapKey];
186+
foreach ($appBootstrapKeys as $appBootstrapKey) {
187+
if (isset($requestParams[$appBootstrapKey]) && !isset($params[$appBootstrapKey])) {
188+
$params[$appBootstrapKey] = $requestParams[$appBootstrapKey];
189+
}
184190
}
185191

186192
$this->objectManager = Bootstrap::create(BP, $params)->getObjectManager();

0 commit comments

Comments
 (0)