Adamw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/93100


Change subject: Slowly refactor remaining queue2civicrm_stomp.inc calls to use 
the new Queue stuff
......................................................................

Slowly refactor remaining queue2civicrm_stomp.inc calls to use the new Queue 
stuff

Change-Id: I166661cf2a598f1dc9bd4219ac8fd328a1a3e842
---
M sites/all/modules/globalcollect_audit/globalcollect_audit.info
M sites/all/modules/globalcollect_audit/globalcollect_audit.module
M sites/all/modules/queue2civicrm/queue2civicrm_stomp.inc
3 files changed, 11 insertions(+), 51 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/00/93100/1

diff --git a/sites/all/modules/globalcollect_audit/globalcollect_audit.info 
b/sites/all/modules/globalcollect_audit/globalcollect_audit.info
index 2e798a4..187936e 100644
--- a/sites/all/modules/globalcollect_audit/globalcollect_audit.info
+++ b/sites/all/modules/globalcollect_audit/globalcollect_audit.info
@@ -5,5 +5,6 @@
 dependencies[] = queue2civicrm
 dependencies[] = civicrm
 dependencies[] = wmf_common
+dependencies[] = wmf_civicrm
 package = CiviAudit
 configure = admin/config/contribution_audit/globalcollect_audit
diff --git a/sites/all/modules/globalcollect_audit/globalcollect_audit.module 
b/sites/all/modules/globalcollect_audit/globalcollect_audit.module
index 45f1163..a03194c 100644
--- a/sites/all/modules/globalcollect_audit/globalcollect_audit.module
+++ b/sites/all/modules/globalcollect_audit/globalcollect_audit.module
@@ -12,12 +12,6 @@
 define( 'GC_AUDIT_MAKE_STREET', '123 Fake Street' );
 define( 'GC_AUDIT_MAKE_CITY', 'Springfield' );
 
-if ( function_exists( 'drupal_get_path' ) ) {
-       require_once( drupal_get_path( 'module', 'wmf_civicrm' ) . 
'/wmf_civicrm.module' );
-       require_once( drupal_get_path( 'module', 'wmf_common' ) . 
'/wmf_dates.php' );
-       require_once( drupal_get_path( 'module', 'queue2civicrm' ) . 
'/queue2civicrm_stomp.inc' );
-}
-
 /**
  * Implementation of hook_menu()
  */
@@ -415,10 +409,7 @@
                        }
                }
        }
-    
-    //done with the quere server, so...
-    closeStompConnection();
-       
+
        if ( count( $errorful_transactions ) ){
                globalcollect_audit_echo("Errorful Transactions: " . print_r( 
$errorful_transactions, true ));
                globalcollect_audit_results_ball( array('Final', 'Errors'), 
count($errorful_transactions) );
diff --git a/sites/all/modules/queue2civicrm/queue2civicrm_stomp.inc 
b/sites/all/modules/queue2civicrm/queue2civicrm_stomp.inc
index 6536b6b..f7ce1d0 100644
--- a/sites/all/modules/queue2civicrm/queue2civicrm_stomp.inc
+++ b/sites/all/modules/queue2civicrm/queue2civicrm_stomp.inc
@@ -9,6 +9,8 @@
  * @param array $transaction Key-value array of staged and ready donation data.
  * @return bool Just returns true all the time. Presumably an indication that
  * nothing exploded big enough to kill the whole thing.
+ *
+ * @deprecated
  */
 function sendSTOMP( $transaction ) {
        $initial_msg = true;
@@ -25,9 +27,10 @@
        $message = json_encode( createQueueMessage( $transaction ) );
        
        if ( $message ){
-        $con = getStompConnection();
+               $q = queue2civicrm_stomp();
+
                // send a message to the queue
-               $result = $con->send( "$stompQueue", $message, array( 
'persistent' => 'true' ) );
+               $result = $q->enqueue( $message, array( 'persistent' => 'true' 
), $stompQueue );
 
                $ret = null;
                if ( !$result ) {
@@ -47,45 +50,6 @@
 }
 
 /**
- * getStompConnection gets (or closes) a reusable connection to the queue 
server.
- * Doing it this way because a static var feels much nicer than a global.
- * @staticvar Stomp|NULL $con The reusable queue server connection, or null
- * @param bool $connect If we're after a connected connection, or a 
disconnected one.
- * @return \Stomp|NULL The active connection, or NULL if it's closed
- */
-function getStompConnection( $connect = true ){
-    static $con = NULL;
-    if ( $connect ){
-        if ( is_null( $con ) ){
-            //no open connection to reuse. Make a new one.
-            $stompServer = variable_get('queue2civicrm_url', 
'tcp://localhost:61613');
-
-            $con = new Stomp( $stompServer );
-        }
-
-        if ( !$con->isConnected() ){
-            $con->connect();
-        }
-        
-    } else { //disconnect
-        if ( !is_null( $con ) ){
-            $con->disconnect();
-            $con = NULL;
-        }
-    }
-    
-    return $con;
-}
-
-/**
- * Purely for readibility.
- * Uses getStompConnection( false ) to close the reusable queue server 
connection.
- */
-function closeStompConnection(){
-    getStompConnection( false );
-}
-
-/**
  * Confirms that all fields expected by queue2civicrm are present before
  * a message is allowed to be placed into the Stomp queue.  Sets all of the
  * fields sent by Extension:DonationInterface to an empty string if not
@@ -93,6 +57,8 @@
  *
  * @param $transaction
  * @return array
+ *
+ * @deprecated
  */
 function createQueueMessage( $msg ) {
        
@@ -188,6 +154,8 @@
 
 /**
  * Arghargharghargh.
+ *
+ * @deprecated
  */
 function stageStompMessageFromDIKeys( $msg ){
 //     foreach ( $msg as $key => $value ){

-- 
To view, visit https://gerrit.wikimedia.org/r/93100
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I166661cf2a598f1dc9bd4219ac8fd328a1a3e842
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to