CRM-17022 fix - Bug introduced in 4.6.6 breaks Grant Search
[civicrm-core.git] / bin / ContributionProcessor.php
index 0e867e266a0856bccb3c9e1a4583abbf9081da14..57abe9cb453e98d34da76ca480299392f447b44b 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -142,8 +142,7 @@ class CiviContributeProcessor {
    * @param $start
    * @param $end
    */
-  static
-  function paypal($paymentProcessor, $paymentMode, $start, $end) {
+  public static function paypal($paymentProcessor, $paymentMode, $start, $end) {
     $url = "{$paymentProcessor['url_api']}nvp";
 
     $keyArgs = array(
@@ -186,7 +185,7 @@ class CiviContributeProcessor {
           // details about a transaction, let's make sure that it doesn't
           // already exist in the database.
           require_once 'CRM/Contribute/DAO/Contribution.php';
-          $dao = new CRM_Contribute_DAO_Contribution;
+          $dao = new CRM_Contribute_DAO_Contribution();
           $dao->trxn_id = $value;
           if ($dao->find(TRUE)) {
             preg_match('/(\d+)$/', $name, $matches);
@@ -248,8 +247,7 @@ class CiviContributeProcessor {
    * @param $start
    * @param $end
    */
-  static
-  function google($paymentProcessor, $paymentMode, $start, $end) {
+  public static function google($paymentProcessor, $paymentMode, $start, $end) {
     require_once "CRM/Contribute/BAO/Contribution/Utils.php";
     require_once 'CRM/Core/Payment/Google.php';
     $nextPageToken = TRUE;
@@ -282,9 +280,7 @@ class CiviContributeProcessor {
           $response[1][$response[0]]['notifications']['charge-amount-notification'][] = $chrgAmt;
         }
 
-        foreach ($response[1][$response[0]]['notifications']['charge-amount-notification']
-                 as $amtData
-        ) {
+        foreach ($response[1][$response[0]]['notifications']['charge-amount-notification'] as $amtData) {
           $searchParams = array(
             'order-numbers' => array($amtData['google-order-number']['VALUE']),
             'notification-types' => array('risk-information', 'new-order', 'charge-amount'),
@@ -321,8 +317,7 @@ class CiviContributeProcessor {
     }
   }
 
-  static
-  function csv() {
+  public static function csv() {
     $csvFile = '/home/deepak/Desktop/crm-4247.csv';
     $delimiter = ";";
     $row = 1;
@@ -364,8 +359,7 @@ class CiviContributeProcessor {
     fclose($handle);
   }
 
-  static
-  function process() {
+  public static function process() {
     require_once 'CRM/Utils/Request.php';
 
     $type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'csv', 'REQUEST');
@@ -404,6 +398,7 @@ class CiviContributeProcessor {
         return self::csv();
     }
   }
+
 }
 
 // bootstrap the environment and run the processor
@@ -417,8 +412,7 @@ CRM_Utils_System::authenticateScript(TRUE);
 //log the execution of script
 CRM_Core_Error::debug_log_message('ContributionProcessor.php');
 
-require_once 'CRM/Core/Lock.php';
-$lock = new CRM_Core_Lock('CiviContributeProcessor');
+$lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.contribute.CiviContributeProcessor');
 
 if ($lock->isAcquired()) {
   // try to unset any time limits
@@ -429,7 +423,7 @@ if ($lock->isAcquired()) {
   CiviContributeProcessor::process();
 }
 else {
-  throw new Exception('Could not acquire lock, another CiviMailProcessor process is running');
+  throw new Exception('Could not acquire lock, another CiviContributeProcessor process is running');
 }
 
 $lock->release();