Skip to content

Commit 043e32a

Browse files
author
Oleksii Korshenko
authored
MAGETWO-85274: Update CrontabManager.php #12610
2 parents d91b5c3 + d134cc4 commit 043e32a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/internal/Magento/Framework/Crontab/CrontabManager.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ public function removeTasks()
138138
private function generateSection($content, $tasks = [])
139139
{
140140
if ($tasks) {
141+
// Add EOL symbol to previous line if not exist.
142+
if (substr($content, -strlen(PHP_EOL)) !== PHP_EOL) {
143+
$content .= PHP_EOL;
144+
}
145+
141146
$content .= $this->getTasksBlockStart() . PHP_EOL;
142147
foreach ($tasks as $task) {
143148
$content .= $task['expression'] . ' ' . PHP_BINARY . ' ' . $task['command'] . PHP_EOL;

lib/internal/Magento/Framework/Crontab/Test/Unit/CrontabManagerTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,17 @@ public function saveTasksDataProvider()
337337
. ' %% cron:run | grep -v \"Ran \'jobs\' by schedule\"' . PHP_EOL
338338
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL,
339339
],
340+
[
341+
'tasks' => [
342+
['command' => '{magentoRoot}run.php % cron:run | grep -v "Ran \'jobs\' by schedule"']
343+
],
344+
'content' => '* * * * * /bin/php /var/www/cron.php',
345+
'contentToSave' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL
346+
. CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5(BP) . PHP_EOL
347+
. '* * * * * ' . PHP_BINARY . ' /var/www/magento2/run.php'
348+
. ' %% cron:run | grep -v \"Ran \'jobs\' by schedule\"' . PHP_EOL
349+
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL,
350+
],
340351
];
341352
}
342353
}

0 commit comments

Comments
 (0)