Skip to content

Commit 3c947d6

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-70971' into 2.3-develop-pr3
2 parents 9823457 + 951bcb3 commit 3c947d6

File tree

12 files changed

+133
-35
lines changed

12 files changed

+133
-35
lines changed

app/code/Magento/Bundle/etc/db_schema.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@
4545
<constraint xsi:type="foreign" name="CAT_PRD_BNDL_OPT_VAL_OPT_ID_CAT_PRD_BNDL_OPT_OPT_ID"
4646
table="catalog_product_bundle_option_value" column="option_id"
4747
referenceTable="catalog_product_bundle_option" referenceColumn="option_id" onDelete="CASCADE"/>
48-
<constraint xsi:type="unique" name="CATALOG_PRODUCT_BUNDLE_OPTION_VALUE_OPTION_ID_STORE_ID">
49-
<column name="option_id"/>
50-
<column name="store_id"/>
51-
</constraint>
5248
<constraint xsi:type="unique" name="CAT_PRD_BNDL_OPT_VAL_OPT_ID_PARENT_PRD_ID_STORE_ID">
5349
<column name="option_id"/>
5450
<column name="parent_product_id"/>

app/code/Magento/Config/App/Config/Type/System.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function get($path = '')
141141
$pathParts = explode('/', $path);
142142
if (count($pathParts) === 1 && $pathParts[0] !== 'default') {
143143
if (!isset($this->data[$pathParts[0]])) {
144-
$data = $this->reader->read();
144+
$data = $this->readData();
145145
$this->data = array_replace_recursive($data, $this->data);
146146
}
147147
return $this->data[$pathParts[0]];
@@ -171,7 +171,7 @@ private function loadAllData()
171171
{
172172
$cachedData = $this->cache->load($this->configType);
173173
if ($cachedData === false) {
174-
$data = $this->reader->read();
174+
$data = $this->readData();
175175
} else {
176176
$data = $this->serializer->unserialize($cachedData);
177177
}
@@ -188,7 +188,7 @@ private function loadDefaultScopeData($scopeType)
188188
{
189189
$cachedData = $this->cache->load($this->configType . '_' . $scopeType);
190190
if ($cachedData === false) {
191-
$data = $this->reader->read();
191+
$data = $this->readData();
192192
$this->cacheData($data);
193193
} else {
194194
$data = [$scopeType => $this->serializer->unserialize($cachedData)];
@@ -216,7 +216,7 @@ private function loadScopeData($scopeType, $scopeId)
216216
if (is_array($this->availableDataScopes) && !isset($this->availableDataScopes[$scopeType][$scopeId])) {
217217
return [$scopeType => [$scopeId => []]];
218218
}
219-
$data = $this->reader->read();
219+
$data = $this->readData();
220220
$this->cacheData($data);
221221
} else {
222222
$data = [$scopeType => [$scopeId => $this->serializer->unserialize($cachedData)]];
@@ -282,6 +282,21 @@ private function getDataByPathParts($data, $pathParts)
282282
return $data;
283283
}
284284

285+
/**
286+
* The freshly read data.
287+
*
288+
* @return array
289+
*/
290+
private function readData(): array
291+
{
292+
$this->data = $this->reader->read();
293+
$this->data = $this->postProcessor->process(
294+
$this->data
295+
);
296+
297+
return $this->data;
298+
}
299+
285300
/**
286301
* Clean cache and global variables cache
287302
*

app/code/Magento/Config/App/Config/Type/System/Reader.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,13 @@ class Reader
2727
*/
2828
private $preProcessor;
2929

30-
/**
31-
* @var \Magento\Framework\App\Config\Spi\PostProcessorInterface
32-
*/
33-
private $postProcessor;
34-
3530
/**
3631
* Reader constructor.
3732
* @param \Magento\Framework\App\Config\ConfigSourceInterface $source
3833
* @param \Magento\Store\Model\Config\Processor\Fallback $fallback
3934
* @param \Magento\Framework\App\Config\Spi\PreProcessorInterface $preProcessor
4035
* @param \Magento\Framework\App\Config\Spi\PostProcessorInterface $postProcessor
36+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4137
*/
4238
public function __construct(
4339
\Magento\Framework\App\Config\ConfigSourceInterface $source,
@@ -48,7 +44,6 @@ public function __construct(
4844
$this->source = $source;
4945
$this->fallback = $fallback;
5046
$this->preProcessor = $preProcessor;
51-
$this->postProcessor = $postProcessor;
5247
}
5348

5449
/**
@@ -60,11 +55,9 @@ public function __construct(
6055
*/
6156
public function read()
6257
{
63-
return $this->postProcessor->process(
64-
$this->fallback->process(
65-
$this->preProcessor->process(
66-
$this->source->get()
67-
)
58+
return $this->fallback->process(
59+
$this->preProcessor->process(
60+
$this->source->get()
6861
)
6962
);
7063
}

app/code/Magento/Config/Test/Unit/App/Config/Type/System/ReaderTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ public function testGetCachedWithLoadDefaultScopeData()
8484
->method('process')
8585
->with($data)
8686
->willReturn($data);
87-
$this->postProcessor->expects($this->once())
88-
->method('process')
89-
->with($data)
90-
->willReturn($data);
9187
$this->assertEquals($data, $this->model->read());
9288
}
9389
}

app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,12 @@ public function testGetNotCached()
170170
$this->reader->expects($this->once())
171171
->method('read')
172172
->willReturn($data);
173+
$this->postProcessor->expects($this->once())
174+
->method('process')
175+
->with($data)
176+
->willReturn($data);
173177

174178
$this->assertEquals($url, $this->configType->get($path));
179+
$this->assertEquals($url, $this->configType->get($path));
175180
}
176181
}

app/code/Magento/Store/Model/Config/Placeholder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ protected function _processPlaceholders($value, $data)
9191
if ($url) {
9292
$value = str_replace('{{' . $placeholder . '}}', $url, $value);
9393
} elseif (strpos($value, $this->urlPlaceholder) !== false) {
94-
// localhost is replaced for cli requests, for http requests method getDistroBaseUrl is used
95-
$value = str_replace($this->urlPlaceholder, 'http://localhost/', $value);
94+
$distroBaseUrl = $this->request->getDistroBaseUrl();
95+
96+
$value = str_replace($this->urlPlaceholder, $distroBaseUrl, $value);
9697
}
9798

9899
if (null !== $this->_getPlaceholder($value)) {

app/code/Magento/Store/Test/Unit/Model/Config/PlaceholderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected function setUp()
2323
{
2424
$this->_requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class);
2525
$this->_requestMock->expects(
26-
$this->any()
26+
$this->once()
2727
)->method(
2828
'getDistroBaseUrl'
2929
)->will(

app/code/Magento/Store/etc/config.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@
115115
<file>
116116
<protected_extensions>
117117
<php>php</php>
118+
<php3>php3</php3>
119+
<php4>php4</php4>
120+
<php5>php5</php5>
121+
<php7>php7</php7>
118122
<htaccess>htaccess</htaccess>
119123
<jsp>jsp</jsp>
120124
<pl>pl</pl>

dev/tests/integration/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/FileTest.php

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22
namespace Magento\Downloadable\Controller\Adminhtml\Downloadable;
33

4+
use Magento\Framework\Serialize\Serializer\Json;
5+
use Magento\TestFramework\Helper\Bootstrap;
6+
47
/**
58
* Magento\Downloadable\Controller\Adminhtml\Downloadable\File
69
*
@@ -10,6 +13,17 @@
1013
*/
1114
class FileTest extends \Magento\TestFramework\TestCase\AbstractBackendController
1215
{
16+
/**
17+
* @inheritdoc
18+
*/
19+
protected function tearDown()
20+
{
21+
$filePath = dirname(__DIR__) . '/_files/sample.tmp';
22+
if (is_file($filePath)) {
23+
unlink($filePath);
24+
}
25+
}
26+
1327
public function testUploadAction()
1428
{
1529
copy(dirname(__DIR__) . '/_files/sample.txt', dirname(__DIR__) . '/_files/sample.tmp');
@@ -25,11 +39,53 @@ public function testUploadAction()
2539

2640
$this->dispatch('backend/admin/downloadable_file/upload/type/samples');
2741
$body = $this->getResponse()->getBody();
28-
$result = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
29-
\Magento\Framework\Json\Helper\Data::class
30-
)->jsonDecode(
31-
$body
32-
);
42+
$result = Bootstrap::getObjectManager()->get(Json::class)->unserialize($body);
3343
$this->assertEquals(0, $result['error']);
3444
}
45+
46+
/**
47+
* Checks a case when php files are not allowed to upload.
48+
*
49+
* @param string $fileName
50+
* @dataProvider extensionsDataProvider
51+
*/
52+
public function testUploadProhibitedExtensions($fileName)
53+
{
54+
$path = dirname(__DIR__) . '/_files/';
55+
copy($path . 'sample.txt', $path . 'sample.tmp');
56+
57+
$_FILES = [
58+
'samples' => [
59+
'name' => $fileName,
60+
'type' => 'text/plain',
61+
'tmp_name' => $path . 'sample.tmp',
62+
'error' => 0,
63+
'size' => 0,
64+
],
65+
];
66+
67+
$this->dispatch('backend/admin/downloadable_file/upload/type/samples');
68+
$body = $this->getResponse()->getBody();
69+
$result = Bootstrap::getObjectManager()->get(Json::class)->unserialize($body);
70+
71+
self::assertArrayHasKey('errorcode', $result);
72+
self::assertEquals(0, $result['errorcode']);
73+
self::assertEquals('Disallowed file type.', $result['error']);
74+
}
75+
76+
/**
77+
* Returns different php file extensions.
78+
*
79+
* @return array
80+
*/
81+
public function extensionsDataProvider()
82+
{
83+
return [
84+
['sample.php'],
85+
['sample.php3'],
86+
['sample.php4'],
87+
['sample.php5'],
88+
['sample.php7'],
89+
];
90+
}
3591
}

lib/internal/Magento/Framework/Module/Dir/Reader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ public function getComposerJsonFiles()
105105
*/
106106
private function getFilesIterator($filename, $subDir = '')
107107
{
108-
#if (!isset($this->fileIterators[$subDir][$filename])) {
108+
if (!isset($this->fileIterators[$subDir][$filename])) {
109109
$this->fileIterators[$subDir][$filename] = $this->fileIteratorFactory->create(
110110
$this->getFiles($filename, $subDir)
111111
);
112-
#}
112+
}
113113
return $this->fileIterators[$subDir][$filename];
114114
}
115115

0 commit comments

Comments
 (0)