Skip to content

Commit 657d4a3

Browse files
MAGETWO-85273: Update CrontabManager.php #12609
2 parents a6f3e1d + 2e11b68 commit 657d4a3

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
@@ -338,6 +338,17 @@ public function saveTasksDataProvider()
338338
. ' %% cron:run | grep -v \"Ran \'jobs\' by schedule\"' . PHP_EOL
339339
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL,
340340
],
341+
[
342+
'tasks' => [
343+
['command' => '{magentoRoot}run.php % cron:run | grep -v "Ran \'jobs\' by schedule"']
344+
],
345+
'content' => '* * * * * /bin/php /var/www/cron.php',
346+
'contentToSave' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL
347+
. CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5(BP) . PHP_EOL
348+
. '* * * * * ' . PHP_BINARY . ' /var/www/magento2/run.php'
349+
. ' %% cron:run | grep -v \"Ran \'jobs\' by schedule\"' . PHP_EOL
350+
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL,
351+
],
341352
];
342353
}
343354
}

0 commit comments

Comments
 (0)