Adamw has uploaded a new change for review.
https://gerrit.wikimedia.org/r/118753
Change subject: (FR #1452) Fix source metadata handling for recurring messages
......................................................................
(FR #1452) Fix source metadata handling for recurring messages
Change-Id: I599c04835bd0b4335e66faed1c91c5e5dc0a9ab5
---
M sites/all/modules/queue2civicrm/queue2civicrm.module
M sites/all/modules/queue2civicrm/recurring/recurring.module
M sites/all/modules/wmf_common/Queue.php
3 files changed, 25 insertions(+), 11 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm
refs/changes/53/118753/1
diff --git a/sites/all/modules/queue2civicrm/queue2civicrm.module
b/sites/all/modules/queue2civicrm/queue2civicrm.module
index cebb439..068dc40 100644
--- a/sites/all/modules/queue2civicrm/queue2civicrm.module
+++ b/sites/all/modules/queue2civicrm/queue2civicrm.module
@@ -218,17 +218,7 @@
// save the original message for logging
$msg_orig = $msg;
- // Take valuable message headers and flatten them into the message body
- $pull_headers = array(
- 'source_name',
- 'source_type',
- 'source_host',
- 'source_run_id',
- 'source_version',
- 'source_enqueued_time',
- );
- $msg = json_decode( $msg->body, true )
- + array_intersect_key( $msg->headers, array_flip( $pull_headers ) );
+ $msg = json_decode( $msg->body, true );
/**
* prepare data for logging
diff --git a/sites/all/modules/queue2civicrm/recurring/recurring.module
b/sites/all/modules/queue2civicrm/recurring/recurring.module
index deedabc..0e916d2 100644
--- a/sites/all/modules/queue2civicrm/recurring/recurring.module
+++ b/sites/all/modules/queue2civicrm/recurring/recurring.module
@@ -655,6 +655,13 @@
$msg_normalized[ 'gateway' ] = ( !empty( $msg['gateway'] ) ? $msg['gateway']
: 'paypal' );
$msg_normalized[ 'date' ] = $timestamp;
+
+ // FIXME: so dirty.
+ foreach ( $msg as $key => $value ) {
+ if ( strpos( $key, "source_" ) === 0 ) {
+ $msg_normalized[$key] = $value;
+ }
+ }
return $msg_normalized;
}
diff --git a/sites/all/modules/wmf_common/Queue.php
b/sites/all/modules/wmf_common/Queue.php
index aebbaba..dbd5df9 100644
--- a/sites/all/modules/wmf_common/Queue.php
+++ b/sites/all/modules/wmf_common/Queue.php
@@ -76,6 +76,7 @@
set_time_limit( 60 );
try {
+ $this->commonMessageNormalize( $msg );
$this->transactionalCall( $callback, $msg );
$this->ack( $msg );
} catch ( WmfException $ex ) {
@@ -444,4 +445,20 @@
$msg_str = print_r( $msg_copy, true );
return $msg_str;
}
+
+ protected function commonMessageNormalize( &$msg ) {
+ // argh. Collapse useful headers into the message, then do a stupid
dance.
+ $pull_headers = array(
+ 'source_name',
+ 'source_type',
+ 'source_host',
+ 'source_run_id',
+ 'source_version',
+ 'source_enqueued_time',
+ );
+ $newBody = json_decode( $msg->body, true )
+ + array_intersect_key( $msg->headers, array_flip( $pull_headers )
);
+
+ $msg->body = json_encode( $newBody );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/118753
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I599c04835bd0b4335e66faed1c91c5e5dc0a9ab5
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