Skip to content

Commit 389bae2

Browse files
author
Alex Paliarush
committed
MAGETWO-83266: Prohibit global variables and output buffering with Code Sniffer
- Blacklisted existing issues in the core, created follow up ticket to fix those
1 parent 189f40e commit 389bae2

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,12 +2001,10 @@ protected function _getUploader()
20012001
$dirConfig = DirectoryList::getDefaultConfig();
20022002
$dirAddon = $dirConfig[DirectoryList::MEDIA][DirectoryList::PATH];
20032003

2004-
$DS = DIRECTORY_SEPARATOR;
2005-
20062004
if (!empty($this->_parameters[Import::FIELD_NAME_IMG_FILE_DIR])) {
20072005
$tmpPath = $this->_parameters[Import::FIELD_NAME_IMG_FILE_DIR];
20082006
} else {
2009-
$tmpPath = $dirAddon . $DS . $this->_mediaDirectory->getRelativePath('import');
2007+
$tmpPath = $dirAddon . '/' . $this->_mediaDirectory->getRelativePath('import');
20102008
}
20112009

20122010
if (!$this->_fileUploader->setTmpDir($tmpPath)) {
@@ -2015,7 +2013,7 @@ protected function _getUploader()
20152013
);
20162014
}
20172015
$destinationDir = "catalog/product";
2018-
$destinationPath = $dirAddon . $DS . $this->_mediaDirectory->getRelativePath($destinationDir);
2016+
$destinationPath = $dirAddon . '/' . $this->_mediaDirectory->getRelativePath($destinationDir);
20192017

20202018
$this->_mediaDirectory->create($destinationPath);
20212019
if (!$this->_fileUploader->setDestDir($destinationPath)) {

app/code/Magento/DownloadableImportExport/Helper/Uploader.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,10 @@ public function getUploader($type, $parameters)
7777
$dirConfig = DirectoryList::getDefaultConfig();
7878
$dirAddon = $dirConfig[DirectoryList::MEDIA][DirectoryList::PATH];
7979

80-
$DS = DIRECTORY_SEPARATOR;
81-
8280
if (!empty($parameters[\Magento\ImportExport\Model\Import::FIELD_NAME_IMG_FILE_DIR])) {
8381
$tmpPath = $parameters[\Magento\ImportExport\Model\Import::FIELD_NAME_IMG_FILE_DIR];
8482
} else {
85-
$tmpPath = $dirAddon . $DS . $this->mediaDirectory->getRelativePath('import');
83+
$tmpPath = $dirAddon . '/' . $this->mediaDirectory->getRelativePath('import');
8684
}
8785

8886
if (!$this->fileUploader->setTmpDir($tmpPath)) {
@@ -91,7 +89,7 @@ public function getUploader($type, $parameters)
9189
);
9290
}
9391
$destinationDir = "downloadable/files/" . $type;
94-
$destinationPath = $dirAddon . $DS . $this->mediaDirectory->getRelativePath($destinationDir);
92+
$destinationPath = $dirAddon . '/' . $this->mediaDirectory->getRelativePath($destinationDir);
9593

9694
$this->mediaDirectory->create($destinationPath);
9795
if (!$this->fileUploader->setDestDir($destinationPath)) {

app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportPost.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ class ImportPost extends \Magento\TaxImportExport\Controller\Adminhtml\Rate
1616
*/
1717
public function execute()
1818
{
19-
if ($this->getRequest()->isPost() && !empty($_FILES['import_rates_file']['tmp_name'])) {
19+
$importRatesFile = $this->getRequest()->getFiles('import_rates_file');
20+
if ($this->getRequest()->isPost() && isset($importRatesFile['tmp_name'])) {
2021
try {
2122
/** @var $importHandler \Magento\TaxImportExport\Model\Rate\CsvImportHandler */
2223
$importHandler = $this->_objectManager->create(
2324
\Magento\TaxImportExport\Model\Rate\CsvImportHandler::class
2425
);
25-
$importHandler->importFromCsvFile($this->getRequest()->getFiles('import_rates_file'));
26+
$importHandler->importFromCsvFile($importRatesFile);
2627

2728
$this->messageManager->addSuccess(__('The tax rate has been imported.'));
2829
} catch (\Magento\Framework\Exception\LocalizedException $e) {

dev/tests/static/framework/Magento/ruleset.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@
3333
<include-pattern>*/(app/code|vendor|setup/src)/*</include-pattern>
3434
<exclude-pattern>*/setup/src/Magento/Setup/Controller/WebConfiguration.php</exclude-pattern>
3535
<exclude-pattern>*/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php</exclude-pattern>
36+
<exclude-pattern>*/app/code/Magento/Eav/Model/Attribute/Data/File.php</exclude-pattern>
37+
<exclude-pattern>*/app/code/Magento/Config/Model/Config/Reader/Source/Deployed/SettingChecker.php</exclude-pattern>
38+
<exclude-pattern>*/app/code/Magento/Backend/App/Area/FrontNameResolver.php</exclude-pattern>
39+
<exclude-pattern>*/app/code/Magento/Indexer/Console/Command/AbstractIndexerCommand.php</exclude-pattern>
40+
<exclude-pattern>*/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php</exclude-pattern>
41+
<exclude-pattern>*/app/code/Magento/Cron/Console/Command/CronCommand.php</exclude-pattern>
42+
<exclude-pattern>*/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Validate.php</exclude-pattern>
43+
<exclude-pattern>*/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate.php</exclude-pattern>
44+
<exclude-pattern>*/app/code/Magento/Store/Model/Store.php</exclude-pattern>
45+
<exclude-pattern>*/app/code/Magento/Config/Model/Config/Processor/EnvironmentPlaceholder.php</exclude-pattern>
46+
<exclude-pattern>*/app/code/Magento/Config/Model/Config/Backend/Email/Logo.php</exclude-pattern>
47+
<exclude-pattern>*/app/code/Magento/Config/Model/Config/Backend/File/RequestData.php</exclude-pattern>
48+
<exclude-pattern>*/app/code/Magento/Config/App/Config/Source/EnvironmentConfigSource.php</exclude-pattern>
49+
<exclude-pattern>*/app/code/Magento/Theme/Controller/Adminhtml/Design/Config/FileUploader/Save.php</exclude-pattern>
50+
<exclude-pattern>*/app/code/Magento/Customer/Model/Metadata/Form/File.php</exclude-pattern>
51+
<exclude-pattern>*/app/code/Magento/Customer/Model/FileUploader.php</exclude-pattern>
52+
<exclude-pattern>*/app/code/Magento/Customer/Controller/Adminhtml/File/Address/Upload.php</exclude-pattern>
53+
<exclude-pattern>*/app/code/Magento/Customer/Controller/Adminhtml/File/Customer/Upload.php</exclude-pattern>
3654
<exclude-pattern>*/Test/Unit/*</exclude-pattern>
3755
</rule>
3856

0 commit comments

Comments
 (0)