Skip to content

Commit 09b6449

Browse files
committed
MAGETWO-80417: Prepare codebase for 2.1.10
1 parent 13d3888 commit 09b6449

File tree

20 files changed

+440
-496
lines changed

20 files changed

+440
-496
lines changed

app/code/Magento/CatalogWidget/Block/Product/ProductsList.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,12 @@ protected function getConditions()
233233
: $this->getData('conditions');
234234

235235
if ($conditions) {
236-
$conditions = $this->conditionsHelper->decode($conditions);
236+
try {
237+
$conditions = $this->conditionsHelper->decode($conditions);
238+
} catch (\InvalidArgumentException $e) {
239+
$this->_logger->critical($e);
240+
$conditions = '';
241+
}
237242
}
238243

239244
$this->rule->loadPost(['conditions' => $conditions]);

app/code/Magento/Deploy/Model/Filesystem.php

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\App\DeploymentConfig\Writer;
1111
use Magento\Framework\App\Filesystem\DirectoryList;
1212
use Magento\Framework\Exception\LocalizedException;
13+
use Magento\Framework\Validator\Locale;
1314
use Magento\User\Model\ResourceModel\User\Collection as UserCollection;
1415

1516
/**
@@ -88,6 +89,11 @@ class Filesystem
8889
*/
8990
private $userCollection;
9091

92+
/**
93+
* @var Locale
94+
*/
95+
private $locale;
96+
9197
/**
9298
* @param \Magento\Framework\App\DeploymentConfig\Writer $writer
9399
* @param \Magento\Framework\App\DeploymentConfig\Reader $reader
@@ -96,7 +102,10 @@ class Filesystem
96102
* @param \Magento\Framework\App\Filesystem\DirectoryList $directoryList
97103
* @param \Magento\Framework\Filesystem\Driver\File $driverFile
98104
* @param \Magento\Store\Model\Config\StoreView $storeView
99-
* @param \Magento\Framework\Shell $shell
105+
* @param \Magento\Framework\ShellInterface $shell
106+
* @param UserCollection|null $userCollection
107+
* @param Locale|null $locale
108+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
100109
*/
101110
public function __construct(
102111
\Magento\Framework\App\DeploymentConfig\Writer $writer,
@@ -106,7 +115,9 @@ public function __construct(
106115
\Magento\Framework\App\Filesystem\DirectoryList $directoryList,
107116
\Magento\Framework\Filesystem\Driver\File $driverFile,
108117
\Magento\Store\Model\Config\StoreView $storeView,
109-
\Magento\Framework\ShellInterface $shell
118+
\Magento\Framework\ShellInterface $shell,
119+
UserCollection $userCollection = null,
120+
Locale $locale = null
110121
) {
111122
$this->writer = $writer;
112123
$this->reader = $reader;
@@ -116,6 +127,8 @@ public function __construct(
116127
$this->driverFile = $driverFile;
117128
$this->storeView = $storeView;
118129
$this->shell = $shell;
130+
$this->userCollection = $userCollection ?: $this->objectManager->get(UserCollection::class);
131+
$this->locale = $locale ?: $this->objectManager->get(Locale::class);
119132
$this->functionCallPath =
120133
PHP_BINARY . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento ';
121134
}
@@ -180,40 +193,38 @@ protected function deployStaticContent(
180193
private function getAdminUserInterfaceLocales()
181194
{
182195
$locales = [];
183-
foreach ($this->getUserCollection() as $user) {
196+
foreach ($this->userCollection as $user) {
184197
$locales[] = $user->getInterfaceLocale();
185198
}
186199
return $locales;
187200
}
188201

189202
/**
190-
* Get used store and admin user locales
203+
* Get used store and admin user locales.
191204
*
192-
* @return []string
205+
* @return array
206+
* @throws \InvalidArgumentException if unknown locale is provided by the store configuration
193207
*/
194208
private function getUsedLocales()
195209
{
196210
$usedLocales = array_merge(
197211
$this->storeView->retrieveLocales(),
198212
$this->getAdminUserInterfaceLocales()
199213
);
200-
return array_unique($usedLocales);
201-
}
202214

203-
/**
204-
* Get user collection
205-
*
206-
* @return UserCollection
207-
* @deprecated
208-
*/
209-
private function getUserCollection()
210-
{
211-
if (!($this->userCollection instanceof UserCollection)) {
212-
return \Magento\Framework\App\ObjectManager::getInstance()->get(
213-
UserCollection::class
214-
);
215-
}
216-
return $this->userCollection;
215+
return array_map(
216+
function ($locale) {
217+
if (!$this->locale->isValid($locale)) {
218+
throw new \InvalidArgumentException(
219+
$locale .
220+
' argument has invalid value, run info:language:list for list of available locales'
221+
);
222+
}
223+
224+
return $locale;
225+
},
226+
array_unique($usedLocales)
227+
);
217228
}
218229

219230
/**

app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php

Lines changed: 0 additions & 176 deletions
This file was deleted.

app/code/Magento/Eav/Model/Entity/Attribute/Backend/Serialized.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,37 @@
55
*/
66
namespace Magento\Eav\Model\Entity\Attribute\Backend;
77

8+
use Magento\Framework\Unserialize\SecureUnserializer;
9+
use Magento\Framework\App\ObjectManager;
10+
use Psr\Log\LoggerInterface;
11+
812
/**
913
* "Serialized" attribute backend
1014
*/
1115
class Serialized extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
1216
{
17+
/**
18+
* @var SecureUnserializer
19+
*/
20+
private $unserializer;
21+
22+
/**
23+
* @var LoggerInterface
24+
*/
25+
private $logger;
26+
27+
/**
28+
* @param SecureUnserializer|null $unserializer
29+
* @param LoggerInterface $logger
30+
*/
31+
public function __construct(
32+
SecureUnserializer $unserializer = null,
33+
LoggerInterface $logger = null
34+
) {
35+
$this->unserializer = $unserializer ?: ObjectManager::getInstance()->get(SecureUnserializer::class);
36+
$this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class);
37+
}
38+
1339
/**
1440
* Serialize before saving
1541
*
@@ -64,9 +90,12 @@ protected function _unserialize(\Magento\Framework\DataObject $object)
6490
$attrCode = $this->getAttribute()->getAttributeCode();
6591
if ($object->getData($attrCode)) {
6692
try {
67-
$unserialized = unserialize($object->getData($attrCode));
93+
$unserialized = $this->unserializer->unserialize($object->getData($attrCode));
6894
$object->setData($attrCode, $unserialized);
69-
} catch (\Exception $e) {
95+
} catch (\InvalidArgumentException $e) {
96+
$this->logger->critical($e);
97+
$object->unsetData($attrCode);
98+
} catch (\Exception $e){
7099
$object->unsetData($attrCode);
71100
}
72101
}

app/code/Magento/Email/Model/Template/Filter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ public function filter($value)
10171017
if ($this->_appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
10181018
$value = sprintf(__('Error filtering template: %s'), $e->getMessage());
10191019
} else {
1020-
$value = __("We're sorry, an error has occurred while generating this email.");
1020+
$value = __("We're sorry, an error has occurred while generating this content.");
10211021
}
10221022
$this->_logger->critical($e);
10231023
}

app/code/Magento/ImportExport/Controller/Adminhtml/History/Download.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public function __construct(
3939
*/
4040
public function execute()
4141
{
42-
$fileName = $this->getRequest()->getParam('filename');
42+
$fileName = basename($this->getRequest()->getParam('filename'));
4343

4444
/** @var \Magento\ImportExport\Helper\Report $reportHelper */
45-
$reportHelper = $this->_objectManager->get('Magento\ImportExport\Helper\Report');
45+
$reportHelper = $this->_objectManager->get(\Magento\ImportExport\Helper\Report::class);
4646

4747
if (!$reportHelper->importFileExists($fileName)) {
4848
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */

0 commit comments

Comments
 (0)