Skip to content

Commit 78bef61

Browse files
committed
Merge remote-tracking branch 'remotes/south/BUGS' into develop
2 parents accc725 + 25468e0 commit 78bef61

File tree

11 files changed

+41
-33
lines changed

11 files changed

+41
-33
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ protected function _convertDate($date)
205205
\IntlDateFormatter::NONE,
206206
$adminTimeZone
207207
);
208-
$simpleRes = new \DateTime('@' . $formatter->parse($date), $adminTimeZone);
208+
$simpleRes = new \DateTime(null, $adminTimeZone);
209+
$simpleRes->setTimestamp($formatter->parse($date));
209210
$simpleRes->setTime(0, 0, 0);
210211
$simpleRes->setTimezone(new \DateTimeZone('UTC'));
211212
return $simpleRes;

app/code/Magento/Backup/Model/Backup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function load($fileName, $filePath)
152152
'extension' => $this->_helper->getExtensionByType($backupData->getType()),
153153
'display_name' => $this->_helper->nameToDisplayName($backupData->getName()),
154154
'name' => $backupData->getName(),
155-
'date_object' => new \DateTime('@' . $backupData->getTime()),
155+
'date_object' => (new \DateTime())->setTimestamp($backupData->getTime()),
156156
]
157157
);
158158

app/code/Magento/Catalog/Model/Product/Option/Type/Date.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function prepareForCart()
165165
$timestamp += 60 * 60 * $value['hour'] + 60 * $value['minute'];
166166
}
167167

168-
$date = new \DateTime('@' . $timestamp);
168+
$date = (new \DateTime())->setTimestamp($timestamp);
169169
$result = $date->format('Y-m-d H:i:s');
170170

171171
// Save date in internal format to avoid locale date bugs
@@ -188,19 +188,22 @@ public function getFormattedOptionValue($optionValue)
188188
{
189189
if ($this->_formattedOptionValue === null) {
190190
if ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE) {
191-
$format = $this->_localeDate->getDateFormat(
192-
\IntlDateFormatter::MEDIUM
191+
$result = $this->_localeDate->formatDateTime(
192+
new \DateTime($optionValue),
193+
\IntlDateFormatter::MEDIUM,
194+
\IntlDateFormatter::NONE
193195
);
194-
$result = \IntlDateFormatter::formatObject(new \DateTime($optionValue), $format);
195196
} elseif ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE_TIME) {
196-
$format = $this->_localeDate->getDateTimeFormat(
197+
$result = $this->_localeDate->formatDateTime(
198+
new \DateTime($optionValue),
199+
\IntlDateFormatter::SHORT,
197200
\IntlDateFormatter::SHORT
198201
);
199-
$result = \IntlDateFormatter::formatObject(new \DateTime($optionValue), $format);
200202
} elseif ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_TIME) {
201-
$result = \IntlDateFormatter::formatObject(
203+
$result = $this->_localeDate->formatDateTime(
202204
new \DateTime($optionValue),
203-
$this->is24hTimeFormat() ? 'H:i' : 'h:i a'
205+
\IntlDateFormatter::NONE,
206+
\IntlDateFormatter::SHORT
204207
);
205208
} else {
206209
$result = $optionValue;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ protected function _saveProducts()
10861086
$storeIds = [0];
10871087

10881088
if ('datetime' == $attribute->getBackendType() && strtotime($attrValue)) {
1089-
$attrValue = new \DateTime('@' . strtotime($attrValue));
1089+
$attrValue = (new \DateTime())->setTimestamp(strtotime($attrValue));
10901090
$attrValue = $attrValue->format(DateTime::DATETIME_PHP_FORMAT);
10911091
} elseif ($backModel) {
10921092
$attribute->getBackend()->beforeSave($product);

app/code/Magento/CatalogRule/Model/Observer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public function prepareCatalogProductCollectionPrices(EventObserver $observer)
267267
if ($observer->getEvent()->hasDate()) {
268268
$date = new \DateTime($observer->getEvent()->getDate());
269269
} else {
270-
$date = new \DateTime('@' . $this->_localeDate->scopeTimeStamp($store));
270+
$date = (new \DateTime())->setTimestamp($this->_localeDate->scopeTimeStamp($store));
271271
}
272272

273273
$productIds = [];

app/code/Magento/Customer/view/frontend/templates/form/register.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
require([
165165
'jquery',
166166
'mage/mage'
167-
], function(jQuery){
167+
], function($){
168168

169169
var dataForm = $('#form-validate');
170170
var ignore = <?php echo $_dob->isEnabled() ? '\'input[id$="full"]\'' : 'null'; ?>;

app/code/Magento/CustomerImportExport/Model/Import/Address.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ protected function _prepareDataForUpdate(array $rowData)
473473
if ('select' == $attributeParams['type']) {
474474
$value = $attributeParams['options'][strtolower($rowData[$attributeAlias])];
475475
} elseif ('datetime' == $attributeParams['type']) {
476-
$value = new \DateTime('@' . strtotime($rowData[$attributeAlias]));
476+
$value = (new \DateTime())->setTimestamp(strtotime($rowData[$attributeAlias]));
477477
$value = $value->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
478478
} else {
479479
$value = $rowData[$attributeAlias];

app/code/Magento/CustomerImportExport/Model/Import/Customer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,11 @@ protected function _prepareDataForUpdate(array $rowData)
292292
$attributesToSave = [];
293293

294294
// entity table data
295-
$now = new \DateTime('@' . time());
295+
$now = new \DateTime();
296296
if (empty($rowData['created_at'])) {
297297
$createdAt = $now;
298298
} else {
299-
$createdAt = new \DateTime('@' . strtotime($rowData['created_at']));
299+
$createdAt = (new \DateTime())->setTimestamp(strtotime($rowData['created_at']));
300300
}
301301
$entityRow = [
302302
'group_id' => empty($rowData['group_id']) ? self::DEFAULT_GROUP_ID : $rowData['group_id'],
@@ -333,7 +333,7 @@ protected function _prepareDataForUpdate(array $rowData)
333333
if ('select' == $attributeParameters['type']) {
334334
$value = $attributeParameters['options'][strtolower($value)];
335335
} elseif ('datetime' == $attributeParameters['type']) {
336-
$value = new \DateTime('@' . strtotime($value));
336+
$value = (new \DateTime())->setTimestamp(strtotime($value));
337337
$value = $value->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
338338
} elseif ($backendModel) {
339339
$attribute->getBackend()->beforeSave($this->_customerModel->setData($attributeCode, $value));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function formatDate($date)
7171
}
7272
// unix timestamp given - simply instantiate date object
7373
if (is_scalar($date) && preg_match('/^[0-9]+$/', $date)) {
74-
$date = new \DateTime('@' . $date);
74+
$date = (new \DateTime())->setTimestamp($date);
7575
// international format
7676
} elseif (!($date instanceof \DateTime)) {
7777
$date = new \DateTime($date);

app/code/Magento/Reports/Block/Adminhtml/Grid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function _prepareCollection()
9292

9393
if (!isset($data['report_from'])) {
9494
// getting all reports from 2001 year
95-
$date = new \DateTime('@' . mktime(0, 0, 0, 1, 1, 2001));
95+
$date = (new \DateTime())->setTimestamp(mktime(0, 0, 0, 1, 1, 2001));
9696
$data['report_from'] = $this->_localeDate->formatDateTime(
9797
$date,
9898
\IntlDateFormatter::SHORT,

app/code/Magento/RequireJs/Block/Html/Head/Config.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77
namespace Magento\RequireJs\Block\Html\Head;
88

9+
use Magento\Framework\RequireJs\Config as RequireJsConfig;
10+
911
/**
1012
* Block responsible for including RequireJs config on the page
1113
*/
1214
class Config extends \Magento\Framework\View\Element\AbstractBlock
1315
{
1416
/**
15-
* @var \Magento\Framework\RequireJs\Config
17+
* @var RequireJsConfig
1618
*/
1719
private $config;
1820

@@ -28,15 +30,15 @@ class Config extends \Magento\Framework\View\Element\AbstractBlock
2830

2931
/**
3032
* @param \Magento\Framework\View\Element\Context $context
31-
* @param \Magento\Framework\RequireJs\Config $config
33+
* @param RequireJsConfig $config
3234
* @param \Magento\RequireJs\Model\FileManager $fileManager
3335
* @param \Magento\Framework\View\Page\Config $pageConfig
3436
* @param \Magento\Framework\View\Asset\ConfigInterface $bundleConfig
3537
* @param array $data
3638
*/
3739
public function __construct(
3840
\Magento\Framework\View\Element\Context $context,
39-
\Magento\Framework\RequireJs\Config $config,
41+
RequireJsConfig $config,
4042
\Magento\RequireJs\Model\FileManager $fileManager,
4143
\Magento\Framework\View\Page\Config $pageConfig,
4244
\Magento\Framework\View\Asset\ConfigInterface $bundleConfig,
@@ -59,28 +61,30 @@ protected function _prepareLayout()
5961
$requireJsConfig = $this->fileManager->createRequireJsConfigAsset();
6062
$assetCollection = $this->pageConfig->getAssetCollection();
6163

62-
if ($this->bundleConfig->isBundlingJsFiles()) {
63-
$after = \Magento\Framework\RequireJs\Config::REQUIRE_JS_FILE_NAME;
64+
$assetCollection->insert(
65+
$requireJsConfig->getFilePath(),
66+
$requireJsConfig,
67+
RequireJsConfig::REQUIRE_JS_FILE_NAME
68+
);
6469

70+
if ($this->bundleConfig->isBundlingJsFiles()) {
6571
$bundleAssets = $this->fileManager->createBundleJsPool();
6672
$staticAsset = $this->fileManager->createStaticJsAsset();
6773

6874
/** @var \Magento\Framework\View\Asset\File $bundleAsset */
6975
if (!empty($bundleAssets) && $staticAsset !== false) {
76+
$bundleAssets = array_reverse($bundleAssets);
7077
foreach ($bundleAssets as $bundleAsset) {
71-
$assetCollection->insert($bundleAsset->getFilePath(), $bundleAsset, $after);
72-
$after = $bundleAsset->getFilePath();
78+
$assetCollection->insert(
79+
$bundleAsset->getFilePath(),
80+
$bundleAsset,
81+
RequireJsConfig::REQUIRE_JS_FILE_NAME
82+
);
7383
}
74-
$assetCollection->insert($staticAsset->getFilePath(), $staticAsset, $after);
84+
$assetCollection->insert($staticAsset->getFilePath(), $staticAsset, RequireJsConfig::CONFIG_FILE_NAME);
7585
}
7686
}
7787

78-
$assetCollection->insert(
79-
$requireJsConfig->getFilePath(),
80-
$requireJsConfig,
81-
\Magento\Framework\RequireJs\Config::REQUIRE_JS_FILE_NAME
82-
);
83-
8488
return parent::_prepareLayout();
8589
}
8690

0 commit comments

Comments
 (0)