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

CRM-21533 : Outbound setting reverts in non-production sites on execu… #11393

Merged
merged 1 commit into from
Jan 15, 2018

Conversation

jitendrapurohit
Copy link
Contributor

@jitendrapurohit jitendrapurohit commented Dec 8, 2017

…ting sched job

Overview

Disable outbound mail on non-production sites after executing schedule job.

Before

If a site is changed to development mode using the newly added setting, outbound mail gets disabled in http://dmaster.demo.civicrm.org/civicrm/admin/setting/smtp?reset=1 (correct).

Now, when a scheduled job is executed using runInNonProductionEnvironment parameter, it reverts the outbound setting to mail()(or its original value).

More details on the Jira issue of how to replicate etc.

After

Outbound mail setting is disabled after job execution is completed on non-production sites.

Comments

Unit test added.

https://issues.civicrm.org/jira/browse/CRM-21533

@eileenmcnaughton
Copy link
Contributor

eileenmcnaughton commented Jan 15, 2018

This code makes sense to me. The original function was poorly named - isAPIJobAllowedToRun implies it is just a check but it makes an actual change. This changes the setting back afterwards. I think it is correct and it is well supported by unit tests.
``
/**

  • Check if job is able to be executed by API.
  • @throws API_Exception
    */
    public static function isAPIJobAllowedToRun($params) {
    $environment = CRM_Core_Config::environment(NULL, TRUE);
    if ($environment != 'Production') {
    if (CRM_Utils_Array::value('runInNonProductionEnvironment', $params)) {
    $mailing = Civi::settings()->get('mailing_backend_store');
    if ($mailing) {
    Civi::settings()->set('mailing_backend', $mailing);
    }
    }
    else {
    throw new Exception(ts("Job has not been executed as it is a %1 (non-production) environment.", array(1 => $environment)));
    }
    }
    }

@eileenmcnaughton eileenmcnaughton merged commit 69a16c0 into civicrm:master Jan 15, 2018
@jitendrapurohit jitendrapurohit deleted the CRM-21533 branch January 15, 2018 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants