Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure Joomla timezone is set for cron jobs #12609

Merged
merged 1 commit into from
Aug 5, 2018

Conversation

mattwire
Copy link
Contributor

@mattwire mattwire commented Aug 1, 2018

Overview

When running CiviCRM on Joomla the timezone is not being set correctly when running cron from the command line (eg. via a server cron job).

Example:
/usr/local/bin/ea-php70 /path/to/site/administrator/components/com_civicrm/civicrm/bin/cli.php -s urltosite.org -u cronjob_user -p cronjob_pwd -e Job -a execute >/dev/null 2>&1

The impact of this is that currently (ie. during British Summer Time (BST)) when you view the list of cron jobs the last_run date is one hour behind when it was actually run - but when you view the job log for each job the start/end date/time is correct and current.

So, for example at 11:00 the mailings job says it was last run at 10:00 but the mailings job log says started at 11:00:05, ended at 11:00:15.

Before

The CRON job is always being executed with timezone set to UTC.

After

The CRON job is executed using the same timezone as Joomla (and the same timezone that is configured for Joomla/CiviCRM/database when running via web).

Technical Details

A similar "fix" was added to the Wordpress loadBootStrap() function a few years ago.

Comments

It is likely that this issue may/may not arise depending on specific server timezone configurations. In this case this is a shared WHM/cpanel server which I only have access to the cpanel account.

The configured Joomla timezone is Europe/London and PHP is also configured for both the domain and home directory to be Europe/London.

The timezone check in CiviCRM passes both before and after this PR because the environment is configured properly when run via web.

I think this may also have an impact on some IPN transactions as I've seen them with the wrong time in the past from PayPal. However, I have not investigated this further at this stage.

@civibot
Copy link

civibot bot commented Aug 1, 2018

(Standard links)

@mattwire
Copy link
Contributor Author

mattwire commented Aug 1, 2018

@lcdservices Would you have time to have a look at this? I know you have a number of Joomla sites.

@lcdservices
Copy link
Contributor

@mattwire Tested and confirmed. Before this patch was applied, triggering the cron via cli resulted in a UTC timestamp in the job listing's Last Run column. After applying this patch the timestamp matches the timezone configured in Joomla global config.

@seamuslee001
Copy link
Contributor

(CiviCRM Review Template WORD-1.1)

@seamuslee001 seamuslee001 merged commit 750f4e6 into civicrm:master Aug 5, 2018
@mattwire mattwire deleted the joomla_cron_timezone branch September 25, 2018 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants