Skip to content

Commit d18c713

Browse files
authored
Merge pull request #3771 from magento-tsg-csl3/2.2-develop-pr21
[TSG-CSL3] For 2.2 (pr21)
2 parents 36e6ba7 + 468f305 commit d18c713

File tree

8 files changed

+216
-49
lines changed

8 files changed

+216
-49
lines changed

app/code/Magento/Catalog/Block/Product/View/Attributes.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Magento\Framework\Pricing\PriceCurrencyInterface;
1717

1818
/**
19+
* Attributes attributes block
20+
*
1921
* @api
2022
* @since 100.0.2
2123
*/
@@ -56,6 +58,8 @@ public function __construct(
5658
}
5759

5860
/**
61+
* Returns a Product.
62+
*
5963
* @return Product
6064
*/
6165
public function getProduct()
@@ -67,6 +71,8 @@ public function getProduct()
6771
}
6872

6973
/**
74+
* Additional data.
75+
*
7076
* $excludeAttr is optional array of attribute codes to
7177
* exclude them from additional data array
7278
*
@@ -89,7 +95,7 @@ public function getAdditionalData(array $excludeAttr = [])
8995
$value = $this->priceCurrency->convertAndFormat($value);
9096
}
9197

92-
if (is_string($value) && strlen($value)) {
98+
if (is_string($value) && strlen(trim($value))) {
9399
$data[$attribute->getAttributeCode()] = [
94100
'label' => __($attribute->getStoreLabel()),
95101
'value' => $value,

app/code/Magento/Catalog/Test/Unit/Block/Product/View/AttributesTest.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,28 @@ protected function setUp()
125125
}
126126

127127
/**
128+
* Get attribute with no value phrase
129+
*
130+
* @param string $phrase
128131
* @return void
132+
* @dataProvider noValueProvider
129133
*/
130-
public function testGetAttributeNoValue()
134+
public function testGetAttributeNoValue(string $phrase)
131135
{
132-
$this->phrase = '';
133-
$this->frontendAttribute
134-
->expects($this->any())
135-
->method('getValue')
136-
->willReturn($this->phrase);
136+
$this->frontendAttribute->method('getValue')
137+
->willReturn($phrase);
137138
$attributes = $this->attributesBlock->getAdditionalData();
138-
$this->assertTrue(empty($attributes['phrase']));
139+
$this->assertArrayNotHasKey('phrase', $attributes);
140+
}
141+
142+
/**
143+
* No value data provider
144+
*
145+
* @return array
146+
*/
147+
public function noValueProvider(): array
148+
{
149+
return [[' '], ['']];
139150
}
140151

141152
/**

app/code/Magento/Checkout/view/frontend/templates/cart/noItems.phtml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@
1313
$block->escapeUrl($block->getContinueShoppingUrl())) ?></p>
1414
<?= $block->getChildHtml('shopping.cart.table.after') ?>
1515
</div>
16+
<script type="text/x-magento-init">
17+
{
18+
"*": {
19+
"Magento_Checkout/js/empty-cart": {}
20+
}
21+
}
22+
</script>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'Magento_Customer/js/customer-data'
8+
], function (customerData) {
9+
'use strict';
10+
11+
customerData.reload(['cart'], false);
12+
});

app/code/Magento/Cron/Model/Schedule.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\Exception\CronException;
1010
use Magento\Framework\App\ObjectManager;
1111
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
12+
use Magento\Framework\Intl\DateTimeFactory;
1213

1314
/**
1415
* Crontab schedule model
@@ -50,24 +51,32 @@ class Schedule extends \Magento\Framework\Model\AbstractModel
5051
*/
5152
private $timezoneConverter;
5253

54+
/**
55+
* @var DateTimeFactory
56+
*/
57+
private $dateTimeFactory;
58+
5359
/**
5460
* @param \Magento\Framework\Model\Context $context
5561
* @param \Magento\Framework\Registry $registry
5662
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
5763
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
5864
* @param array $data
59-
* @param TimezoneInterface $timezoneConverter
65+
* @param TimezoneInterface|null $timezoneConverter
66+
* @param DateTimeFactory|null $dateTimeFactory
6067
*/
6168
public function __construct(
6269
\Magento\Framework\Model\Context $context,
6370
\Magento\Framework\Registry $registry,
6471
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
6572
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
6673
array $data = [],
67-
TimezoneInterface $timezoneConverter = null
74+
TimezoneInterface $timezoneConverter = null,
75+
DateTimeFactory $dateTimeFactory = null
6876
) {
6977
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
7078
$this->timezoneConverter = $timezoneConverter ?: ObjectManager::getInstance()->get(TimezoneInterface::class);
79+
$this->dateTimeFactory = $dateTimeFactory ?: ObjectManager::getInstance()->get(DateTimeFactory::class);
7180
}
7281

7382
/**
@@ -109,17 +118,20 @@ public function trySchedule()
109118
if (!$e || !$time) {
110119
return false;
111120
}
121+
$configTimeZone = $this->timezoneConverter->getConfigTimezone();
122+
$storeDateTime = $this->dateTimeFactory->create(null, new \DateTimeZone($configTimeZone));
112123
if (!is_numeric($time)) {
113124
//convert time from UTC to admin store timezone
114125
//we assume that all schedules in configuration (crontab.xml and DB tables) are in admin store timezone
115-
$time = $this->timezoneConverter->date($time)->format('Y-m-d H:i');
116-
$time = strtotime($time);
126+
$dateTimeUtc = $this->dateTimeFactory->create($time);
127+
$time = $dateTimeUtc->getTimestamp();
117128
}
118-
$match = $this->matchCronExpression($e[0], strftime('%M', $time))
119-
&& $this->matchCronExpression($e[1], strftime('%H', $time))
120-
&& $this->matchCronExpression($e[2], strftime('%d', $time))
121-
&& $this->matchCronExpression($e[3], strftime('%m', $time))
122-
&& $this->matchCronExpression($e[4], strftime('%w', $time));
129+
$time = $storeDateTime->setTimestamp($time);
130+
$match = $this->matchCronExpression($e[0], $time->format('i'))
131+
&& $this->matchCronExpression($e[1], $time->format('H'))
132+
&& $this->matchCronExpression($e[2], $time->format('d'))
133+
&& $this->matchCronExpression($e[3], $time->format('m'))
134+
&& $this->matchCronExpression($e[4], $time->format('w'));
123135

124136
return $match;
125137
}

0 commit comments

Comments
 (0)