Skip to content

Commit 5940a90

Browse files
committed
Merge remote-tracking branch 'origin/AC-3160-fix-deprecation-issues-part10' into delivery-bunch-w22
2 parents 2f5f1e7 + 7160ad6 commit 5940a90

File tree

5 files changed

+20
-26
lines changed

5 files changed

+20
-26
lines changed

dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/Category/Plugin/StorageTest.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Framework\App\ResourceConnection;
1616
use Magento\Framework\Exception\NoSuchEntityException;
1717
use Magento\Framework\Filesystem;
18+
use Magento\Framework\Filesystem\Directory\Write;
1819
use Magento\Framework\Filesystem\Driver\File;
1920
use Magento\Framework\ObjectManagerInterface;
2021
use Magento\ImportExport\Model\Import;
@@ -67,6 +68,9 @@ class StorageTest extends TestCase
6768
/** @var Data */
6869
private $importDataResource;
6970

71+
/** @var Write */
72+
private $mediaDirectory;
73+
7074
/**
7175
* @inheritdoc
7276
*/
@@ -85,6 +89,7 @@ protected function setUp(): void
8589
$this->importDataResource = $this->objectManager->get(Data::class);
8690
$this->appParams = Bootstrap::getInstance()->getBootstrap()->getApplication()
8791
->getInitParams()[AppBootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS];
92+
$this->mediaDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::MEDIA);
8893
}
8994

9095
/**
@@ -182,17 +187,14 @@ private function prepareFile(string $fileName): Csv
182187
*/
183188
private function updateUploader(): void
184189
{
190+
$mediaDir = !$this->mediaDirectory->getDriver() instanceof File ?
191+
DirectoryList::MEDIA : $this->appParams[DirectoryList::MEDIA][DirectoryList::PATH];
192+
$destDir = $mediaDir . DIRECTORY_SEPARATOR . $this->mediaConfig->getBaseMediaPath();
193+
$tmpDir = $mediaDir . DIRECTORY_SEPARATOR . 'import';
194+
$this->mediaDirectory->create($this->mediaConfig->getBaseMediaPath());
195+
$this->mediaDirectory->create('import');
196+
$this->import->setParameters([Import::FIELD_NAME_IMG_FILE_DIR => $tmpDir]);
185197
$uploader = $this->import->getUploader();
186-
$rootDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::ROOT);
187-
$destDir = $rootDirectory->getRelativePath(
188-
$this->appParams[DirectoryList::MEDIA][DirectoryList::PATH]
189-
. DIRECTORY_SEPARATOR . $this->mediaConfig->getBaseMediaPath()
190-
);
191-
$tmpDir = $rootDirectory->getRelativePath(
192-
$this->appParams[DirectoryList::MEDIA][DirectoryList::PATH]
193-
);
194-
$rootDirectory->create($destDir);
195-
$rootDirectory->create($tmpDir);
196198
$uploader->setDestDir($destDir);
197199
$uploader->setTmpDir($tmpDir);
198200
}

lib/internal/Magento/Framework/View/Element/Template/File/Validator.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@
99
use Magento\Framework\Component\ComponentRegistrar;
1010
use \Magento\Framework\Filesystem\Driver\File as FileDriver;
1111

12-
/**
13-
* Class Validator
14-
*/
1512
class Validator
1613
{
1714
/**
1815
* Config path to 'Allow Symlinks' template settings
1916
*/
20-
const XML_PATH_TEMPLATE_ALLOW_SYMLINK = 'dev/template/allow_symlink';
17+
public const XML_PATH_TEMPLATE_ALLOW_SYMLINK = 'dev/template/allow_symlink';
2118

2219
/**
2320
* Template files map
@@ -140,7 +137,7 @@ protected function isPathInDirectories($path, $directories)
140137
}
141138
$realPath = $this->fileDriver->getRealPath($path);
142139
foreach ($directories as $directory) {
143-
if (0 === strpos($realPath, $directory)) {
140+
if ($directory !== null && 0 === strpos($realPath, $directory)) {
144141
return true;
145142
}
146143
}

lib/internal/Magento/Framework/View/Element/UiComponent/Config/DomMerger.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@
88
use Magento\Framework\Config\Dom;
99
use Magento\Framework\Config\ValidationStateInterface;
1010

11-
/**
12-
* Class DomMerger
13-
*/
1411
class DomMerger implements DomMergerInterface
1512
{
1613
/**
1714
* Format of items in errors array to be used by default. Available placeholders - fields of \LibXMLError.
1815
*/
19-
const ERROR_FORMAT_DEFAULT = "Message: %message%\nLine: %line%\n";
16+
public const ERROR_FORMAT_DEFAULT = "Message: %message%\nLine: %line%\n";
2017

2118
/**
2219
* @var \Magento\Framework\Config\ValidationStateInterface
@@ -45,15 +42,11 @@ class DomMerger implements DomMergerInterface
4542
protected $idAttributes = [];
4643

4744
/**
48-
* Context XPath
49-
*
5045
* @var array
5146
*/
5247
protected $contextXPath = [];
5348

5449
/**
55-
* Is merge simple XML Element
56-
*
5750
* @var bool
5851
*/
5952
protected $isMergeSimpleXMLElement;
@@ -152,7 +145,7 @@ protected function mergeAttributes(\DOMElement $baseNode, \DOMNode $mergeNode)
152145
protected function createXPath(\DOMNode $node)
153146
{
154147
$parentXPath = '';
155-
$currentXPath = $node->getNodePath();
148+
$currentXPath = $node->getNodePath() ?? '';
156149
if ($node->parentNode !== null && !$node->isSameNode($node->parentNode)) {
157150
$parentXPath = $this->createXPath($node->parentNode);
158151
$pathParts = explode('/', $currentXPath);
@@ -187,6 +180,7 @@ protected function createXPath(\DOMNode $node)
187180
*
188181
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
189182
* @SuppressWarnings(PHPMD.NPathComplexity)
183+
* phpcs:disable Generic.Metrics.NestingLevel
190184
*/
191185
protected function nestedMerge(\DOMXPath $rootDomXPath, \DOMNodeList $insertedNodes, \DOMNode $contextNode)
192186
{
@@ -236,6 +230,7 @@ protected function nestedMerge(\DOMXPath $rootDomXPath, \DOMNodeList $insertedNo
236230
}
237231
}
238232
}
233+
// phpcs:enable Generic.Metrics.NestingLevel
239234

240235
/**
241236
* Append child node

lib/internal/Magento/Framework/View/FileSystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function getEmailTemplateFileName($fileId, array $params, $module)
171171
*/
172172
public static function normalizePath($path)
173173
{
174-
$parts = explode('/', $path);
174+
$parts = $path !== null ? explode('/', $path) : [];
175175
$result = [];
176176

177177
foreach ($parts as $part) {

lib/internal/Magento/Framework/View/Layout/Data/Structure.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function createStructuralElement($name, $type, $class)
7777
*/
7878
protected function _generateAnonymousName($class)
7979
{
80-
$position = strpos($class, '\\Block\\');
80+
$position = $class !== null ? strpos($class, '\\Block\\') : '';
8181
$key = $position !== false ? substr($class, $position + 7) : $class;
8282
$key = strtolower(trim($key, '_'));
8383

0 commit comments

Comments
 (0)