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

Scheduled jobs: Warnting text if runInNonProductionEnvironment=TRUE #25307

Conversation

jofranz
Copy link
Contributor

@jofranz jofranz commented Jan 10, 2023

Overview

Adds a description to inform admins about runInNonProductionEnvironment=TRUE sending emails even if mail sending is suppressed in settings.

Before

Important detail missing.
Only visible in Setting.php#L527

After

Description text has been extended to inform users, as I almost sent a bunch of mails in a test environment :D

Technical Details

Nothing technical. Just a change of a text string

Comments

  • Set your civicrm to non-production mode.
  • Navigate to /civicrm/admin/job?reset=1&action=browse and have a look at the popup window. if this pupup doesn't appear, select a job and save or cancel it. Afterwards this popup will appear.

Unfortunately, I don't have much time to work on a more sophisticated solution. But I'm happy for different wording.

@civicrm-builder
Copy link

Can one of the admins verify this patch?

@civibot
Copy link

civibot bot commented Jan 10, 2023

(Standard links)

@civibot civibot bot added the master label Jan 10, 2023
@eileenmcnaughton
Copy link
Contributor

@mlutfy this looks OK to me - just pinging you as this will mean the string needs re-translation in multiple languages so any input you have is welcome

@mlutfy
Copy link
Member

mlutfy commented Jan 12, 2023

"This will ignore email settings for this job and will send actual emails if this job is sending mails!"

Just making sure I understand correctly: which email settings are we talking about? If emails are disabled or set to log-to-database, that parameter should not change those settings?

@jofranz
Copy link
Contributor Author

jofranz commented Jan 12, 2023

@mlutfy

  • Emails are disabled in /civicrm/admin/setting/smtp
  • set runInNonProductionEnvironment=TRUE as a schedule job parameter
  • calling a custom APIv3 where this is implemented: civicrm_api3('MessageTemplate', 'send', [...]);
  • result: emails will be sent for this API call

I kind of thought this text intended being on purpose:
https://github.com/civicrm/civicrm-core/blob/master/CRM/Core/BAO/Setting.php#L527

Well it's awesome for testing but I almost mailed a bunch of clients in a testing environment. But or feature? 🤷‍♂️

@mlutfy
Copy link
Member

mlutfy commented Jan 12, 2023

huh ok, I wasn't aware of that behaviour, and looking through the code, it just raises more questions, but I'll blame that on my fever/cold.

Ex: CRM/Job/Manager.php has:

    //Disable outBound option after executing the job.
    $environment = CRM_Core_Config::environment(NULL, TRUE);
    if ($environment != 'Production' && !empty($job->apiParams['runInNonProductionEnvironment'])) {
      Civi::settings()->set('mailing_backend', ['outBound_option' => CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED]);
    }

but I don't see it enabling the mailing_backend, and I think it should store the old value in mailing_backend_store? Anyway, I'll avoid the rabbit hole.

@eileenmcnaughton If it makes sense to you, fine by me :)

@eileenmcnaughton
Copy link
Contributor

@mlutfy ohh - that looks a bit scary let's pretend we didn't see it.....

Wording change OK then

@eileenmcnaughton eileenmcnaughton merged commit 5cbdfde into civicrm:master Jan 15, 2023
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