Mwalker has submitted this change and it was merged.

Change subject: Polish exchange rates module
......................................................................


Polish exchange rates module

Do not insert blank rows when we dont have data
-and-
Use Oanda's fixed IP web service.

Change-Id: Idc8770d0c87c8375f2731fdc2002f7342665cccf
---
M sites/all/modules/exchange_rates/exchange_rates.module
1 file changed, 18 insertions(+), 16 deletions(-)

Approvals:
  Adamw: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/sites/all/modules/exchange_rates/exchange_rates.module 
b/sites/all/modules/exchange_rates/exchange_rates.module
index 60b5bbe..3747b75 100644
--- a/sites/all/modules/exchange_rates/exchange_rates.module
+++ b/sites/all/modules/exchange_rates/exchange_rates.module
@@ -340,7 +340,7 @@
        
        // Construct the URL for the API call
        $currencyList = implode( '_', $currencies );
-       $url = 
'https://www.oanda.com/cgi-bin/fxml/fxml?fxmlrequest=%3Cconvert%3E%3Cclient_id%3E';
+       $url = 
'https://web-services.oanda.com/cgi-bin/fxml/fxml?fxmlrequest=%3Cconvert%3E%3Cclient_id%3E';
        $url .= 'WikimediaFoundation';
        $url .= '%3C/client_id%3E%3Cexpr%3EUSD%3C/expr%3E%3Cexch%3E';
        $url .= $currencyList;
@@ -371,6 +371,7 @@
                }
        } else {
                // Use our back-up XML source. This will only set the rate for 
the most common currencies.
+        watchdog( WATCHDOG_WARNING, 'Using backup exchange rates source from 
the ECB' );
                $url = 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml';
                
                // Retrieve and parse the XML results
@@ -395,21 +396,22 @@
                $bankUpdateTimestamp = strtotime( $date . ' 00:00:00 GMT' );
                variable_set( 'exchange_rates_bank_update', 
$bankUpdateTimestamp );
          
-               // Table is based on EUR, so must insert manually
-               exchange_rates_update_rate( 'EUR', $usdBase, 
$bankUpdateTimestamp );
-         
-               // Calculate and insert remaining rates
-               foreach ( $index['CUBE'] as $valIndex ) {
-                       $current = $results[$valIndex];
-                       if ( isset( $current['attributes']['CURRENCY'] ) && 
isset( $current['attributes']['RATE'] ) ) {
-                               exchange_rates_update_rate(
-                                       $current['attributes']['CURRENCY'], 
-                                       $usdBase / 
$current['attributes']['RATE'], 
-                                       $bankUpdateTimestamp
-                               );
-                       }
-               }
-               
+               // Table is based on EUR, so must insert manually if we 
actually got anything
+        if ( $usdBase !== 0 ) {
+            exchange_rates_update_rate( 'EUR', $usdBase, $bankUpdateTimestamp 
);
+
+            // Calculate and insert remaining rates
+            foreach ( $index['CUBE'] as $valIndex ) {
+                $current = $results[$valIndex];
+                if ( isset( $current['attributes']['CURRENCY'] ) && isset( 
$current['attributes']['RATE'] ) ) {
+                    exchange_rates_update_rate(
+                        $current['attributes']['CURRENCY'],
+                        $usdBase / $current['attributes']['RATE'],
+                        $bankUpdateTimestamp
+                    );
+                }
+            }
+        }
        }
        
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Idc8770d0c87c8375f2731fdc2002f7342665cccf
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Mwalker <mwal...@wikimedia.org>
Gerrit-Reviewer: Adamw <awi...@wikimedia.org>
Gerrit-Reviewer: Mwalker <mwal...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to