[MediaWiki-commits] [Gerrit] wikimedia...vendor[master]: Update Amazon SDK
Ejegg has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/402889 ) Change subject: Update Amazon SDK .. Update Amazon SDK Change-Id: If3cf11e0883d512e1bd817797bb4b6c62961d6db --- A amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/ArrayUtil.php M amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php M amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php M amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/PaymentsClient.php M amzn/login-and-pay-with-amazon-sdk-php/composer.json M composer/installed.json 6 files changed, 90 insertions(+), 72 deletions(-) Approvals: Ejegg: Verified; Looks good to me, approved diff --git a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/ArrayUtil.php b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/ArrayUtil.php new file mode 100644 index 000..4285620 --- /dev/null +++ b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/ArrayUtil.php @@ -0,0 +1,18 @@ + $value) +{ +if(!is_null($value) && !is_array($value) && $key!=='proxy_password') +{ +$array[$key] = trim($value); +} +} +return $array; +} +} diff --git a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php index 899ae49..9ede9f2 100644 --- a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php +++ b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php @@ -1,5 +1,7 @@ null, 'proxy_password' => null, 'client_id'=> null, - 'handle_throttle' => true + 'handle_throttle' => true, +'logger'=> null ); protected $modePath = null; @@ -81,6 +90,17 @@ $this->checkConfigKeys($configArray); } else { throw new \Exception('$config is of the incorrect type ' . gettype($configArray) . ' and should be of the type array'); +} +if (empty($configArray['logger'])) { +$this->logger = new NullLogger(); +} else { +if ($configArray['logger'] instanceof LoggerInterface) { +$this->logger = $configArray['logger']; +} else { +throw new \InvalidArgumentException( +'Logger passed in config must implement Psr\Log\LoggerInterface' +); +} } } else { throw new \Exception('$config cannot be null.'); @@ -127,7 +147,7 @@ private function checkConfigKeys($config) { $config = array_change_key_case($config, CASE_LOWER); - $config = $this->trimArray($config); + $config = ArrayUtil::trimArray($config); foreach ($config as $key => $value) { if (array_key_exists($key, $this->config)) { @@ -245,20 +265,6 @@ public function getParameters() { return trim($this->parameters); -} - -/* Trim the input Array key values */ - -protected function trimArray($array) -{ - foreach ($array as $key => $value) - { - if(!is_array($value) && $key!=='proxy_password') - { - $array[$key] = trim($value); - } - } - return $array; } /* setParametersAndPost - sets the parameters array with non empty values from the requestParameters array sent to API calls. @@ -560,6 +566,7 @@ $this->pauseOnRetry(++$retries, $statusCode); } } else { +$this->logger->info("Returned status code $statusCode, not retrying."); $shouldRetry = false; } } catch (\Exception $e) { @@ -582,6 +589,7 @@ { if ($retries <= self::MAX_ERROR_RETRY) { $delay = (int) (pow(4, $retries) * $this->basePause); +$this->logger->info("Returned status code $status on try $retries, waiting $delay microseconds."); usleep($delay); } else { throw new \Exception('Error Code: '. $status.PHP_EOL.'Maximum number of retry attempts - '. $retries .' reached'); diff --git a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php index 2514af1..94318a0 100644 --- a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php +++ b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php @@ -5,9 +5,10 @@ * Takes headers and body of the IPN message as input in the constructor * verifies that the IPN is from the right resource and has the
[MediaWiki-commits] [Gerrit] wikimedia...vendor[master]: Update Amazon SDK
Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/402889 ) Change subject: Update Amazon SDK .. Update Amazon SDK Change-Id: If3cf11e0883d512e1bd817797bb4b6c62961d6db --- A amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/ArrayUtil.php M amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php M amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php M amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/PaymentsClient.php M amzn/login-and-pay-with-amazon-sdk-php/composer.json M composer/installed.json 6 files changed, 90 insertions(+), 72 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/SmashPig/vendor refs/changes/89/402889/1 diff --git a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/ArrayUtil.php b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/ArrayUtil.php new file mode 100644 index 000..4285620 --- /dev/null +++ b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/ArrayUtil.php @@ -0,0 +1,18 @@ + $value) +{ +if(!is_null($value) && !is_array($value) && $key!=='proxy_password') +{ +$array[$key] = trim($value); +} +} +return $array; +} +} diff --git a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php index 899ae49..9ede9f2 100644 --- a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php +++ b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/BaseClient.php @@ -1,5 +1,7 @@ null, 'proxy_password' => null, 'client_id'=> null, - 'handle_throttle' => true + 'handle_throttle' => true, +'logger'=> null ); protected $modePath = null; @@ -81,6 +90,17 @@ $this->checkConfigKeys($configArray); } else { throw new \Exception('$config is of the incorrect type ' . gettype($configArray) . ' and should be of the type array'); +} +if (empty($configArray['logger'])) { +$this->logger = new NullLogger(); +} else { +if ($configArray['logger'] instanceof LoggerInterface) { +$this->logger = $configArray['logger']; +} else { +throw new \InvalidArgumentException( +'Logger passed in config must implement Psr\Log\LoggerInterface' +); +} } } else { throw new \Exception('$config cannot be null.'); @@ -127,7 +147,7 @@ private function checkConfigKeys($config) { $config = array_change_key_case($config, CASE_LOWER); - $config = $this->trimArray($config); + $config = ArrayUtil::trimArray($config); foreach ($config as $key => $value) { if (array_key_exists($key, $this->config)) { @@ -245,20 +265,6 @@ public function getParameters() { return trim($this->parameters); -} - -/* Trim the input Array key values */ - -protected function trimArray($array) -{ - foreach ($array as $key => $value) - { - if(!is_array($value) && $key!=='proxy_password') - { - $array[$key] = trim($value); - } - } - return $array; } /* setParametersAndPost - sets the parameters array with non empty values from the requestParameters array sent to API calls. @@ -560,6 +566,7 @@ $this->pauseOnRetry(++$retries, $statusCode); } } else { +$this->logger->info("Returned status code $statusCode, not retrying."); $shouldRetry = false; } } catch (\Exception $e) { @@ -582,6 +589,7 @@ { if ($retries <= self::MAX_ERROR_RETRY) { $delay = (int) (pow(4, $retries) * $this->basePause); +$this->logger->info("Returned status code $status on try $retries, waiting $delay microseconds."); usleep($delay); } else { throw new \Exception('Error Code: '. $status.PHP_EOL.'Maximum number of retry attempts - '. $retries .' reached'); diff --git a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php index 2514af1..94318a0 100644 --- a/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php +++ b/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon/IpnHandler.php @@ -5,9 +5,10 @@ * Takes headers and body of the IPN message as input in the constructor * verifies that the