Skip to content

Commit 424864e

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-69862' into MAGETWO-69846
2 parents 5afa939 + c6b20d1 commit 424864e

File tree

32 files changed

+449
-225
lines changed

32 files changed

+449
-225
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/Package/Processor/PreProcessor/Less.php

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,34 @@ private function hasOverrides(PackageFile $parentFile, Package $package)
127127
$parentFile->getPackage()->getPath(),
128128
$parentFile->getExtension()
129129
);
130-
$parentFiles = $this->collectFileMap($parentFile->getFileName(), $map);
131-
$currentPackageLessFiles = $package->getFilesByType('less');
132-
$currentPackageCssFiles = $package->getFilesByType('css');
133130
/** @var PackageFile[] $currentPackageFiles */
134-
$currentPackageFiles = array_merge($currentPackageLessFiles, $currentPackageCssFiles);
131+
$currentPackageFiles = array_merge($package->getFilesByType('less'), $package->getFilesByType('css'));
135132

136133
foreach ($currentPackageFiles as $file) {
137-
if (in_array($file->getDeployedFileName(), $parentFiles)) {
134+
if ($this->inParentFiles($file->getDeployedFileName(), $parentFile->getFileName(), $map)) {
138135
return true;
139136
}
140137
}
138+
return false;
139+
}
141140

142-
$intersections = array_intersect($parentFiles, array_keys($currentPackageFiles));
143-
if ($intersections) {
144-
return true;
141+
/**
142+
* @param string $fileName
143+
* @param string $parentFile
144+
* @param array $map
145+
* @return bool
146+
*/
147+
private function inParentFiles($fileName, $parentFile, $map)
148+
{
149+
if (isset($map[$parentFile])) {
150+
if (in_array($fileName, $map[$parentFile])) {
151+
return true;
152+
} else {
153+
foreach ($map[$parentFile] as $pFile) {
154+
return $this->inParentFiles($fileName, $pFile, $map);
155+
}
156+
}
145157
}
146-
147158
return false;
148159
}
149160

@@ -186,25 +197,6 @@ private function buildMap($filePath, $packagePath, $contentType)
186197
return $this->map;
187198
}
188199

189-
/**
190-
* Flatten map tree into simple array
191-
*
192-
* Original map file information structure in form of tree,
193-
* and to have checking of overridden files simpler we need to flatten that tree
194-
*
195-
* @param string $fileName
196-
* @param array $map
197-
* @return array
198-
*/
199-
private function collectFileMap($fileName, array $map)
200-
{
201-
$result = isset($map[$fileName]) ? $map[$fileName] : [];
202-
foreach ($result as $fName) {
203-
$result = array_merge($result, $this->collectFileMap($fName, $map));
204-
}
205-
return array_unique($result);
206-
}
207-
208200
/**
209201
* Return normalized path
210202
*

app/code/Magento/Deploy/Process/Queue.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,15 @@ private function assertAndExecute($name, array & $packages, array $packageJob)
187187
{
188188
/** @var Package $package */
189189
$package = $packageJob['package'];
190-
$parentPackagesDeployed = true;
191190
if ($package->getParent() && $package->getParent() !== $package) {
192-
if (!$this->isDeployed($package->getParent())) {
193-
$parentPackagesDeployed = false;
194-
} else {
195-
$dependencies = $packageJob['dependencies'];
196-
foreach ($dependencies as $parentPackage) {
197-
if (!$this->isDeployed($parentPackage)) {
198-
$parentPackagesDeployed = false;
199-
break;
200-
}
191+
foreach ($packageJob['dependencies'] as $dependencyName => $dependency) {
192+
if (!$this->isDeployed($dependency)) {
193+
$this->assertAndExecute($dependencyName, $packages, $packages[$dependencyName]);
201194
}
202195
}
203196
}
204-
if (
205-
$parentPackagesDeployed
206-
&& ($this->maxProcesses < 2 || (count($this->inProgress) < $this->maxProcesses))
207-
) {
197+
if (!$this->isDeployed($package)
198+
&& ($this->maxProcesses < 2 || (count($this->inProgress) < $this->maxProcesses))) {
208199
unset($packages[$name]);
209200
$this->execute($package);
210201
}

0 commit comments

Comments
 (0)