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 18231 Create provision for testing environment variable #8132

Closed
wants to merge 8 commits into from

Conversation

pradpnayak
Copy link
Contributor

No description provided.

----------------------------------------
* CRM-18231: Create provision for testing environment variable
  https://issues.civicrm.org/jira/browse/CRM-18231
----------------------------------------
* CRM-18231: Create provision for testing environment variable
  https://issues.civicrm.org/jira/browse/CRM-18231
… in civicrm.settings.php file

----------------------------------------
* CRM-18231:
  https://issues.civicrm.org/jira/browse/CRM-18231
…turned off

----------------------------------------
* CRM-18231: Create provision for testing environment variable
  https://issues.civicrm.org/jira/browse/CRM-18231
----------------------------------------
* CRM-18231:
  https://issues.civicrm.org/jira/browse/CRM-18231
----------------------------------------
* CRM-18231: Create provision for testing environment variable
  https://issues.civicrm.org/jira/browse/CRM-18231
----------------------------------------
* CRM-18231: Create provision for testing environment variable
  https://issues.civicrm.org/jira/browse/CRM-18231
@eileenmcnaughton
Copy link
Contributor

test this please

@pradpnayak pradpnayak changed the title Crm 18231 master Crm 18231 Create provision for testing environment variable Apr 14, 2016
@pradpnayak
Copy link
Contributor Author

@eileenmcnaughton can you please review this for us?

@eileenmcnaughton
Copy link
Contributor

Hi Pradeep, I had hoped to bring it into this months QA cycle but there was too much to get through. I checked with Monish because if you had put in a lot of work already this month but he wasn't aware of you having done that so I decided it makes more sense to push it to next month than for me to stay up late to get it done

public function postProcess() {
$params = $this->controller->exportValues($this->_name);

if ($params['isProductionEnvironment'] === FALSE) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I did notices is that this is happening in the form - which is not correct, it should work via the api too - take a look at how the logging setting works for how to not do it in the form layer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton I'm not quite sure what you are getting at here: isn't Civi::settings()->set() merely a wrapper for functionality also exposed via API wrapper? Or is your concern that the success message should be bubbled up from something the API calls too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean - I wasn't expecting the call backs relevant to this setting to be doing any thing in the form layer. ie. this is setting a setting in the form post process hook - if you look at the logging setting, by contrast, disabling & enabling the field has a callback that does the needed, regardless where it is called from

@eileenmcnaughton
Copy link
Contributor

NB - I don't have time to do a full QA but I think there is a lot to like here - it's well tested and I can see the idea is that if you want to test scheduled jobs etc you need to make sure it's set to production which definitely has merit.

One hesitation I have is that it feels like it should be isDevelopment or even environment to allow for the possibility of more options, but I'm waivering a bit on that. I think equating isProduction unset with isProduction = FALSE would be flakey on 4.6 but it might not be on 4.7.

A few things probably worth doing

  1. sending an email on the dev list mentioning you have done this PR & inviting comment - since they will be affected
  2. adding a few lines to the civicrm_settings.php as a template for enabling this
  3. How will people know that the setting is enabled? Or not enabled? Should Dev sites have something showing?

@xurizaemon
Copy link
Member

xurizaemon commented May 17, 2016

👍 to Eileen's comments above - both that I love the direction, and that isProduction feels prescriptive.

IMO isProduction is a true-false thing, and the aim here is to move towards more flexible methods around development workflow (not just production-or-not but dev-test-staging-production and back again). Drupal's Environment module has similarities, and that it ships with development/production/readonly as defaults while permitting other environments is IMO a good thing.

Sorry for coming into the discussion a month later but hadn't had this appear on my radar until now!

@@ -142,6 +142,10 @@ public function run() {
* @param null $action
*/
public function browse($action = NULL) {
// check if non-prod mode is enabled.
if (Civi::settings()->get('isProductionEnvironment') === FALSE) {
CRM_Core_Session::setStatus(ts('Execution of scheduled jobs have been turned off.'), ts("Non-production Environment"), "warning", array('expires' => 0));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be precise about things: when production environment is toggled off, execution of scheduled jobs is turned off by default, BUT parameters on jobs can override this. So please change message to 'Execution of scheduled jobs has been turned off by default since this is a non-production environment. You can override this for particular jobs by adding runInNonProductionEnvironment=TRUE as a parameter.'

@JoeMurray
Copy link
Contributor

@eileenmcnaughton sorry I didn't see you comments till now. I think it is appropriate that when JMA didn't put in the volunteer time as promised in April that you didn't put in extra effort on this. Our bad. Would have been nice to see it included in list for May. @totten thank for putting on list for June.

I think the default value for whatever the new setting is called should be production. I considered increasing scope to put in staging/dev/test, but a) could not see any differences for our current use cases amongst the non-production environments, and b) didn't want to gold-plate especially since this not fully funded by client (http://www.projectmanagementlearning.com/what-is-gold-plating-in-project-management.html). I'd be happy to see this develop in the future, but feel it addresses something useful as it is. I see @xurizaemon also agrees, so now I'm on the fence about refactoring to support more values than just true false.

  1. I'll send out a message to dev - great idea. I think there was a mention in response to @adixon but no call for comments.
  2. Yes, we'll add some commented out text showing how to enable as well as explanation.
  3. Umm, I was thinking the url would be the key, but I guess you're suggesting that when functionality is turned off on non-production environments then something dramatic should be displayed, beyond the values in the settings page and scheduled job page? I don't want it to be so irritating that people would want a setting to turn off the notice about the value of this setting...


if ($params['isProductionEnvironment'] === FALSE) {
Civi::settings()->set('mailing_backend', array('outBound_option' => CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED));
CRM_Core_Session::setStatus(ts('Outbound emails have been disabled. Scheduled jobs have been prevented from being executed.'), ts("Non-production environment set"), "success");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change message to ''Outbound emails have been disabled. Scheduled jobs will not run unless runInNonProductionEnvironment=TRUE is added as a parameter for a specific job"

@eileenmcnaughton
Copy link
Contributor

Closing by request of @JoeMurray as spec is revised

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.

5 participants