Skip to content

Commit f75ba2b

Browse files
author
Karpenko, Oleksandr
committed
Merge branch 'develop' of github.com:magento/magento2ce into MAGETWO-69515
2 parents 9072154 + bd22a2c commit f75ba2b

File tree

22 files changed

+325
-112
lines changed

22 files changed

+325
-112
lines changed

app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -315,26 +315,35 @@ protected function getMultilineFieldConfig($attributeCode, array $attributeConfi
315315
*/
316316
protected function getDefaultValue($attributeCode)
317317
{
318+
if ($attributeCode === 'country_id') {
319+
return $this->directoryHelper->getDefaultCountry();
320+
}
321+
322+
$customer = $this->getCustomer();
323+
if ($customer === null) {
324+
return null;
325+
}
326+
327+
$attributeValue = null;
318328
switch ($attributeCode) {
329+
case 'prefix':
330+
$attributeValue = $customer->getPrefix();
331+
break;
319332
case 'firstname':
320-
if ($this->getCustomer()) {
321-
return $this->getCustomer()->getFirstname();
322-
}
333+
$attributeValue = $customer->getFirstname();
323334
break;
324335
case 'middlename':
325-
if ($this->getCustomer()) {
326-
return $this->getCustomer()->getMiddlename();
327-
}
336+
$attributeValue = $customer->getMiddlename();
328337
break;
329338
case 'lastname':
330-
if ($this->getCustomer()) {
331-
return $this->getCustomer()->getLastname();
332-
}
339+
$attributeValue = $customer->getLastname();
340+
break;
341+
case 'suffix':
342+
$attributeValue = $customer->getSuffix();
333343
break;
334-
case 'country_id':
335-
return $this->directoryHelper->getDefaultCountry();
336344
}
337-
return null;
345+
346+
return $attributeValue;
338347
}
339348

340349
/**

app/code/Magento/Cron/Observer/ProcessCronQueueObserver.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ class ProcessCronQueueObserver implements ObserverInterface
9797
protected $_shell;
9898

9999
/**
100-
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
100+
* @var \Magento\Framework\Stdlib\DateTime\DateTime
101101
*/
102-
protected $timezone;
102+
protected $dateTime;
103103

104104
/**
105105
* @var \Symfony\Component\Process\PhpExecutableFinder
@@ -124,7 +124,7 @@ class ProcessCronQueueObserver implements ObserverInterface
124124
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
125125
* @param \Magento\Framework\App\Console\Request $request
126126
* @param \Magento\Framework\ShellInterface $shell
127-
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone
127+
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
128128
* @param \Magento\Framework\Process\PhpExecutableFinderFactory $phpExecutableFinderFactory
129129
* @param \Psr\Log\LoggerInterface $logger
130130
* @param \Magento\Framework\App\State $state
@@ -138,7 +138,7 @@ public function __construct(
138138
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
139139
\Magento\Framework\App\Console\Request $request,
140140
\Magento\Framework\ShellInterface $shell,
141-
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone,
141+
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
142142
\Magento\Framework\Process\PhpExecutableFinderFactory $phpExecutableFinderFactory,
143143
\Psr\Log\LoggerInterface $logger,
144144
\Magento\Framework\App\State $state
@@ -150,7 +150,7 @@ public function __construct(
150150
$this->_scopeConfig = $scopeConfig;
151151
$this->_request = $request;
152152
$this->_shell = $shell;
153-
$this->timezone = $timezone;
153+
$this->dateTime = $dateTime;
154154
$this->phpExecutableFinder = $phpExecutableFinderFactory->create();
155155
$this->logger = $logger;
156156
$this->state = $state;
@@ -170,7 +170,7 @@ public function __construct(
170170
public function execute(\Magento\Framework\Event\Observer $observer)
171171
{
172172
$pendingJobs = $this->_getPendingSchedules();
173-
$currentTime = $this->timezone->scopeTimeStamp();
173+
$currentTime = $this->dateTime->gmtTimestamp();
174174
$jobGroupsRoot = $this->_config->getJobs();
175175

176176
$phpPath = $this->phpExecutableFinder->find() ?: 'php';
@@ -274,7 +274,7 @@ protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule,
274274
);
275275
}
276276

277-
$schedule->setExecutedAt(strftime('%Y-%m-%d %H:%M:%S', $this->timezone->scopeTimeStamp()))->save();
277+
$schedule->setExecutedAt(strftime('%Y-%m-%d %H:%M:%S', $this->dateTime->gmtTimestamp()))->save();
278278

279279
try {
280280
call_user_func_array($callback, [$schedule]);
@@ -285,7 +285,7 @@ protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule,
285285

286286
$schedule->setStatus(Schedule::STATUS_SUCCESS)->setFinishedAt(strftime(
287287
'%Y-%m-%d %H:%M:%S',
288-
$this->timezone->scopeTimeStamp()
288+
$this->dateTime->gmtTimestamp()
289289
));
290290
}
291291

@@ -322,7 +322,7 @@ protected function _generate($groupId)
322322
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
323323
);
324324
$schedulePeriod = $rawSchedulePeriod * self::SECONDS_IN_MINUTE;
325-
if ($lastRun > $this->timezone->scopeTimeStamp() - $schedulePeriod) {
325+
if ($lastRun > $this->dateTime->gmtTimestamp() - $schedulePeriod) {
326326
return $this;
327327
}
328328

@@ -343,7 +343,7 @@ protected function _generate($groupId)
343343
* save time schedules generation was ran with no expiration
344344
*/
345345
$this->_cache->save(
346-
$this->timezone->scopeTimeStamp(),
346+
$this->dateTime->gmtTimestamp(),
347347
self::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT . $groupId,
348348
['crontab'],
349349
null
@@ -398,7 +398,7 @@ protected function _cleanup($groupId)
398398
'system/cron/' . $groupId . '/' . self::XML_PATH_HISTORY_CLEANUP_EVERY,
399399
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
400400
);
401-
if ($lastCleanup > $this->timezone->scopeTimeStamp() - $historyCleanUp * self::SECONDS_IN_MINUTE) {
401+
if ($lastCleanup > $this->dateTime->gmtTimestamp() - $historyCleanUp * self::SECONDS_IN_MINUTE) {
402402
return $this;
403403
}
404404

@@ -431,7 +431,7 @@ protected function _cleanup($groupId)
431431
Schedule::STATUS_ERROR => $historyFailure * self::SECONDS_IN_MINUTE,
432432
];
433433

434-
$now = $this->timezone->scopeTimeStamp();
434+
$now = $this->dateTime->gmtTimestamp();
435435
/** @var Schedule $record */
436436
foreach ($history as $record) {
437437
$checkTime = $record->getExecutedAt() ? strtotime($record->getExecutedAt()) :
@@ -443,7 +443,7 @@ protected function _cleanup($groupId)
443443

444444
// save time history cleanup was ran with no expiration
445445
$this->_cache->save(
446-
$this->timezone->scopeTimeStamp(),
446+
$this->dateTime->gmtTimestamp(),
447447
self::CACHE_KEY_LAST_HISTORY_CLEANUP_AT . $groupId,
448448
['crontab'],
449449
null
@@ -475,7 +475,7 @@ protected function getConfigSchedule($jobConfig)
475475
*/
476476
protected function saveSchedule($jobCode, $cronExpression, $timeInterval, $exists)
477477
{
478-
$currentTime = $this->timezone->scopeTimeStamp();
478+
$currentTime = $this->dateTime->gmtTimestamp();
479479
$timeAhead = $currentTime + $timeInterval;
480480
for ($time = $currentTime; $time < $timeAhead; $time += self::SECONDS_IN_MINUTE) {
481481
$ts = strftime('%Y-%m-%d %H:%M:00', $time);
@@ -503,7 +503,7 @@ protected function generateSchedule($jobCode, $cronExpression, $time)
503503
->setCronExpr($cronExpression)
504504
->setJobCode($jobCode)
505505
->setStatus(Schedule::STATUS_PENDING)
506-
->setCreatedAt(strftime('%Y-%m-%d %H:%M:%S', $this->timezone->scopeTimeStamp()))
506+
->setCreatedAt(strftime('%Y-%m-%d %H:%M:%S', $this->dateTime->gmtTimestamp()))
507507
->setScheduledAt(strftime('%Y-%m-%d %H:%M', $time));
508508

509509
return $schedule;

app/code/Magento/Cron/Test/Unit/Observer/ProcessCronQueueObserverTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ class ProcessCronQueueObserverTest extends \PHPUnit_Framework_TestCase
6464
protected $_cronGroupConfig;
6565

6666
/**
67-
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
67+
* @var \Magento\Framework\Stdlib\DateTime\DateTime
6868
*/
69-
protected $timezone;
69+
protected $dateTimeMock;
7070

7171
/**
7272
* @var \Magento\Framework\Event\Observer
@@ -126,8 +126,10 @@ protected function setUp()
126126

127127
$this->observer = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false);
128128

129-
$this->timezone = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);
130-
$this->timezone->expects($this->any())->method('scopeTimeStamp')->will($this->returnValue(time()));
129+
$this->dateTimeMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTime::class)
130+
->disableOriginalConstructor()
131+
->getMock();
132+
$this->dateTimeMock->expects($this->any())->method('gmtTimestamp')->will($this->returnValue(time()));
131133

132134
$phpExecutableFinder = $this->getMock(\Symfony\Component\Process\PhpExecutableFinder::class, [], [], '', false);
133135
$phpExecutableFinder->expects($this->any())->method('find')->willReturn('php');
@@ -148,7 +150,7 @@ protected function setUp()
148150
$this->_scopeConfig,
149151
$this->_request,
150152
$this->_shell,
151-
$this->timezone,
153+
$this->dateTimeMock,
152154
$phpExecutableFinderFactory,
153155
$this->loggerMock,
154156
$this->appStateMock

app/code/Magento/Deploy/Console/DeployStaticOptions.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ class DeployStaticOptions
131131
*/
132132
const CONTENT_VERSION = 'content-version';
133133

134+
/**
135+
* Key for refresh content version only mode
136+
*/
137+
const REFRESH_CONTENT_VERSION_ONLY = 'refresh-content-version-only';
138+
134139
/**
135140
* Deploy static command options list
136141
*
@@ -225,6 +230,13 @@ private function getBasicOptions()
225230
'Custom version of static content can be used if running deployment on multiple nodes '
226231
. 'to ensure that static content version is identical and caching works properly.'
227232
),
233+
new InputOption(
234+
self::REFRESH_CONTENT_VERSION_ONLY,
235+
null,
236+
InputOption::VALUE_NONE,
237+
'Refreshing the version of static content only can be used to refresh static content '
238+
. 'in browser cache and CDN cache.'
239+
),
228240
new InputArgument(
229241
self::LANGUAGES_ARGUMENT,
230242
InputArgument::IS_ARRAY,

app/code/Magento/Deploy/Service/DeployStaticContent.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ public function __construct(
7575
*/
7676
public function deploy(array $options)
7777
{
78+
$version = !empty($options[Options::CONTENT_VERSION]) && is_string($options[Options::CONTENT_VERSION])
79+
? $options[Options::CONTENT_VERSION]
80+
: (new \DateTime())->getTimestamp();
81+
$this->versionStorage->save($version);
82+
83+
if ($this->isRefreshContentVersionOnly($options)) {
84+
$this->logger->warning("New content version: " . $version);
85+
return;
86+
}
87+
7888
$queue = $this->queueFactory->create(
7989
[
8090
'logger' => $this->logger,
@@ -96,11 +106,6 @@ public function deploy(array $options)
96106
]
97107
);
98108

99-
$version = !empty($options[Options::CONTENT_VERSION]) && is_string($options[Options::CONTENT_VERSION])
100-
? $options[Options::CONTENT_VERSION]
101-
: (new \DateTime())->getTimestamp();
102-
$this->versionStorage->save($version);
103-
104109
$packages = $deployStrategy->deploy($options);
105110

106111
if ($options[Options::NO_JAVASCRIPT] !== true) {
@@ -135,4 +140,14 @@ private function getProcessesAmount(array $options)
135140
{
136141
return isset($options[Options::JOBS_AMOUNT]) ? (int)$options[Options::JOBS_AMOUNT] : 0;
137142
}
143+
144+
/**
145+
* @param array $options
146+
* @return bool
147+
*/
148+
private function isRefreshContentVersionOnly(array $options)
149+
{
150+
return isset($options[Options::REFRESH_CONTENT_VERSION_ONLY])
151+
&& $options[Options::REFRESH_CONTENT_VERSION_ONLY];
152+
}
138153
}

0 commit comments

Comments
 (0)