Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit fa2b73b

Browse files
committed
Merge branch 'release/v2.5.0'
2 parents 18b32f7 + b480ff4 commit fa2b73b

File tree

169 files changed

+5635
-928
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+5635
-928
lines changed

.travis.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ dist: trusty
22
sudo: false
33
language: php
44
php:
5-
- 7.0
6-
- 5.6
7-
- 7.1
5+
- 7.0.31
6+
- 5.6.37
7+
- 7.1.18
88
- 7.2
99
- hhvm
1010
- nightly
@@ -31,17 +31,17 @@ before_install:
3131
before_script:
3232
- composer config -g github-oauth.github.com $GITHUB_OAUTH_TOKEN
3333
- if [ $GUZZLE == '5' ] ; then ./set_guzzle5.sh; fi
34-
- if [ $PHP != 'nightly' ] && [ $PHP != '7.1' ]; then composer global require hirak/prestissimo; fi
3534
- if [ $GUZZLE == '5' ] ; then composer update -o --prefer-dist --prefer-lowest; fi
3635
- if [ $GUZZLE != '5' ] ; then composer install -o --prefer-dist; fi
3736
script:
38-
- if [ $PHP == '7.1' ] && [ $GUZZLE == '6' ]; then ant phpcs-ci; fi
39-
- if [ $GUZZLE == '5' ] || [ $PHP == '5.6' ] || [ $PHP == 'hhvm' ] ; then vendor/bin/phpunit -c phpunit5.xml.dist --testsuite=unit; fi
40-
- if [ $GUZZLE == '6' ] && [ $PHP != '5.6' ] ; then vendor/bin/phpunit --testsuite=unit; fi
41-
- if [ $PHP == '7.0' ] && [ $GUZZLE == '6' ] && [ $TRAVIS_PULL_REQUEST == 'false' ]; then vendor/bin/phpunit --testsuite=integration; fi
37+
- if [ $PHP == '7.1.18' ] && [ $GUZZLE == '6' ]; then ant phpcs-ci; fi
38+
- if [ $GUZZLE == '5' ] || [ $PHP == '5.6.37' ] || [ $PHP == 'hhvm' ] ; then vendor/bin/phpunit -c phpunit5.xml.dist --testsuite=unit; fi
39+
- if [ $GUZZLE == '6' ] && [ $PHP != '5.6.37' ] ; then vendor/bin/phpunit --testsuite=unit; fi
40+
- if [ $PHP == '7.0.31' ] && [ $GUZZLE == '6' ] && [ $TRAVIS_PULL_REQUEST == 'false' ]; then vendor/bin/phpunit --testsuite=integration; fi
4241
- ant behat
42+
- bin/ctp-tlscheck.php
4343
before_deploy:
44-
- if [ $(phpenv version-name) = "7.1" ] ; then ant apigen; fi
44+
- if [ $(phpenv version-name) = "7.1.18" ] ; then ant apigen; fi
4545
deploy:
4646
- provider: script
4747
skip_cleanup: true

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
<a name="2.5.0"></a>
2+
# [2.5.0](https://github.com/commercetools/commercetools-php-sdk/compare/v2.4.0...v2.5.0) (2018-08-16)
3+
4+
5+
### Features
6+
7+
* **Cart:** support multiple shipping addresses ([20014da](https://github.com/commercetools/commercetools-php-sdk/commit/20014da))
8+
* **Extension:** support API extensions ([9ca58c8](https://github.com/commercetools/commercetools-php-sdk/commit/9ca58c8)), closes [#365](https://github.com/commercetools/commercetools-php-sdk/issues/365)
9+
* **Money:** support high precision money ([95722b9](https://github.com/commercetools/commercetools-php-sdk/commit/95722b9)), closes [#410](https://github.com/commercetools/commercetools-php-sdk/issues/410)
10+
* **Order:** support multiple shipping addresses ([d98c259](https://github.com/commercetools/commercetools-php-sdk/commit/d98c259))
11+
* **OrderFromCart:** support state, orderState, shipmentState at OrderCreateFromCart ([5fd4375](https://github.com/commercetools/commercetools-php-sdk/commit/5fd4375)), closes [#412](https://github.com/commercetools/commercetools-php-sdk/issues/412) [#417](https://github.com/commercetools/commercetools-php-sdk/issues/417)
12+
* **ProductDiscount:** add setValidFromAndUntil update action ([1e54656](https://github.com/commercetools/commercetools-php-sdk/commit/1e54656))
13+
* **ProductDiscounts:** add endpoint for Matching ProductDiscount ([9258a62](https://github.com/commercetools/commercetools-php-sdk/commit/9258a62))
14+
* **Request:** add GDPR dataErasure flag ([5d35ea1](https://github.com/commercetools/commercetools-php-sdk/commit/5d35ea1)), closes [#411](https://github.com/commercetools/commercetools-php-sdk/issues/411)
15+
* **ShoppingList:** support AnonymousId on ShoppingList owner ([efd2565](https://github.com/commercetools/commercetools-php-sdk/commit/efd2565))
16+
* **Subscription:** add Google Cloud PubSub destination ([585501a](https://github.com/commercetools/commercetools-php-sdk/commit/585501a)), closes [#418](https://github.com/commercetools/commercetools-php-sdk/issues/418)
17+
* **Subscription:** add modifiedAt to change subscription payloads ([602303a](https://github.com/commercetools/commercetools-php-sdk/commit/602303a)), closes [#416](https://github.com/commercetools/commercetools-php-sdk/issues/416)
18+
* **Subscription:** add payloadNotIncluded to message delivery ([60e207b](https://github.com/commercetools/commercetools-php-sdk/commit/60e207b)), closes [#413](https://github.com/commercetools/commercetools-php-sdk/issues/413)
19+
20+
21+
122
<a name="2.4.0"></a>
223
# [2.4.0](https://github.com/commercetools/commercetools-php-sdk/compare/v2.3.0...v2.4.0) (2018-05-31)
324

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ Please read the [Changelog](CHANGELOG.md) before updating in any case.
6262

6363
### Getting started
6464

65-
To get up and running, [create a free test project](http://admin.sphere.io) on the commercetools platform with API credentials (Menu "Developers"->"API Clients").
65+
To get up and running, create a free test project ([EU located](https://admin.commercetools.com/en/signup) or [US located](https://admin.commercetools.co/en/signup)) on the commercetools platform. To generate your API credentials go to [EU Merchant Center](https://mc.commercetools.com/) or [US Merchant Center](https://mc.commercetools.co/) (Menu "Settings"->"Developer Settings"->"API Clients"->"Create New Api Client").
66+
You need to select the template for the "Admin client".
6667

6768
```php
6869
<?php
@@ -104,6 +105,18 @@ foreach ($products as $product) {
104105

105106
```
106107

108+
If you prefer not to have a client with all admin rights, you need to explicitly include the client's permission scopes that you selected when creating the client, on the client's configuration:
109+
110+
```php
111+
<?php
112+
$config = [
113+
'client_id' => 'my client id',
114+
'client_secret' => 'my client secret',
115+
'project' => 'my project id',
116+
'scope' => 'permission_scope and_another_scope'
117+
];
118+
```
119+
107120
In real world, you will not put your API credentials directly into code but use a config file or your framework's config or dependency injection system for that.
108121

109122
#### Using the phar distribution
@@ -118,8 +131,8 @@ require __DIR__ . '/commercetools-php-sdk.phar';
118131

119132
$config = \Commercetools\Core\Config::fromArray([
120133
'client_id' => 'myClientId',
121-
'client_secret' => 'myClientSecret',
122-
'project' => 'myProjectId'
134+
'client_secret' => 'myClientSecret',
135+
'project' => 'myProjectId'
123136
]);
124137
$client = \Commercetools\Core\Client::ofConfig($config);
125138
$request = \Commercetools\Core\Request\Project\ProjectGetRequest::of();

bin/ctp-tlscheck.php

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
class Tls12Checker
5+
{
6+
const API_URI = 'api-tls12.commercetools.com';
7+
8+
const URIS = [
9+
'auth-tls12.commercetools.com',
10+
'api-tls12.commercetools.com',
11+
'auth-tls12.commercetools.co',
12+
'api-tls12.commercetools.co',
13+
'api.sphere.io',
14+
'api.commercetools.co',
15+
];
16+
17+
public function allowedCiphers()
18+
{
19+
return [
20+
'TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA',
21+
'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256',
22+
'TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA',
23+
'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384',
24+
'TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256',
25+
'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA',
26+
'TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256',
27+
'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA',
28+
'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384',
29+
'TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256',
30+
];
31+
}
32+
33+
/**
34+
* @return array
35+
* @throws \Exception
36+
*/
37+
private function getSupportedCiphers()
38+
{
39+
$ch = curl_init();
40+
curl_setopt($ch, CURLOPT_URL, "https://www.howsmyssl.com/a/check");
41+
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
42+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
43+
$response = curl_exec($ch);
44+
curl_close($ch);
45+
$tlsInfo = json_decode($response, true);
46+
47+
if ($response === false) {
48+
throw new \Exception('Connection not connect using TLS 1.2', 1);
49+
}
50+
51+
return isset($tlsInfo['given_cipher_suites']) ? $tlsInfo['given_cipher_suites'] : [];
52+
}
53+
54+
/**
55+
* @throws \Exception
56+
*/
57+
private function checkCiphers()
58+
{
59+
$supportedCiphers = $this->getSupportedCiphers();
60+
$allowedCiphers = $this->allowedCiphers();
61+
62+
$diff = array_diff($allowedCiphers, $supportedCiphers);
63+
64+
if (count($diff) < count($allowedCiphers)) {
65+
return;
66+
};
67+
throw new \Exception('None of the allowed cipher suites are supported by curl: ' . implode(', ', $allowedCiphers), 1);
68+
}
69+
70+
/**
71+
* @param string $apiUri
72+
* @param string $cipher
73+
* @throws Exception
74+
*/
75+
private function checkApiConnection($apiUri = self::API_URI, $cipher = null)
76+
{
77+
$ch = curl_init();
78+
curl_setopt($ch, CURLOPT_URL, 'https://' . $apiUri);
79+
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
80+
if (!is_null($cipher)) {
81+
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, $cipher);
82+
}
83+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
84+
$response = curl_exec($ch);
85+
curl_close($ch);
86+
87+
if ($response == false) {
88+
throw new \Exception('Could not connect not connect to API using TLS 1.2' . (is_null($cipher) ? '' : ' with cipher ' . $cipher), 1);
89+
}
90+
}
91+
92+
private function checkCurlVersion()
93+
{
94+
$curlVersion = curl_version();
95+
$supportsTLS12 = true;
96+
if (version_compare(curl_version()['version'], '7.34.0', '<')) {
97+
$supportsTLS12 = false;
98+
}
99+
echo 'Curl version: ' . ($supportsTLS12 ? "\033[32m" : "\033[31m") . curl_version()['version'] . "\033[0m" . ($supportsTLS12 ? '' : '(TLS 1.2 not supported)') . PHP_EOL;
100+
101+
if (isset($curlVersion['ssl_version'])) {
102+
echo 'Curl SSL Library: ' . curl_version()['ssl_version'] . PHP_EOL;
103+
}
104+
}
105+
106+
/**
107+
* @return int
108+
*/
109+
public function check()
110+
{
111+
$this->checkCurlVersion();
112+
113+
echo "Checking TLS 1.2 connection ... ";
114+
try {
115+
$this->checkCiphers();
116+
foreach (self::URIS as $uri) {
117+
$this->checkApiConnection($uri);
118+
}
119+
} catch (\Exception $exception) {
120+
echo "\033[31mFailed\033[0m" . PHP_EOL;
121+
echo $exception->getMessage() . PHP_EOL;
122+
return (int)$exception->getCode();
123+
}
124+
125+
echo "\033[32mOK\033[0m" . PHP_EOL;
126+
127+
return 0;
128+
}
129+
130+
// private function availableCiphers()
131+
// {
132+
// $localCiphers = explode(' ', exec('openssl ciphers \'ALL:eNULL\' | tr \':\' \' \''));
133+
// $allowedCiphers = [];
134+
// foreach ($localCiphers as $localCipher) {
135+
// exec('echo -n | openssl s_client -connect ' . self::API_URI . ':443 -cipher ' . $localCipher . ' -tls1_2 2>&1', $dummy, $status);
136+
// if ($status === 0) {
137+
// $allowedCiphers[] = $localCipher;
138+
// }
139+
// }
140+
//
141+
// return $allowedCiphers;
142+
// }
143+
//
144+
// private function checkAvailableCiphers()
145+
// {
146+
// $availableCiphers = $this->availableCiphers();
147+
// foreach ($availableCiphers as $cipher) {
148+
// echo 'Testing ' . $cipher . '...';
149+
// try {
150+
// $this->checkApiConnection(self::API_URI, $cipher);
151+
// echo "\033[32mOK\033[0m" . PHP_EOL;
152+
// } catch (\Exception $exception) {
153+
// echo "\033[31mFailed\033[0m" . PHP_EOL;
154+
// }
155+
// }
156+
// }
157+
}
158+
159+
$checker = new Tls12Checker();
160+
exit($checker->check());

build.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<exec executable="${toolsdir}phpcs${execPostfix}" failonerror="true">
6565
<arg value="--standard=PSR2" />
6666
<arg value="--extensions=php" />
67-
<arg value="--ignore=autoload.php" />
67+
<arg value="--ignore=autoload.php,src/Core/Builder" />
6868
<arg path="${basedir}/src" />
6969
<arg path="${basedir}/tests" />
7070
</exec>
@@ -76,7 +76,7 @@
7676
<exec executable="${toolsdir}phpcs${execPostfix}" failonerror="true">
7777
<arg value="--standard=PSR2" />
7878
<arg value="--extensions=php" />
79-
<arg value="--ignore=autoload.php" />
79+
<arg value="--ignore=autoload.php,src/Core/Builder" />
8080
<arg path="${basedir}/src" />
8181
</exec>
8282
</target>

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"require": {
3131
"php": ">=5.6",
3232
"psr/log": "^1.0",
33-
"guzzlehttp/guzzle": "^6.0 || ^5.3.1",
33+
"guzzlehttp/guzzle": "^6.0 || ^5.3.3",
3434
"guzzlehttp/psr7": "^1.1",
3535
"psr/cache": "^1.0",
3636
"psr/simple-cache": "^1.0",
@@ -59,6 +59,9 @@
5959
"replaces": {
6060
"commercetools/commons": "*"
6161
},
62+
"bin": [
63+
"bin/ctp-tlscheck.php"
64+
],
6265
"suggest": {
6366
"cache/redis-adapter": "For usage of a redis server to store the client access token",
6467
"cache/doctrine-adapter": "For usage of a doctrine cache instance to store the client access token"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "commercetools-php-sdk-changelog",
3-
"version": "2.4.0",
3+
"version": "2.6.0",
44
"description": "commercetools PHP SDK changelog generator package description",
55
"homepage": "https://github.com/commercetools/commercetools-php-sdk",
66
"bugs": "https://github.com/commercetools/commercetools-php-sdk/issues",

set_guzzle5.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22
SRC='"guzzlehttp/guzzle": "^6.0"'
3-
DST='"guzzlehttp/guzzle": "^5.3.1", "react/promise": "^2.2.0"'
3+
DST='"guzzlehttp/guzzle": "^5.3.3", "react/promise": "^2.2.0"'
44
sed -ibak -e "s|$SRC|$DST|g" composer.json

src/Core/AbstractHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
abstract class AbstractHttpClient
1616
{
17-
const VERSION = '2.4.0';
17+
const VERSION = '2.5.0';
1818

1919
/**
2020
* @var AdapterInterface

0 commit comments

Comments
 (0)