civicrm / civicrm/cv

cv cron: runs with the UTC timezone if not configured globally

Open
#274 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
45
Forks
36
Avg merge
17h 54m
Merged PRs (30d)
3

Description

I encountered an interesting problem with Scheduled Reminders:

- The client was saying that the Scheduled Reminders seemed to be running with UTC time, instead of UTC+3 in their case. We could confirm it was the case, looking at the civicrm logs and the activity table.
- I debugged it to where `CRM_Core_BAO_ActionSchedule::processQueue` gets the `$now` using `CRM_Utils_Time::getTime()`, and that boils down to running `time()`.
- `cv cron -vvv` mentions setting the timezone, and looking at the code, I see that it calls `\CRM_Core_Config::singleton()->userSystem->setTimeZone()`. On Drupal10, this seems to be `CRM_Utils_System_Base::setTimeZone()`, which I was able to confirm with tracing. This uses `date_default_timezone_get()`.

The PHP docs state that `date_default_timezone_get()` will return UTC, if not set in the PHP config explicitly.

I can workaround the issue by adding a `date_default_timezone_set()` statement in the `civicrm.settings.php`, but that's not a very convenient fix.

I will dig into the timezone settings for Standalone, and if it might make sense to expose it for all CMSes?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at CRM_Core_BAO_ActionSchedule::processQueue and trace how cv cron sets the timezone through CRM_Core_Config::singleton()->userSystem->setTimeZone(). Compare the Drupal 10 path in CRM_Utils_System_Base::setTimeZone() with the timezone settings for Standalone and other CMSes. Done means scheduled reminders use the configured timezone instead of defaulting to UTC, with the supported behavior verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.