[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] "Run time" is meant to be in UTC. Add this info in the explanatory...
Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <689127adb9717_2cd5c8c-32c@gitlab-sidekiq-low-urgency-cpu-bound-v2-58b475bb65-2f5ld.mail> |
Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
1ff8414e by NasserNgandu at 2025-08-04T21:05:23+00:00
[FIX] "Run time" is meant to be in UTC. Add this info in the explanatory "Information" text in tiki-admin_schedulers.php?scheduler=2&logs=1#contenttabs_admin_schedulers-2
---
* [FIX] Code correct.
* [FIX] Displaying the run time zone.
* [FIX] Code correct.
* [FIX] Code correct.
* [FIX] Code correct.
* [FIX] Code correct.
* [FIX] Code correct.
* [FIX] Pipeline correct.
* [FIX] Modified the code to handle cases where the server time zone is UTC.
* [NEW] Add a unit test to check scheduler run timezone.
* [FIX] "Run time" is meant to be in UTC. Add this info in the explanatory "Information" text in tiki-admin_schedulers.php?scheduler=2&logs=1#contenttabs_admin_schedulers-2
See merge request tikiwiki/tiki!7149
- - - - -
3 changed files:
- lib/test/Core/Scheduler/ManagerTest.php
- templates/tiki-admin_schedulers.tpl
- tiki-admin_schedulers.php
Changes:
=====================================
lib/test/Core/Scheduler/ManagerTest.php
=====================================
@@ -202,4 +202,35 @@ class ManagerTest extends TestCase
$this->assertFalse($shouldRun);
}
+ /**
+ * Test if the Scheduler does run in the Timezone of the server.
+ */
+ public function testSchedulerRunsInServerTimezone()
+ {
+ $defaultTimezone = date_default_timezone_get();
+ $testTimezone = $defaultTimezone === 'Pacific/Kiritimati' ? 'Pacific/Fiji' : 'Pacific/Kiritimati';
+ $currentTime = date('Y-m-d H:i:s');
+ $logger = new Tiki_Log('UnitTests', LogLevel::ERROR);
+ $scheduler = Scheduler_Item::fromArray([
+ 'id' => null,
+ 'name' => 'Test Scheduler Server Timezone',
+ 'description' => 'Scheduler to test Server Timezone',
+ 'task' => 'ConsoleCommandTask',
+ 'params' => '{"console_command":"list"}',
+ 'run_time' => '0 2 * * *',
+ 'status' => Scheduler_Item::STATUS_ACTIVE,
+ 're_run' => 0,
+ 'run_only_once' => 0,
+ 'creation_date' => time() - 60,
+ 'user_run_now' => self::USER,
+ ], $logger);
+ $scheduler->save();
+ $date_run_default_timezone = new \DateTime('@' . $scheduler->getPreviousRunDate($currentTime));
+ $date_default_timezone = $date_run_default_timezone->format('Y-m-d H:i');
+ date_default_timezone_set($testTimezone);
+ $date_run_test_timezone = new \DateTime('@' . $scheduler->getPreviousRunDate($currentTime));
+ $date_test_timezone = $date_run_test_timezone->format('Y-m-d H:i');
+ date_default_timezone_set($defaultTimezone);
+ $this->assertNotEquals($date_default_timezone, $date_test_timezone);
+ }
}
=====================================
templates/tiki-admin_schedulers.tpl
=====================================
@@ -143,7 +143,8 @@
<div class="row">
<div class="offset-sm-2 col-sm-10">
{remarksbox type="note" title="{tr}Information{/tr}"}
- {tr}Use CRON format to enter the values in "Run Time":<br>Minute, Hour, Day of Month, Month, Day of Week<br>Eg. every 5 minutes: */5 * * * *{/tr}
+ {tr}Use CRON format to enter the values in "Run Time":<br>Minute, Hour, Day of Month, Month, Day of Week<br>Eg. every 5 minutes: */5 * * * *{/tr}<br>
+ {tr _0=$run_timezone}"Run time" must be in the %0 time zone.{/tr}
{/remarksbox}
</div>
</div>
=====================================
tiki-admin_schedulers.php
=====================================
@@ -263,6 +263,7 @@ $smarty->assign('schedulerruns', isset($schedulerRuns) ? $schedulerRuns : []);
$smarty->assign('schedulerId', $scheduler);
$smarty->assign('schedulerTasks', $schedulerTasks);
$smarty->assign('selectedTask', '');
+$smarty->assign('run_timezone', TikiLib::lib('tiki')->get_display_timezone(false));
$smarty->assign('schedulerStatus', [
Scheduler_Item::STATUS_ACTIVE => tra('Active'),
Scheduler_Item::STATUS_INACTIVE => tra('Inactive'),
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/1ff8414e2dd60954bc83a50171909a7ae43981c7
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/1ff8414e2dd60954bc83a50171909a7ae43981c7
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs