Skip to content

Commit 13f64b5

Browse files
Merge remote-tracking branch 'remotes/github/2.3-develop' into MC-15140-V2
2 parents c560c66 + 39cfaa7 commit 13f64b5

File tree

62 files changed

+1217
-579
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1217
-579
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

app/code/Magento/AdminNotification/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,25 @@ The Magento_AdminNotification module provides the ability to alert administrator
44

55
## Installation details
66

7+
The Magento_AdminNotification module creates the following tables in the database:
8+
- `adminnotification_inbox`
9+
- `admin_system_messages`
10+
711
Before disabling or uninstalling this module, note that the Magento_Indexer module depends on this module.
812

913
For information about module installation in Magento 2, see [Enable or disable modules](https://devdocs.magento.com/guides/v2.3/install-gde/install/cli/install-cli-subcommands-enable.html).
1014

15+
## Extensibility
16+
17+
Extension developers can interact with the Magento_AdminNotification module. For more information about the Magento extension mechanism, see [Magento plug-ins](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html).
18+
19+
[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_AdminNotification module.
20+
1121
### Events
1222

1323
This module observes the following events:
1424

15-
- `controller_action_predispatch` event in `Magento\AdminNotification\Observer\PredispatchAdminActionControllerObserver`
25+
- `controller_action_predispatch` event in `Magento\AdminNotification\Observer\PredispatchAdminActionControllerObserver` file.
1626

1727
### Layouts
1828

app/code/Magento/AdvancedPricingImportExport/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@
22

33
The Magento_AdvancedPricingImportExport module handles the import and export of the advanced pricing.
44

5+
## Extensibility
6+
7+
Extension developers can interact with the Magento_AdvancedPricingImportExport module. For more information about the Magento extension mechanism, see [Magento plug-ins](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html).
8+
9+
[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_AdvancedPricingImportExport module.

app/code/Magento/Amqp/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
# Amqp
1+
# Magento_Amqp module
22

3-
**Amqp** provides functionality to publish/consume messages with Amqp.
3+
Magento_Amqp module provides functionality to publish/consume messages with the Advanced Message Queuing Protocol (AMQP).
4+
5+
## Extensibility
6+
7+
Extension developers can interact with the Magento_Amqp module. For more information about the Magento extension mechanism, see [Magento plug-ins](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html).
8+
9+
[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_Amqp module.

app/code/Magento/Backend/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@
536536
<label>Enable HTTP Strict Transport Security (HSTS)</label>
537537
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
538538
<backend_model>Magento\Config\Model\Config\Backend\Secure</backend_model>
539-
<comment><![CDATA[See <a href="https://www.owasp.org/index.php/HTTP_Strict_Transport_Security" target="_blank">HTTP Strict Transport Security</a> page for details.]]></comment>
539+
<comment><![CDATA[See <a href="https://cheatsheetseries.owasp.org/cheatsheets/HTTP_Strict_Transport_Security_Cheat_Sheet.html" target="_blank">HTTP Strict Transport Security</a> page for details.]]></comment>
540540
<depends>
541541
<field id="use_in_frontend">1</field>
542542
<field id="use_in_adminhtml">1</field>

app/code/Magento/Catalog/Model/Category.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,9 @@ public function move($parentId, $afterCategoryId)
448448
if ($this->flatState->isFlatEnabled()) {
449449
$flatIndexer = $this->indexerRegistry->get(Indexer\Category\Flat\State::INDEXER_ID);
450450
if (!$flatIndexer->isScheduled()) {
451-
$flatIndexer->reindexList([$this->getId(), $oldParentId, $parentId]);
451+
$sameLevelCategories = explode(',', $this->getParentCategory()->getChildren());
452+
$list = array_unique(array_merge($sameLevelCategories, [$this->getId(), $oldParentId, $parentId]));
453+
$flatIndexer->reindexList($list);
452454
}
453455
}
454456
$productIndexer = $this->indexerRegistry->get(Indexer\Category\Product::INDEXER_ID);

app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,15 @@ public function beforeSave($object)
121121

122122
if ($this->fileResidesOutsideCategoryDir($value)) {
123123
// use relative path for image attribute so we know it's outside of category dir when we fetch it
124+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
125+
$value[0]['url'] = parse_url($value[0]['url'], PHP_URL_PATH);
124126
$value[0]['name'] = $value[0]['url'];
125127
}
126128

127129
if ($imageName = $this->getUploadedImageName($value)) {
128-
$imageName = $this->checkUniqueImageName($imageName);
130+
if (!$this->fileResidesOutsideCategoryDir($value)) {
131+
$imageName = $this->checkUniqueImageName($imageName);
132+
}
129133
$object->setData($this->additionalData . $attributeName, $value);
130134
$object->setData($attributeName, $imageName);
131135
} elseif (!is_string($value)) {
@@ -182,7 +186,7 @@ private function fileResidesOutsideCategoryDir($value)
182186
return false;
183187
}
184188

185-
return strpos($fileUrl, $baseMediaDir) === 0;
189+
return strpos($fileUrl, $baseMediaDir) !== false;
186190
}
187191

188192
/**

app/code/Magento/Catalog/Model/Category/FileInfo.php

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Magento\Framework\Filesystem;
1111
use Magento\Framework\Filesystem\Directory\WriteInterface;
1212
use Magento\Framework\Filesystem\Directory\ReadInterface;
13+
use Magento\Framework\Exception\NoSuchEntityException;
14+
use Magento\Store\Model\StoreManagerInterface;
1315

1416
/**
1517
* Class FileInfo
@@ -48,16 +50,26 @@ class FileInfo
4850
*/
4951
private $pubDirectory;
5052

53+
/**
54+
* Store manager
55+
*
56+
* @var \Magento\Store\Model\StoreManagerInterface
57+
*/
58+
private $storeManager;
59+
5160
/**
5261
* @param Filesystem $filesystem
5362
* @param Mime $mime
63+
* @param StoreManagerInterface $storeManager
5464
*/
5565
public function __construct(
5666
Filesystem $filesystem,
57-
Mime $mime
67+
Mime $mime,
68+
StoreManagerInterface $storeManager
5869
) {
5970
$this->filesystem = $filesystem;
6071
$this->mime = $mime;
72+
$this->storeManager = $storeManager;
6173
}
6274

6375
/**
@@ -152,7 +164,8 @@ public function isExist($fileName)
152164
*/
153165
private function getFilePath($fileName)
154166
{
155-
$filePath = ltrim($fileName, '/');
167+
$filePath = $this->removeStorePath($fileName);
168+
$filePath = ltrim($filePath, '/');
156169

157170
$mediaDirectoryRelativeSubpath = $this->getMediaDirectoryPathRelativeToBaseDirectoryPath($filePath);
158171
$isFileNameBeginsWithMediaDirectoryPath = $this->isBeginsWithMediaDirectoryPath($fileName);
@@ -177,14 +190,39 @@ private function getFilePath($fileName)
177190
*/
178191
public function isBeginsWithMediaDirectoryPath($fileName)
179192
{
180-
$filePath = ltrim($fileName, '/');
193+
$filePath = $this->removeStorePath($fileName);
194+
$filePath = ltrim($filePath, '/');
181195

182196
$mediaDirectoryRelativeSubpath = $this->getMediaDirectoryPathRelativeToBaseDirectoryPath($filePath);
183197
$isFileNameBeginsWithMediaDirectoryPath = strpos($filePath, (string) $mediaDirectoryRelativeSubpath) === 0;
184198

185199
return $isFileNameBeginsWithMediaDirectoryPath;
186200
}
187201

202+
/**
203+
* Clean store path in case if it's exists
204+
*
205+
* @param string $path
206+
* @return string
207+
*/
208+
private function removeStorePath(string $path): string
209+
{
210+
$result = $path;
211+
try {
212+
$storeUrl = $this->storeManager->getStore()->getBaseUrl();
213+
} catch (NoSuchEntityException $e) {
214+
return $result;
215+
}
216+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
217+
$path = parse_url($path, PHP_URL_PATH);
218+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
219+
$storePath = parse_url($storeUrl, PHP_URL_PATH);
220+
$storePath = rtrim($storePath, '/');
221+
222+
$result = preg_replace('/^' . preg_quote($storePath, '/') . '/', '', $path);
223+
return $result;
224+
}
225+
188226
/**
189227
* Get media directory subpath relative to base directory path
190228
*

app/code/Magento/Catalog/Model/Category/Tree.php

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@
55
*/
66
namespace Magento\Catalog\Model\Category;
77

8+
use Magento\Catalog\Api\Data\CategoryTreeInterface;
9+
use Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory;
10+
use Magento\Catalog\Model\Category;
11+
use Magento\Catalog\Model\ResourceModel\Category\Collection;
12+
use Magento\Catalog\Model\ResourceModel\Category\TreeFactory;
13+
use Magento\Framework\App\ObjectManager;
814
use Magento\Framework\Data\Tree\Node;
15+
use Magento\Framework\Exception\LocalizedException;
16+
use Magento\Framework\Exception\NoSuchEntityException;
17+
use Magento\Store\Model\StoreManagerInterface;
918

1019
/**
1120
* Retrieve category data represented in tree structure
@@ -18,54 +27,54 @@ class Tree
1827
protected $categoryTree;
1928

2029
/**
21-
* @var \Magento\Store\Model\StoreManagerInterface
30+
* @var StoreManagerInterface
2231
*/
2332
protected $storeManager;
2433

2534
/**
26-
* @var \Magento\Catalog\Model\ResourceModel\Category\Collection
35+
* @var Collection
2736
*/
2837
protected $categoryCollection;
2938

3039
/**
31-
* @var \Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory
40+
* @var CategoryTreeInterfaceFactory
3241
*/
3342
protected $treeFactory;
3443

3544
/**
36-
* @var \Magento\Catalog\Model\ResourceModel\Category\TreeFactory
45+
* @var TreeFactory
3746
*/
3847
private $treeResourceFactory;
3948

4049
/**
4150
* @param \Magento\Catalog\Model\ResourceModel\Category\Tree $categoryTree
42-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
43-
* @param \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection
44-
* @param \Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory $treeFactory
45-
* @param \Magento\Catalog\Model\ResourceModel\Category\TreeFactory|null $treeResourceFactory
51+
* @param StoreManagerInterface $storeManager
52+
* @param Collection $categoryCollection
53+
* @param CategoryTreeInterfaceFactory $treeFactory
54+
* @param TreeFactory|null $treeResourceFactory
4655
*/
4756
public function __construct(
4857
\Magento\Catalog\Model\ResourceModel\Category\Tree $categoryTree,
49-
\Magento\Store\Model\StoreManagerInterface $storeManager,
50-
\Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection,
51-
\Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory $treeFactory,
52-
\Magento\Catalog\Model\ResourceModel\Category\TreeFactory $treeResourceFactory = null
58+
StoreManagerInterface $storeManager,
59+
Collection $categoryCollection,
60+
CategoryTreeInterfaceFactory $treeFactory,
61+
TreeFactory $treeResourceFactory = null
5362
) {
5463
$this->categoryTree = $categoryTree;
5564
$this->storeManager = $storeManager;
5665
$this->categoryCollection = $categoryCollection;
5766
$this->treeFactory = $treeFactory;
58-
$this->treeResourceFactory = $treeResourceFactory ?? \Magento\Framework\App\ObjectManager::getInstance()
59-
->get(\Magento\Catalog\Model\ResourceModel\Category\TreeFactory::class);
67+
$this->treeResourceFactory = $treeResourceFactory ?? ObjectManager::getInstance()
68+
->get(TreeFactory::class);
6069
}
6170

6271
/**
6372
* Get root node by category.
6473
*
65-
* @param \Magento\Catalog\Model\Category|null $category
74+
* @param Category|null $category
6675
* @return Node|null
67-
* @throws \Magento\Framework\Exception\LocalizedException
68-
* @throws \Magento\Framework\Exception\NoSuchEntityException
76+
* @throws LocalizedException
77+
* @throws NoSuchEntityException
6978
*/
7079
public function getRootNode($category = null)
7180
{
@@ -86,28 +95,28 @@ public function getRootNode($category = null)
8695
/**
8796
* Get node by category.
8897
*
89-
* @param \Magento\Catalog\Model\Category $category
98+
* @param Category $category
9099
* @return Node
91-
* @throws \Magento\Framework\Exception\LocalizedException
92-
* @throws \Magento\Framework\Exception\NoSuchEntityException
100+
* @throws LocalizedException
101+
* @throws NoSuchEntityException
93102
*/
94-
protected function getNode(\Magento\Catalog\Model\Category $category)
103+
protected function getNode(Category $category)
95104
{
96105
$nodeId = $category->getId();
97106
$categoryTree = $this->treeResourceFactory->create();
98107
$node = $categoryTree->loadNode($nodeId);
99108
$node->loadChildren();
100109
$this->prepareCollection();
101-
$this->categoryTree->addCollectionData($this->categoryCollection);
110+
$categoryTree->addCollectionData($this->categoryCollection);
102111
return $node;
103112
}
104113

105114
/**
106115
* Prepare category collection.
107116
*
108117
* @return void
109-
* @throws \Magento\Framework\Exception\LocalizedException
110-
* @throws \Magento\Framework\Exception\NoSuchEntityException
118+
* @throws LocalizedException
119+
* @throws NoSuchEntityException
111120
*/
112121
protected function prepareCollection()
113122
{
@@ -128,16 +137,16 @@ protected function prepareCollection()
128137
/**
129138
* Get tree by node.
130139
*
131-
* @param \Magento\Framework\Data\Tree\Node $node
140+
* @param Node $node
132141
* @param int $depth
133142
* @param int $currentLevel
134-
* @return \Magento\Catalog\Api\Data\CategoryTreeInterface
143+
* @return CategoryTreeInterface
135144
*/
136145
public function getTree($node, $depth = null, $currentLevel = 0)
137146
{
138-
/** @var \Magento\Catalog\Api\Data\CategoryTreeInterface[] $children */
147+
/** @var CategoryTreeInterface[] $children */
139148
$children = $this->getChildren($node, $depth, $currentLevel);
140-
/** @var \Magento\Catalog\Api\Data\CategoryTreeInterface $tree */
149+
/** @var CategoryTreeInterface $tree */
141150
$tree = $this->treeFactory->create();
142151
$tree->setId($node->getId())
143152
->setParentId($node->getParentId())
@@ -153,10 +162,10 @@ public function getTree($node, $depth = null, $currentLevel = 0)
153162
/**
154163
* Get node children.
155164
*
156-
* @param \Magento\Framework\Data\Tree\Node $node
165+
* @param Node $node
157166
* @param int $depth
158167
* @param int $currentLevel
159-
* @return \Magento\Catalog\Api\Data\CategoryTreeInterface[]|[]
168+
* @return CategoryTreeInterface[]|[]
160169
*/
161170
protected function getChildren($node, $depth, $currentLevel)
162171
{

0 commit comments

Comments
 (0)