Skip to content

Commit cbd8d8a

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #18662: [Backport] move hardcoded MIME types from class private to DI configuration (by @gelanivishal) - #18659: [Backport] Fix for #12969 - server port detection for errors (by @gelanivishal) - #18657: [Backport] Create empty modelData array to avoid undefined var error (by @gelanivishal) Fixed GitHub Issues: - #12969: processor.php getHostUrl() does not detect the server port correctly (reported by @boldhedgehog) has been fixed in #18659 by @gelanivishal in 2.2-develop branch Related commits: 1. ef426a7 2. 774a8a2 3. 763be49
2 parents 82b50ac + 6674052 commit cbd8d8a

File tree

8 files changed

+33
-16
lines changed

8 files changed

+33
-16
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,9 @@ class ImageUploader
6969
/**
7070
* List of allowed image mime types
7171
*
72-
* @var array
72+
* @var string[]
7373
*/
74-
private $allowedMimeTypes = [
75-
'image/jpg',
76-
'image/jpeg',
77-
'image/gif',
78-
'image/png'
79-
];
74+
private $allowedMimeTypes;
8075

8176
/**
8277
* ImageUploader constructor
@@ -89,6 +84,7 @@ class ImageUploader
8984
* @param string $baseTmpPath
9085
* @param string $basePath
9186
* @param string[] $allowedExtensions
87+
* @param string[] $allowedMimeTypes
9288
*/
9389
public function __construct(
9490
\Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDatabase,
@@ -98,7 +94,8 @@ public function __construct(
9894
\Psr\Log\LoggerInterface $logger,
9995
$baseTmpPath,
10096
$basePath,
101-
$allowedExtensions
97+
$allowedExtensions,
98+
$allowedMimeTypes = []
10299
) {
103100
$this->coreFileStorageDatabase = $coreFileStorageDatabase;
104101
$this->mediaDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
@@ -108,6 +105,7 @@ public function __construct(
108105
$this->baseTmpPath = $baseTmpPath;
109106
$this->basePath = $basePath;
110107
$this->allowedExtensions = $allowedExtensions;
108+
$this->allowedMimeTypes = $allowedMimeTypes;
111109
}
112110

113111
/**
@@ -167,7 +165,7 @@ public function getBasePath()
167165
}
168166

169167
/**
170-
* Retrieve base path
168+
* Retrieve allowed extensions
171169
*
172170
* @return string[]
173171
*/

app/code/Magento/Catalog/Test/Unit/Model/ImageUploaderTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,17 @@ class ImageUploaderTest extends \PHPUnit\Framework\TestCase
6969
/**
7070
* Allowed extensions
7171
*
72-
* @var string
72+
* @var array
7373
*/
7474
private $allowedExtensions;
7575

76+
/**
77+
* Allowed mime types
78+
*
79+
* @var array
80+
*/
81+
private $allowedMimeTypes;
82+
7683
protected function setUp()
7784
{
7885
$this->coreFileStorageDatabaseMock = $this->createMock(
@@ -97,6 +104,7 @@ protected function setUp()
97104
$this->baseTmpPath = 'base/tmp/';
98105
$this->basePath = 'base/real/';
99106
$this->allowedExtensions = ['.jpg'];
107+
$this->allowedMimeTypes = ['image/jpg', 'image/jpeg', 'image/gif', 'image/png'];
100108

101109
$this->imageUploader =
102110
new \Magento\Catalog\Model\ImageUploader(
@@ -107,7 +115,8 @@ protected function setUp()
107115
$this->loggerMock,
108116
$this->baseTmpPath,
109117
$this->basePath,
110-
$this->allowedExtensions
118+
$this->allowedExtensions,
119+
$this->allowedMimeTypes
111120
);
112121
}
113122

app/code/Magento/Catalog/etc/di.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@
212212
<item name="gif" xsi:type="string">gif</item>
213213
<item name="png" xsi:type="string">png</item>
214214
</argument>
215+
<argument name="allowedMimeTypes" xsi:type="array">
216+
<item name="jpg" xsi:type="string">image/jpg</item>
217+
<item name="jpeg" xsi:type="string">image/jpeg</item>
218+
<item name="gif" xsi:type="string">image/gif</item>
219+
<item name="png" xsi:type="string">image/png</item>
220+
</argument>
215221
</arguments>
216222
</virtualType>
217223
<type name="Magento\Catalog\Controller\Adminhtml\Category\Image\Upload">

app/code/Magento/Developer/Console/Command/SourceThemeDeployCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
namespace Magento\Developer\Console\Command;
77

8-
use Magento\Framework\App\State;
98
use Magento\Framework\Validator\Locale;
109
use Magento\Framework\View\Asset\Repository;
1110
use Symfony\Component\Console\Command\Command;

app/code/Magento/NewRelicReporting/Model/Cron/ReportModulesInfo.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function report()
6464
$moduleData = $this->collect->getModuleData();
6565
if (count($moduleData['changes']) > 0) {
6666
foreach ($moduleData['changes'] as $change) {
67+
$modelData = [];
6768
switch ($change['type']) {
6869
case Config::ENABLED:
6970
$modelData = [

app/code/Magento/NewRelicReporting/Model/NewRelicWrapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function addCustomParameter($param, $value)
3131
/**
3232
* Wrapper for 'newrelic_notice_error' function
3333
*
34-
* @param Exception $exception
34+
* @param \Exception $exception
3535
* @return void
3636
*/
3737
public function reportError($exception)

dev/tests/integration/testsuite/Magento/Catalog/Model/ImageUploaderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ protected function setUp()
4646
[
4747
'baseTmpPath' => $this->mediaDirectory->getRelativePath('tmp'),
4848
'basePath' => __DIR__,
49-
'allowedExtensions' => ['jpg', 'jpeg', 'gif', 'png']
49+
'allowedExtensions' => ['jpg', 'jpeg', 'gif', 'png'],
50+
'allowedMimeTypes' => ['image/jpg', 'image/jpeg', 'image/gif', 'image/png']
5051
]
5152
);
5253
}

pub/errors/processor.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,11 @@ public function getHostUrl()
268268
$isSecure = (!empty($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] != 'off');
269269
$url = ($isSecure ? 'https://' : 'http://') . $host;
270270

271-
if (!empty($_SERVER['SERVER_PORT']) && !in_array($_SERVER['SERVER_PORT'], [80, 443])
271+
$port = explode(':', $host);
272+
if (isset($port[1]) && !in_array($port[1], [80, 443])
272273
&& !preg_match('/.*?\:[0-9]+$/', $url)
273274
) {
274-
$url .= ':' . $_SERVER['SERVER_PORT'];
275+
$url .= ':' . $port[1];
275276
}
276277
return $url;
277278
}
@@ -379,6 +380,8 @@ protected function _loadXml($xmlFile)
379380
}
380381

381382
/**
383+
* Render page
384+
*
382385
* @param string $template
383386
* @return string
384387
*/

0 commit comments

Comments
 (0)