diff --git a/app/workers/functions.php b/app/workers/functions.php index 1acde1f62..8020581e0 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/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index e14a35d93..4534508b9 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 0f29ac9a9..13a951230 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 663c9b4d9..86dcea380 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