Skip to content

Commit 071413e

Browse files
author
He, Joan(johe)
committed
Merge pull request #175 from magento2/time_zone
[Extensibility] Timezone bug fixes
2 parents 1b6e07b + 46161fd commit 071413e

File tree

127 files changed

+931
-1215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+931
-1215
lines changed

app/bootstrap.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,5 @@
4141
!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
4242
);
4343
}
44-
if (ini_get('date.timezone') == '') {
45-
date_default_timezone_set('UTC');
46-
}
44+
45+
date_default_timezone_set('UTC');

app/code/Magento/AdminNotification/Model/Feed.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,11 @@ public function checkUpdate()
141141

142142
if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
143143
foreach ($feedXml->channel->item as $item) {
144-
if ($installDate <= strtotime((string)$item->pubDate)) {
144+
$itemPublicationDate = strtotime((string)$item->pubDate);
145+
if ($installDate <= $itemPublicationDate) {
145146
$feedData[] = [
146147
'severity' => (int)$item->severity,
147-
'date_added' => $this->getDate((string)$item->pubDate),
148+
'date_added' => date('Y-m-d H:i:s', $itemPublicationDate),
148149
'title' => (string)$item->title,
149150
'description' => (string)$item->description,
150151
'url' => (string)$item->link,
@@ -161,17 +162,6 @@ public function checkUpdate()
161162
return $this;
162163
}
163164

164-
/**
165-
* Retrieve DB date from RSS date
166-
*
167-
* @param string $rssDate
168-
* @return string YYYY-MM-DD YY:HH:SS
169-
*/
170-
public function getDate($rssDate)
171-
{
172-
return gmdate('Y-m-d H:i:s', strtotime($rssDate));
173-
}
174-
175165
/**
176166
* Retrieve Update Frequency
177167
*

app/code/Magento/AdminNotification/Observer/PredispathAdminActionControllerObserver.php renamed to app/code/Magento/AdminNotification/Observer/PredispatchAdminActionControllerObserver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
* @author Magento Core Team <core@magentocommerce.com>
1414
*/
15-
class PredispathAdminActionControllerObserver implements ObserverInterface
15+
class PredispatchAdminActionControllerObserver implements ObserverInterface
1616
{
1717
/**
1818
* @var \Magento\AdminNotification\Model\FeedFactory

app/code/Magento/AdminNotification/etc/adminhtml/events.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
99
<event name="controller_action_predispatch">
10-
<observer name="adminnotification" instance="Magento\AdminNotification\Observer\PredispathAdminActionControllerObserver" />
10+
<observer name="adminnotification" instance="Magento\AdminNotification\Observer\PredispatchAdminActionControllerObserver" />
1111
</event>
1212
</config>

app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,10 @@ protected function getTierPrices(array $listSku, $table)
345345
if (isset($exportFilter) && !empty($exportFilter)) {
346346
$date = $exportFilter[\Magento\Catalog\Model\Category::KEY_UPDATED_AT];
347347
if (isset($date[0]) && !empty($date[0])) {
348-
$updatedAtFrom = date('Y-m-d H:i:s', strtotime($date[0]));
348+
$updatedAtFrom = $this->_localeDate->date($date[0], null, false)->format('Y-m-d H:i:s');
349349
}
350350
if (isset($date[1]) && !empty($date[1])) {
351-
$updatedAtTo = date('Y-m-d H:i:s', strtotime($date[1]));
351+
$updatedAtTo = $this->_localeDate->date($date[1], null, false)->format('Y-m-d H:i:s');
352352
}
353353
}
354354
try {

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
143143
protected $_catalogProductEntity;
144144

145145
/**
146-
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
146+
* @var \Magento\Framework\Stdlib\DateTime\DateTime
147147
*/
148-
protected $_localeDate;
148+
protected $dateTime;
149149

150150
/**
151151
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -157,7 +157,7 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
157157
* @param \Magento\ImportExport\Model\ResourceModel\Helper $resourceHelper
158158
* @param \Magento\Framework\Stdlib\StringUtils $string
159159
* @param ProcessingErrorAggregatorInterface $errorAggregator
160-
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
160+
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
161161
* @param \Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModelFactory $resourceFactory
162162
* @param \Magento\Catalog\Model\Product $productModel
163163
* @param \Magento\Catalog\Helper\Data $catalogData
@@ -177,7 +177,7 @@ public function __construct(
177177
\Magento\ImportExport\Model\ResourceModel\Helper $resourceHelper,
178178
\Magento\Framework\Stdlib\StringUtils $string,
179179
ProcessingErrorAggregatorInterface $errorAggregator,
180-
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
180+
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
181181
\Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModelFactory $resourceFactory,
182182
\Magento\Catalog\Model\Product $productModel,
183183
\Magento\Catalog\Helper\Data $catalogData,
@@ -187,7 +187,7 @@ public function __construct(
187187
AdvancedPricing\Validator\Website $websiteValidator,
188188
AdvancedPricing\Validator\TierPrice $tierPriceValidator
189189
) {
190-
$this->_localeDate = $localeDate;
190+
$this->dateTime = $dateTime;
191191
$this->jsonHelper = $jsonHelper;
192192
$this->_importExportData = $importExportData;
193193
$this->_resourceHelper = $resourceHelper;
@@ -470,11 +470,11 @@ protected function deleteProductTierPrices(array $listSku, $tableName)
470470
*/
471471
protected function setUpdatedAt(array $listSku)
472472
{
473-
$updatedAt = $this->_localeDate->date(null, null, false)->format('Y-m-d H:i:s');
473+
$updatedAt = $this->dateTime->gmtDate('Y-m-d H:i:s');
474474
$this->_connection->update(
475475
$this->_catalogProductEntity,
476476
[\Magento\Catalog\Model\Category::KEY_UPDATED_AT => $updatedAt],
477-
$this->_connection->quoteInto('sku IN (?)', $listSku)
477+
$this->_connection->quoteInto('sku IN (?)', array_unique($listSku))
478478
);
479479
return $this;
480480
}

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class AdvancedPricingTest extends \Magento\ImportExport\Test\Unit\Model\Import\A
7979
/**
8080
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject
8181
*/
82-
protected $localeDate;
82+
protected $dateTime;
8383

8484
/**
8585
* @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
@@ -249,14 +249,14 @@ public function setUp()
249249
false
250250
);
251251
$this->errorAggregator = $this->getErrorAggregatorObject();
252-
$this->localeDate = $this->getMock(
253-
'\Magento\Framework\Stdlib\DateTime\Timezone',
252+
$this->dateTime = $this->getMock(
253+
'\Magento\Framework\Stdlib\DateTime\DateTime',
254254
['date', 'format'],
255255
[],
256256
'',
257257
false
258258
);
259-
$this->localeDate->expects($this->any())->method('date')->willReturnSelf();
259+
$this->dateTime->expects($this->any())->method('date')->willReturnSelf();
260260

261261
$this->advancedPricing = $this->getAdvancedPricingMock([
262262
'retrieveOldSkus',
@@ -783,7 +783,7 @@ private function getAdvancedPricingMock($methods = [])
783783
$this->resourceHelper,
784784
$this->stringObject,
785785
$this->errorAggregator,
786-
$this->localeDate,
786+
$this->dateTime,
787787
$this->resourceFactory,
788788
$this->productModel,
789789
$this->catalogData,

app/code/Magento/Authorization/Model/ResourceModel/Role.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,16 @@ class Role extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
2626
*/
2727
protected $_cache;
2828

29-
/**
30-
* @var \Magento\Framework\Stdlib\DateTime
31-
*/
32-
protected $dateTime;
33-
3429
/**
3530
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
3631
* @param \Magento\Framework\App\CacheInterface $cache
37-
* @param \Magento\Framework\Stdlib\DateTime $dateTime
3832
* @param string $connectionName
3933
*/
4034
public function __construct(
4135
\Magento\Framework\Model\ResourceModel\Db\Context $context,
4236
\Magento\Framework\App\CacheInterface $cache,
43-
\Magento\Framework\Stdlib\DateTime $dateTime,
4437
$connectionName = null
4538
) {
46-
$this->dateTime = $dateTime;
4739
parent::__construct($context, $connectionName);
4840
$this->_cache = $cache->getFrontend();
4941
}
@@ -67,11 +59,6 @@ protected function _construct()
6759
*/
6860
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $role)
6961
{
70-
if (!$role->getId()) {
71-
$role->setCreated($this->dateTime->formatDate(true));
72-
}
73-
$role->setModified($this->dateTime->formatDate(true));
74-
7562
if ($role->getId() == '') {
7663
if ($role->getIdFieldName()) {
7764
$role->unsetData($role->getIdFieldName());

app/code/Magento/Backend/Block/Dashboard/Graph.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ public function getChartUrl($directUrl = true)
387387
*/
388388
foreach ($this->_axisLabels[$idx] as $_index => $_label) {
389389
if ($_label != '') {
390-
$period = new \DateTime($_label);
390+
$period = new \DateTime($_label, new \DateTimeZone($timezoneLocal));
391391
switch ($this->getDataHelper()->getParam('period')) {
392392
case '24h':
393393
$this->_axisLabels[$idx][$_index] = $this->_localeDate->formatDateTime(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ public function setFilterType($type, $className)
447447
*/
448448
protected function _getFilterByType()
449449
{
450-
$type = strtolower($this->getType());
450+
$type = $this->getFilterType() ? strtolower($this->getFilterType()) : strtolower($this->getType());
451451
$filterClass = isset($this->_filterTypes[$type]) ? $this->_filterTypes[$type] : $this->_filterTypes['default'];
452452

453453
return $filterClass;

0 commit comments

Comments
 (0)