Missing index and unquoted service patch

apmuthu wrote on Sunday, April 07, 2013:

The problem:

PHP Notice:  Use of undefined constant background_shutdown - assumed 'background_shutdown' in /var/www/openemr/library/ajax/execute_background_services.php on line 164, referer: http://openemr.example.com/interface/main/left_nav.php
Undefined index: background_force in /var/www/openemr/library/ajax/execute_background_services.php on line 108, referer: http://openemr.example.com/interface/main/left_nav.php

The fix:

--- old/var/www/openemr/library/ajax/execute_background_services.php	Tue Apr 02 02:47:00 2013
+++ new/var/www/openemr/library/ajax/execute_background_services.php	Sun Apr 07 12:29:28 2013
@@ -105,7 +105,8 @@
 
   $single_service = (isset($_GET['background_service']) ? $_GET['background_service'] : 
 	(isset($_POST['background_service']) ? $_POST['background_service'] : ''));
-  $force = ($_GET['background_force'] || $_POST['background_force']);
+  $force = (isset($_GET['background_force']) ? $_GET['background_force'] : 
+	(isset($_POST['background_force']) ? $_POST['background_force'] : ''));
 
   $sql = 'SELECT * FROM background_services WHERE ' . ($force ? '1' : 'execute_interval > 0');
   if ($single_service!="")
@@ -161,7 +162,7 @@
   }
 }
 
-register_shutdown_function(background_shutdown);
+register_shutdown_function('background_shutdown');
 execute_background_service_calls();
 unset($service_name);
 

yehster wrote on Sunday, April 07, 2013:


It is cleaner to use “$_REQUEST” instead of trying to check for both “$_GET” and “$_POST”

apmuthu wrote on Monday, April 08, 2013:

It’s now committed in the mainline branch:

bradymiller wrote on Monday, April 08, 2013:

Hi Ap Muthu,

Thank you for posting this fix. For the future, if possible, try to use git/github for code submissions. Here’s a tutorial (and we are all happy to help with any questions along the way):
http://www.open-emr.org/wiki/index.php/Git_for_dummies

-brady
OpenEMR

apmuthu wrote on Monday, April 08, 2013:

Must I fork it to get submissions in or do I get to directly put in the main GitHub (dangerous) repo?

From the link above:

Let the developers know to review your code by posting an item in the ‘Code Review’ OpenEMR tracker on sourceforge and posting a message in the sourceforge OpenEMR developer forum (simply provide a link to your published github branch along with a quick explanation of your code).

This is where it gets ‘sticky’ …

bradymiller wrote on Tuesday, April 09, 2013:

Hi,

All you need to do is post a link on the forums (or the tracker). Then it will get reviewed on github. And when it’s ready to go to the official codebase, then one of the code integrators (myself, Kevin, Rod or Tony) will actually commit it to the codebase on sourceforge (note this codebase gets mirrored to github (and several other git repo sites) every 30 minutes.

For more details on how the repos work, check this out:
http://www.open-emr.org/wiki/index.php/Repository_work_flow_structure

-brady
OpenEMR