diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php
index 01a2dae92f5..79a501dd740 100644
--- a/htdocs/admin/system/dolibarr.php
+++ b/htdocs/admin/system/dolibarr.php
@@ -43,7 +43,6 @@ $sfurl = '';
$version = '0.0';
-
/*
* Actions
*/
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index 0842d2befba..086f1ed7bf9 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -3494,10 +3494,15 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
function dol_filecache($directory, $filename, $object)
{
if (!dol_is_dir($directory)) {
- dol_mkdir($directory);
+ $result = dol_mkdir($directory);
+ if ($result < -1) {
+ dol_syslog("Failed to create the cache directory ".$directory, LOG_WARNING);
+ }
}
$cachefile = $directory.$filename;
+
file_put_contents($cachefile, serialize($object), LOCK_EX);
+
dolChmod($cachefile, '0644');
}
diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php
index 9535232386f..67067405898 100644
--- a/htdocs/cron/card.php
+++ b/htdocs/cron/card.php
@@ -721,7 +721,7 @@ if (($action == "create") || ($action == "edit")) {
} elseif (!empty($object->datenextrun)) {
print img_picto('', 'object_calendarday').' '.$form->textwithpicto(dol_print_date($object->datenextrun, 'dayhoursec'), $langs->trans("CurrentTimeZone"));
} else {
- print $langs->trans('CronNone');
+ print ''.$langs->trans('CronNone').'';
}
if ($object->status == Cronjob::STATUS_ENABLED) {
if ($object->maxrun && $object->nbrun >= $object->maxrun) {
@@ -746,7 +746,7 @@ if (($action == "create") || ($action == "edit")) {
if (!empty($object->datelastrun)) {
print $form->textwithpicto(dol_print_date($object->datelastrun, 'dayhoursec'), $langs->trans("CurrentTimeZone"));
} else {
- print $langs->trans('CronNone');
+ print ''.$langs->trans('CronNotYetRan').'';
}
print "";
@@ -756,7 +756,7 @@ if (($action == "create") || ($action == "edit")) {
print $form->textwithpicto(dol_print_date($object->datelastresult, 'dayhoursec'), $langs->trans("CurrentTimeZone"));
} else {
if (empty($object->datelastrun)) {
- print $langs->trans('CronNone');
+ print ''.$langs->trans('CronNotYetRan').'';
} else {
// In progress
}
diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang
index b40a7df0318..cdde3204dfa 100644
--- a/htdocs/langs/en_US/cron.lang
+++ b/htdocs/langs/en_US/cron.lang
@@ -29,7 +29,8 @@ CronExecute=Launch now
CronConfirmExecute=Are you sure you want to execute these scheduled jobs now?
CronInfo=Scheduled job module allows to schedule jobs to execute them automatically. Jobs can also be started manually.
CronTask=Job
-CronNone=None
+CronNone=Next run of scheduled task
+CronNotYetRan=Never executed
CronDtStart=Not before
CronDtEnd=Not after
CronDtNextLaunch=Next execution
diff --git a/htdocs/public/cron/cron_run_jobs_by_url.php b/htdocs/public/cron/cron_run_jobs_by_url.php
index 4fec2fe7160..3185f7bfa55 100644
--- a/htdocs/public/cron/cron_run_jobs_by_url.php
+++ b/htdocs/public/cron/cron_run_jobs_by_url.php
@@ -189,7 +189,10 @@ if (is_array($object->lines) && (count($object->lines) > 0)) {
}
//If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database
- if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) {
+ $datenextrunok = (empty($line->datenextrun) || (int) $line->datenextrun < $now);
+ $datestartok = (empty($line->datestart) || $line->datestart <= $now);
+ $dateendok = (empty($line->dateend) || $line->dateend >= $now);
+ if ($datenextrunok && $datestartok && $dateendok) {
echo " - qualified";
dol_syslog("cron_run_jobs.php line->datenextrun:".dol_print_date($line->datenextrun, 'dayhourrfc')." line->datestart:".dol_print_date($line->datestart, 'dayhourrfc')." line->dateend:".dol_print_date($line->dateend, 'dayhourrfc')." now:".dol_print_date($now, 'dayhourrfc'));
@@ -210,11 +213,13 @@ if (is_array($object->lines) && (count($object->lines) > 0)) {
echo "You can also enable module Log if not yet enabled, run again and take a look into dolibarr.log file\n";
dol_syslog("cron_run_jobs.php::run_jobs Error".$cronjob->error, LOG_ERR);
$nbofjobslaunchedko++;
+ $resultstring = 'KO';
} else {
$nbofjobslaunchedok++;
+ $resultstring = 'OK';
}
- echo " - result of run_jobs = ".$result;
+ echo "Result of run_jobs = ".$resultstring." result = ".$result;
// We re-program the next execution and stores the last execution time for this job
$result = $cronjob->reprogram_jobs($userlogin, $now);
@@ -225,11 +230,11 @@ if (is_array($object->lines) && (count($object->lines) > 0)) {
exit;
}
- echo " - reprogrammed\n";
+ echo "Job re-scheduled\n";
} else {
- echo " - not qualified\n";
+ echo " - not qualified (datenextrunok=".($datenextrunok ?: 0).", datestartok=".($datestartok ?: 0).", dateendok=".($dateendok ?: 0).")\n";
- dol_syslog("cron_run_jobs.php job not qualified line->datenextrun:".dol_print_date($line->datenextrun, 'dayhourrfc')." line->datestart:".dol_print_date($line->datestart, 'dayhourrfc')." line->dateend:".dol_print_date($line->dateend, 'dayhourrfc')." now:".dol_print_date($now, 'dayhourrfc'));
+ dol_syslog("cron_run_jobs.php job ".$line->id." not qualified line->datenextrun:".dol_print_date($line->datenextrun, 'dayhourrfc')." line->datestart:".dol_print_date($line->datestart, 'dayhourrfc')." line->dateend:".dol_print_date($line->dateend, 'dayhourrfc')." now:".dol_print_date($now, 'dayhourrfc'));
}
}
diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php
index a0752fe28da..e31dd7ffa61 100644
--- a/htdocs/societe/list.php
+++ b/htdocs/societe/list.php
@@ -37,7 +37,6 @@
* \brief Page to show list of third parties
*/
-
// Load Dolibarr environment
require_once '../main.inc.php';
include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php
index 6e93799169a..cc5a12e7ad6 100755
--- a/scripts/cron/cron_run_jobs.php
+++ b/scripts/cron/cron_run_jobs.php
@@ -94,6 +94,10 @@ $now = dol_now();
@set_time_limit(0);
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." - userlogin=".$userlogin." - ".dol_print_date($now, 'dayhourrfc', 'gmt')." - ".gethostname()." *****\n";
+// Show TZ of the serveur when ran from command line.
+$ini_path = php_ini_loaded_file();
+print 'TZ server = '.getServerTimeZoneString()." - set in PHP ini ".$ini_path."\n";
+
// Check module cron is activated
if (!isModEnabled('cron')) {
print "Error: module Scheduled jobs (cron) not activated\n";
@@ -240,7 +244,10 @@ if (is_array($object->lines) && (count($object->lines) > 0)) {
}
//If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database
- if ($forcequalified || (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now))) {
+ $datenextrunok = (empty($line->datenextrun) || (int) $line->datenextrun < $now);
+ $datestartok = (empty($line->datestart) || $line->datestart <= $now);
+ $dateendok = (empty($line->dateend) || $line->dateend >= $now);
+ if ($forcequalified || ($datenextrunok && $datestartok && $dateendok)) {
echo " - qualified";
dol_syslog("cron_run_jobs.php line->datenextrun:".dol_print_date($line->datenextrun, 'dayhourrfc')." line->datestart:".dol_print_date($line->datestart, 'dayhourrfc')." line->dateend:".dol_print_date($line->dateend, 'dayhourrfc')." now:".dol_print_date($now, 'dayhourrfc'));
@@ -267,7 +274,7 @@ if (is_array($object->lines) && (count($object->lines) > 0)) {
$resultstring = 'OK';
}
- echo " - run_jobs ".$resultstring." result = ".$result;
+ echo "Result of run_jobs ".$resultstring." result = ".$result;
// We re-program the next execution and stores the last execution time for this job
$result = $cronjob->reprogram_jobs($userlogin, $now);
@@ -278,11 +285,11 @@ if (is_array($object->lines) && (count($object->lines) > 0)) {
exit(1);
}
- echo " - reprogrammed\n";
+ echo "Job re-scheduled\n";
} else {
- echo " - not qualified\n";
+ echo " - not qualified (datenextrunok=".($datenextrunok ?: 0).", datestartok=".($datestartok ?: 0).", dateendok=".($dateendok ?: 0).")\n";
- dol_syslog("cron_run_jobs.php job not qualified line->datenextrun:".dol_print_date($line->datenextrun, 'dayhourrfc')." line->datestart:".dol_print_date($line->datestart, 'dayhourrfc')." line->dateend:".dol_print_date($line->dateend, 'dayhourrfc')." now:".dol_print_date($now, 'dayhourrfc'));
+ dol_syslog("cron_run_jobs.php job ".$line->id." not qualified line->datenextrun:".dol_print_date($line->datenextrun, 'dayhourrfc')." line->datestart:".dol_print_date($line->datestart, 'dayhourrfc')." line->dateend:".dol_print_date($line->dateend, 'dayhourrfc')." now:".dol_print_date($now, 'dayhourrfc'));
}
}