diff --git a/app/config/platforms.php b/app/config/platforms.php index 8f47d44df6..348aa18cb4 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -217,7 +217,7 @@ return [ [ 'key' => 'php', 'name' => 'PHP', - 'version' => '2.3.0', + 'version' => '2.3.1', 'url' => 'https://github.com/appwrite/sdk-for-php', 'package' => 'https://packagist.org/packages/appwrite/appwrite', 'enabled' => true, diff --git a/app/controllers/general.php b/app/controllers/general.php index b23b51cb65..30eb1ff8d6 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -42,7 +42,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $consoleDB if (empty($domain->get()) || !$domain->isKnown() || $domain->isTest()) { $domains[$domain->get()] = false; Console::warning($domain->get() . ' is not a publicly accessible domain. Skipping SSL certificate generation.'); - } elseif(str_ends_with($request->getURI(), '/.well-known/acme-challenge')) { + } elseif(str_starts_with($request->getURI(), '/.well-known/acme-challenge')) { Console::warning('Skipping SSL certificates generation on ACME challenge.'); } else { Authorization::disable(); diff --git a/app/realtime.php b/app/realtime.php index 9112810e7c..40537ea615 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -110,8 +110,8 @@ $server->onStart(function () use ($stats, $register, $containerId, &$documentId) continue; } - $connections = $value['connections']; - $messages = $value['messages']; + $connections = $stats->get($projectId, 'connections'); + $messages = $stats->get($projectId, 'messages'); $usage = new Event('v1-usage', 'UsageV1'); $usage @@ -129,11 +129,13 @@ $server->onStart(function () use ($stats, $register, $containerId, &$documentId) if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { $usage->trigger(); } + + unset($usage, $connections, $messages); } $payload = []; foreach ($stats as $projectId => $value) { if (!empty($value['connectionsTotal'])) { - $payload[$projectId] = $value['connectionsTotal']; + $payload[$projectId] = $stats->get($projectId, 'connectionsTotal'); } } if (empty($payload)) { @@ -210,7 +212,7 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats, $event = [ 'project' => 'console', - 'roles' => ['team:' . $value['teamId']], + 'roles' => ['team:' . $stats->get($projectId, 'teamId')], 'data' => [ 'event' => 'stats.connections', 'channels' => ['project'], diff --git a/app/workers/functions.php b/app/workers/functions.php index 1acde1f62a..8020581e0e 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -482,7 +482,7 @@ class FunctionsV1 extends Worker $exitCode = 0; try { - $exitCode = (int)!$orchestration->execute( + $exitCode = (int) !$orchestration->execute( name: $container, command: $orchestration->parseCommandString($command), stdout: $stdout, @@ -509,8 +509,8 @@ class FunctionsV1 extends Worker 'tagId' => $tag->getId(), 'status' => $functionStatus, 'exitCode' => $exitCode, - 'stdout' => \mb_substr($stdout, -4000), // log last 4000 chars output - 'stderr' => \mb_substr($stderr, -4000), // log last 4000 chars output + 'stdout' => \utf8_encode(\mb_substr($stdout, -4000)), // log last 4000 chars output + 'stderr' => \utf8_encode(\mb_substr($stderr, -4000)), // log last 4000 chars output 'time' => $executionTime ])); @@ -535,11 +535,11 @@ class FunctionsV1 extends Worker $target = Realtime::fromPayload('functions.executions.update', $execution); Realtime::send( - $projectId, - $execution->getArrayCopy(), - 'functions.executions.update', - $target['channels'], - $target['roles'] + projectId: $projectId, + payload: $execution->getArrayCopy(), + event: 'functions.executions.update', + channels: $target['channels'], + roles: $target['roles'] ); $usage = new Event('v1-usage', 'UsageV1'); @@ -551,8 +551,7 @@ class FunctionsV1 extends Worker ->setParam('functionStatus', $functionStatus) ->setParam('functionExecutionTime', $executionTime * 1000) // ms ->setParam('networkRequestSize', 0) - ->setParam('networkResponseSize', 0) - ; + ->setParam('networkResponseSize', 0); if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { $usage->trigger(); diff --git a/composer.json b/composer.json index bae61c40c9..3ca194945f 100644 --- a/composer.json +++ b/composer.json @@ -64,7 +64,7 @@ "slickdeals/statsd": "3.1.0" }, "require-dev": { - "appwrite/sdk-generator": "0.14.3", + "appwrite/sdk-generator": "0.14.4", "phpunit/phpunit": "9.5.6", "swoole/ide-helper": "4.6.7", "textalk/websocket": "1.5.2", diff --git a/composer.lock b/composer.lock index 8c4e16206c..f991ded4f1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "432285e325d8c4b39da4f8d5d00d2b03", + "content-hash": "82b47392837605b4fb552e5c9374c4cc", "packages": [ { "name": "adhocore/jwt", @@ -248,16 +248,16 @@ }, { "name": "chillerlan/php-settings-container", - "version": "2.1.1", + "version": "2.1.2", "source": { "type": "git", "url": "https://github.com/chillerlan/php-settings-container.git", - "reference": "98ccc1b31b31a53bcb563465c4961879b2b93096" + "reference": "ec834493a88682dd69652a1eeaf462789ed0c5f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/98ccc1b31b31a53bcb563465c4961879b2b93096", - "reference": "98ccc1b31b31a53bcb563465c4961879b2b93096", + "url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/ec834493a88682dd69652a1eeaf462789ed0c5f5", + "reference": "ec834493a88682dd69652a1eeaf462789ed0c5f5", "shasum": "" }, "require": { @@ -307,7 +307,7 @@ "type": "ko_fi" } ], - "time": "2021-01-06T15:57:03+00:00" + "time": "2021-09-06T15:17:01+00:00" }, { "name": "colinmollenhour/credis", @@ -2516,16 +2516,16 @@ }, { "name": "appwrite/sdk-generator", - "version": "0.14.3", + "version": "0.14.4", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "a1075a59db33fe2bba9e648bf67b3ece1debcfa4" + "reference": "b89a51170f99e6977df72c46522c7d931257bc28" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/a1075a59db33fe2bba9e648bf67b3ece1debcfa4", - "reference": "a1075a59db33fe2bba9e648bf67b3ece1debcfa4", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/b89a51170f99e6977df72c46522c7d931257bc28", + "reference": "b89a51170f99e6977df72c46522c7d931257bc28", "shasum": "" }, "require": { @@ -2559,9 +2559,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/0.14.3" + "source": "https://github.com/appwrite/sdk-generator/tree/0.14.4" }, - "time": "2021-09-06T09:32:51+00:00" + "time": "2021-09-07T13:23:19+00:00" }, { "name": "composer/package-versions-deprecated", diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index e14a35d934..4534508b9b 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -326,6 +326,7 @@ class FunctionsCustomServerTest extends Scope $this->assertStringContainsString('http', $execution['body']['stdout']); $this->assertStringContainsString('PHP', $execution['body']['stdout']); $this->assertStringContainsString('8.0', $execution['body']['stdout']); + $this->assertStringContainsString('êä', $execution['body']['stdout']); // tests unknown utf-8 chars $this->assertEquals('', $execution['body']['stderr']); $this->assertGreaterThan(0.05, $execution['body']['time']); $this->assertLessThan(0.500, $execution['body']['time']); diff --git a/tests/resources/functions/package-php.sh b/tests/resources/functions/package-php.sh old mode 100644 new mode 100755 diff --git a/tests/resources/functions/php.tar.gz b/tests/resources/functions/php.tar.gz index 0f29ac9a96..13a9512301 100644 Binary files a/tests/resources/functions/php.tar.gz and b/tests/resources/functions/php.tar.gz differ diff --git a/tests/resources/functions/php/index.php b/tests/resources/functions/php/index.php index 663c9b4d95..86dcea3802 100644 --- a/tests/resources/functions/php/index.php +++ b/tests/resources/functions/php/index.php @@ -25,4 +25,6 @@ echo $_ENV['APPWRITE_FUNCTION_RUNTIME_NAME']."\n"; echo $_ENV['APPWRITE_FUNCTION_RUNTIME_VERSION']."\n"; // echo $result['$id']; echo $_ENV['APPWRITE_FUNCTION_EVENT']."\n"; -echo $_ENV['APPWRITE_FUNCTION_EVENT_DATA']."\n"; \ No newline at end of file +echo $_ENV['APPWRITE_FUNCTION_EVENT_DATA']."\n"; +// Test unknwon UTF-8 chars +echo "\xEA\xE4\n"; \ No newline at end of file