Skip to content

Commit

Permalink
Merge pull request #191 from ably/feature/upgrade-protocol-2.0
Browse files Browse the repository at this point in the history
Support protocol 2.0 and php 8.3
  • Loading branch information
sacOO7 authored Mar 21, 2024
2 parents 09aad4b + 03b7019 commit 563a84f
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: [7.2, 7.3, 7.4, 8.0, 8.1, 8.2]
php-version: [7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3]
protocol: [ 'json', 'msgpack' ]
ignorePlatformReq: [ '' ]

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This is a PHP REST client library for Ably. The library currently targets the [A

## Supported Platforms

This SDK supports PHP 7.2+, 8.0, 8.1 and 8.2
This SDK supports PHP >=7.2

We regression-test the library against a selection of PHP versions (which will change over time, but usually consists of the versions that are supported upstream). Please refer to [the check workflow](.github/workflows/check.yml) for the set of versions that currently undergo CI testing.

Expand Down
2 changes: 1 addition & 1 deletion ably-common
Submodule ably-common updated 51 files
+19 −0 .editorconfig
+25 −0 .eslintrc.js
+44 −0 .github/workflows/check.yml
+33 −0 .github/workflows/publish-json-schemas.yml
+38 −0 .github/workflows/publish.yml
+4 −0 .gitignore
+9 −0 .markdownlint-cli2.yaml
+2 −0 .tool-versions
+45 −0 CONTRIBUTING.md
+1 −0 COPYRIGHT
+176 −0 LICENSE
+6 −0 MAINTAINERS.md
+34 −0 README.md
+3 −0 go.mod
+110 −0 go/cmd/ablyagent/main.go
+36 −0 json-schemas/README.md
+69 −0 json-schemas/publish.js
+852 −0 json-schemas/src/account-stats.json
+42 −0 json-schemas/src/agents.json
+806 −0 json-schemas/src/app-stats.json
+157 −0 json-schemas/src/attachments.json
+31 −0 json-schemas/src/channel-lifecycle.json
+104 −0 json-schemas/src/client-events-api-requests.json
+207 −0 json-schemas/src/client-events-connections.json
+118 −0 json-schemas/src/epoch.json
+10 −0 json-schemas/versions.json
+29 −0 network/README.md
+935 −0 network/aws-edge-locations.json
+8 −0 network/datacenter-locations.csv
+13,776 −0 package-lock.json
+33 −0 package.json
+1 −0 protocol/.ruby-version
+7 −0 protocol/Gemfile
+28 −0 protocol/Gemfile.lock
+158 −1 protocol/README.md
+30 −0 protocol/Rakefile
+372 −0 protocol/agents.json
+179 −146 protocol/errors.json
+86 −23 protocol/errorsHelp.json
+33 −0 scripts/build-go.sh
+55 −0 scripts/publish-go.sh
+6 −0 templates/README.md
+20 −0 templates/sdk-contributing.md
+94 −0 templates/sdk-readme.md
+8 −0 test-resources/README.md
+910 −0 test-resources/crypto-data-256.json
+20 −20 test-resources/messages-encoding.json
+75 −0 test-resources/msgpack_test_fixtures.json
+40 −0 test-resources/presence-messages-encoding.json
+21 −5 test-resources/test-app-setup.json
+18 −0 test/agents.test.js
2 changes: 1 addition & 1 deletion src/Defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Ably;

class Defaults {
const API_VERSION = '1.1';
const API_VERSION = '2';
const LIB_VERSION = '1.1.9';

static $restHost = "rest.ably.io";
Expand Down
14 changes: 7 additions & 7 deletions src/Models/BaseMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,6 @@ function( $obj ) use ($cipherParams) { return static::fromEncoded($obj, $cipherP
protected function encode() {
$msg = new \stdClass();

if ($this->encoding) {
$msg->encoding = $this->encoding;
$msg->data = $this->data;

return $msg;
}

if ($this->id) {
$msg->id = $this->id;
}
Expand All @@ -170,6 +163,13 @@ protected function encode() {
$msg->extras = $this->extras;
}

if ($this->encoding) {
$msg->encoding = $this->encoding;
$msg->data = $this->data;

return $msg;
}

$isBinary = false;
$encodings = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Models/ClientOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ClientOptions extends AuthOptions {
/**
* @var bool defaults to false for clients with version < 1.2, otherwise true
*/
public $idempotentRestPublishing = Defaults::API_VERSION >= '1.2';
public $idempotentRestPublishing = true;

/**
* @var string a class that should be used for Auth
Expand Down
4 changes: 2 additions & 2 deletions tests/AblyRestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,10 @@ public function testHttpTimeout() {
'httpRequestTimeout' => 20, // 20 ms
]);

$ably->http->get('https://cdn.ably.io/lib/ably.js'); // should work
$ably->http->get('https://rest.ably.io/time'); // should work
$this->expectException(AblyRequestException::class);
$this->expectExceptionCode(50003);
$ablyTimeout->http->get('https://cdn.ably.io/lib/ably.js'); // guaranteed to take more than 20 ms
$ablyTimeout->http->get('https://rest.ably.io/time'); // guaranteed to take more than 20 ms
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public function testCreateTokenRequestValidity() {

$this->assertFalse( $ably->auth->isUsingBasicAuth(), 'Expected token auth to be used' );
$this->assertLessThan(
200,
300,
abs($timestamp - $ably->auth->getTokenDetails()->issued),
'Expected token issued timestamp to be near to the time of request (allowing for clock skew)'
);
Expand Down
6 changes: 2 additions & 4 deletions tests/PushAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ public function testAdminPublish() {
];
$data = [ 'data' => [ 'foo' => 'bar' ] ];

$res = self::$ably->push->admin->publish( $recipient, $data , true );
$this->assertNull($res);
sleep(3); // It takes some time for the message to show up in the history

self::$ably->push->admin->publish( $recipient, $data , true );
sleep(5); // It takes some time for the message to show up in the history
$channel = self::$ably->channel($channelName);
$history = $channel->history();
$this->assertEquals( 1, count($history->items), 'Expected 1 message' );
Expand Down

0 comments on commit 563a84f

Please sign in to comment.