Bläddra i källkod

Always log cron execution

There was a setting to disable the last execution of cron. There is no known
problem with this write access and it was also questioned when this feature
was build in https://github.com/owncloud/core/pull/7689#issuecomment-38264707

Recently there was also a bug report about a non-visible last cron execution
(#6088) - let's better remove this.

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
tags/v13.0.0beta1
Morris Jobke 6 år sedan
förälder
incheckning
1c38a83927

+ 0
- 7
config/config.sample.php Visa fil

*/ */
'log_query' => false, 'log_query' => false,


/**
* Log successful cron runs.
*
* Defaults to ``true``
*/
'cron_log' => true,

/** /**
* Enables log rotation and limits the total size of logfiles. The default is 0, * Enables log rotation and limits the total size of logfiles. The default is 0,
* or no rotation. Specify a size in bytes, for example 104857600 (100 megabytes * or no rotation. Specify a size in bytes, for example 104857600 (100 megabytes

+ 1
- 3
cron.php Visa fil

} }


// Log the successful cron execution // Log the successful cron execution
if (\OC::$server->getConfig()->getSystemValue('cron_log', true)) {
\OC::$server->getConfig()->setAppValue('core', 'lastcron', time());
}
\OC::$server->getConfig()->setAppValue('core', 'lastcron', time());
exit(); exit();


} catch (Exception $ex) { } catch (Exception $ex) {

+ 0
- 1
lib/private/Settings/Admin/Server.php Visa fil



// Background jobs // Background jobs
'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'), 'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'),
'cron_log' => $this->config->getSystemValue('cron_log', true),
'lastcron' => $this->config->getAppValue('core', 'lastcron', false), 'lastcron' => $this->config->getAppValue('core', 'lastcron', false),
'cronErrors' => $this->config->getAppValue('core', 'cronErrors'), 'cronErrors' => $this->config->getAppValue('core', 'cronErrors'),
'cli_based_cron_possible' => function_exists('posix_getpwuid'), 'cli_based_cron_possible' => function_exists('posix_getpwuid'),

+ 19
- 21
settings/templates/settings/admin/server.php Visa fil



<div class="section" id="backgroundjobs"> <div class="section" id="backgroundjobs">
<h2 class="inlineblock"><?php p($l->t('Background jobs'));?></h2> <h2 class="inlineblock"><?php p($l->t('Background jobs'));?></h2>
<?php if ($_['cron_log']): ?>
<p class="cronlog inlineblock">
<?php if ($_['lastcron'] !== false):
$relative_time = relative_modified_date($_['lastcron']);
$absolute_time = OC_Util::formatDate($_['lastcron']);
if (time() - $_['lastcron'] <= 3600): ?>
<span class="status success"></span>
<span class="crondate" title="<?php p($absolute_time);?>">
<?php p($l->t("Last job ran %s.", [$relative_time]));?>
</span>
<?php else: ?>
<span class="status error"></span>
<span class="crondate" title="<?php p($absolute_time);?>">
<?php p($l->t("Last job execution ran %s. Something seems wrong.", [$relative_time]));?>
</span>
<?php endif;
else: ?>
<p class="cronlog inlineblock">
<?php if ($_['lastcron'] !== false):
$relative_time = relative_modified_date($_['lastcron']);
$absolute_time = OC_Util::formatDate($_['lastcron']);
if (time() - $_['lastcron'] <= 3600): ?>
<span class="status success"></span>
<span class="crondate" title="<?php p($absolute_time);?>">
<?php p($l->t("Last job ran %s.", [$relative_time]));?>
</span>
<?php else: ?>
<span class="status error"></span> <span class="status error"></span>
<?php p($l->t("Background job didn’t run yet!"));
endif; ?>
</p>
<?php endif; ?>
<span class="crondate" title="<?php p($absolute_time);?>">
<?php p($l->t("Last job execution ran %s. Something seems wrong.", [$relative_time]));?>
</span>
<?php endif;
else: ?>
<span class="status error"></span>
<?php p($l->t("Background job didn’t run yet!"));
endif; ?>
</p>
<a target="_blank" rel="noreferrer" class="icon-info" <a target="_blank" rel="noreferrer" class="icon-info"
title="<?php p($l->t('Open documentation'));?>" title="<?php p($l->t('Open documentation'));?>"
href="<?php p(link_to_docs('admin-background-jobs')); ?>"></a> href="<?php p(link_to_docs('admin-background-jobs')); ?>"></a>

+ 2
- 8
tests/lib/Settings/Admin/ServerTest.php Visa fil

->with('core', 'backgroundjobs_mode', 'ajax') ->with('core', 'backgroundjobs_mode', 'ajax')
->willReturn('ajax'); ->willReturn('ajax');
$this->config $this->config
->expects($this->at(4))
->expects($this->at(3))
->method('getAppValue') ->method('getAppValue')
->with('core', 'lastcron', false) ->with('core', 'lastcron', false)
->willReturn(false); ->willReturn(false);
$this->config $this->config
->expects($this->at(5))
->expects($this->at(4))
->method('getAppValue') ->method('getAppValue')
->with('core', 'cronErrors') ->with('core', 'cronErrors')
->willReturn(''); ->willReturn('');
->method('getSystemValue') ->method('getSystemValue')
->with('check_for_working_wellknown_setup', true) ->with('check_for_working_wellknown_setup', true)
->willReturn(true); ->willReturn(true);
$this->config
->expects($this->at(3))
->method('getSystemValue')
->with('cron_log', true)
->willReturn(true);
$this->l10n $this->l10n
->expects($this->at(0)) ->expects($this->at(0))
->method('t') ->method('t')


// Background jobs // Background jobs
'backgroundjobs_mode' => 'ajax', 'backgroundjobs_mode' => 'ajax',
'cron_log' => true,
'lastcron' => false, 'lastcron' => false,
'cronErrors' => '', 'cronErrors' => '',
'cli_based_cron_possible' => true, 'cli_based_cron_possible' => true,

Laddar…
Avbryt
Spara