Page MenuHomeIn-Portal Phabricator

D329.id821.diff
No OneTemporary

File Metadata

Created
Sun, Jun 29, 3:58 AM

D329.id821.diff

Index: modules/in-commerce/units/currencies/currencies_event_handler.php
===================================================================
--- modules/in-commerce/units/currencies/currencies_event_handler.php
+++ modules/in-commerce/units/currencies/currencies_event_handler.php
@@ -241,12 +241,14 @@
$event->setEventParam('ids', $ids);
$ids = $event->getEventParam('ids');
- $object = $event->getObject();
- if(is_array($ids) && $ids[0])
- {
- $sql = 'SELECT ISO FROM '.$object->TableName.' WHERE CurrencyId IN ('.implode(',', $ids).')';
+ if ( $ids ) {
+ $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $sql = 'SELECT ISO FROM ' . $table_name . ' WHERE CurrencyId IN (' . implode(',', $ids) . ')';
$iso_list = $this->Conn->GetCol($sql);
}
+ else {
+ $iso_list = array();
+ }
$rate_source = $this->Application->ConfigValue('Comm_ExchangeRateSource');
$rate_source_classes = Array( 2 => 'FRNYCurrencyRates',
@@ -319,4 +321,4 @@
$this->Application->setUnitOption($event->Prefix, 'CalculatedFields', $calculated_fields);
}
-}
\ No newline at end of file
+}
Index: modules/in-commerce/units/helpers/bank_lv_currency_rates.php
===================================================================
--- modules/in-commerce/units/helpers/bank_lv_currency_rates.php
+++ modules/in-commerce/units/helpers/bank_lv_currency_rates.php
@@ -28,9 +28,14 @@
/** @var kCurlHelper $curl_helper */
$curl_helper = $this->Application->recallObject('CurlHelper');
+ $curl_helper->followLocation = true;
$xml = $curl_helper->Send($this->RateSource);
+ if ( !$curl_helper->isGoodResponseCode() || strlen($xml) == 0 ) {
+ return;
+ }
+
xml_parse_into_struct($xml_parser, $xml, $struct, $index);
$data_res = Array();
$currency = '';
Index: modules/in-commerce/units/helpers/ecb_currency_rates.php
===================================================================
--- modules/in-commerce/units/helpers/ecb_currency_rates.php
+++ modules/in-commerce/units/helpers/ecb_currency_rates.php
@@ -17,7 +17,7 @@
public function __construct()
{
- $this->RateSource = 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml';
+ $this->RateSource = 'http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml';
parent::__construct();
}
@@ -28,9 +28,14 @@
/** @var kCurlHelper $curl_helper */
$curl_helper = $this->Application->recallObject('CurlHelper');
+ $curl_helper->followLocation = true;
$xml = $curl_helper->Send($this->RateSource);
+ if ( !$curl_helper->isGoodResponseCode() || strlen($xml) == 0 ) {
+ return;
+ }
+
xml_parse_into_struct($xml_parser, $xml, $struct, $index);
$data_res = Array();
foreach($struct as $element)
@@ -44,13 +49,14 @@
$data_res[$currency]['RATE'] = ($element['attributes']['RATE'] == 0) ? 0 : 1 / $element['attributes']['RATE'];
}
}
- if(!$data_res['EUR'])
- {
+
+ if ( !isset($data_res['EUR']) ) {
$data_res['EUR']['ID'] = 'EUR';
$data_res['EUR']['UNITS'] = 1;
$data_res['EUR']['TARGET'] = 'EUR';
$data_res['EUR']['RATE'] = 1;
}
+
$this->ExchangeRates = $data_res;
}
}
Index: modules/in-commerce/units/helpers/frny_currency_rates.php
===================================================================
--- modules/in-commerce/units/helpers/frny_currency_rates.php
+++ modules/in-commerce/units/helpers/frny_currency_rates.php
@@ -26,6 +26,7 @@
{
/** @var kCurlHelper $curl_helper */
$curl_helper = $this->Application->recallObject('CurlHelper');
+ $curl_helper->followLocation = true;
for($i = 0; $i < 10; $i++)
{
@@ -33,6 +34,10 @@
$source_file = sprintf($this->RateSource, adodb_date('Y-m-d', $time));
$xml = $curl_helper->Send($source_file);
+ if ( !$curl_helper->isGoodResponseCode() || strlen($xml) == 0 ) {
+ continue;
+ }
+
$xml_parser = xml_parser_create();
xml_parse_into_struct($xml_parser, $xml, $struct, $index);
foreach($struct as $element)

Event Timeline