From a03104d61da61e82b5dcda8681dbfaa8615a9f04 Mon Sep 17 00:00:00 2001 From: Sami Mazouz Date: Fri, 21 Jun 2024 10:25:02 +0100 Subject: [PATCH] fix --- framework/core/src/Api/Serializer.php | 2 +- framework/core/src/Frontend/Compiler/LessCompiler.php | 10 +++++++--- .../tests/integration/api/discussions/CreateTest.php | 4 +++- .../core/tests/integration/api/posts/CreateTest.php | 4 +++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/framework/core/src/Api/Serializer.php b/framework/core/src/Api/Serializer.php index 72b1d8e6d..96308d9ae 100644 --- a/framework/core/src/Api/Serializer.php +++ b/framework/core/src/Api/Serializer.php @@ -192,7 +192,7 @@ class Serializer extends \Tobyz\JsonApiServer\Serializer $deferred = $this->deferred; /** @var Closure $resolve */ - while ($resolve = $deferred->shift()) { + while (($resolve = $deferred->shift()) && is_callable($resolve)) { $resolve(); } diff --git a/framework/core/src/Frontend/Compiler/LessCompiler.php b/framework/core/src/Frontend/Compiler/LessCompiler.php index 381fc2b5e..10e8750c5 100644 --- a/framework/core/src/Frontend/Compiler/LessCompiler.php +++ b/framework/core/src/Frontend/Compiler/LessCompiler.php @@ -12,7 +12,9 @@ namespace Flarum\Frontend\Compiler; use Flarum\Frontend\Compiler\Source\FileSource; use Illuminate\Support\Collection; use Illuminate\Support\Str; +use Less_FileManager; use Less_Parser; +use Less_Tree_Import; /** * @internal @@ -129,8 +131,10 @@ class LessCompiler extends RevisionCompiler ]; })->unique('path'); - return function ($evald) use ($baseSources): ?array { - $relativeImportPath = Str::of($evald->PathAndUri()[0])->split('/\/less\//'); + return function (Less_Tree_Import $evald) use ($baseSources): ?array { + $pathAndUri = Less_FileManager::getFilePath($evald->getPath(), $evald->currentFileInfo); + + $relativeImportPath = Str::of($pathAndUri[0])->split('/\/less\//'); $extensionId = $baseSources->where('path', $relativeImportPath->first())->pluck('extensionId')->first(); $overrideImport = $this->lessImportOverrides @@ -141,7 +145,7 @@ class LessCompiler extends RevisionCompiler return null; } - return [$overrideImport['newFilePath'], $evald->PathAndUri()[1]]; + return [$overrideImport['newFilePath'], $pathAndUri[1]]; }; } diff --git a/framework/core/tests/integration/api/discussions/CreateTest.php b/framework/core/tests/integration/api/discussions/CreateTest.php index e9d8c5f14..06cbc4e64 100644 --- a/framework/core/tests/integration/api/discussions/CreateTest.php +++ b/framework/core/tests/integration/api/discussions/CreateTest.php @@ -209,7 +209,7 @@ class CreateTest extends TestCase */ public function discussion_creation_limited_by_throttler() { - $this->send( + $response = $this->send( $this->request('POST', '/api/discussions', [ 'authenticatedAs' => 2, 'json' => [ @@ -224,6 +224,8 @@ class CreateTest extends TestCase ]) ); + $this->assertEquals(201, $response->getStatusCode()); + $response = $this->send( $this->request('POST', '/api/discussions', [ 'authenticatedAs' => 2, diff --git a/framework/core/tests/integration/api/posts/CreateTest.php b/framework/core/tests/integration/api/posts/CreateTest.php index d5db5b995..75079074a 100644 --- a/framework/core/tests/integration/api/posts/CreateTest.php +++ b/framework/core/tests/integration/api/posts/CreateTest.php @@ -104,7 +104,7 @@ class CreateTest extends TestCase */ public function limited_by_throttler() { - $this->send( + $response = $this->send( $this->request('POST', '/api/posts', [ 'authenticatedAs' => 2, 'json' => [ @@ -121,6 +121,8 @@ class CreateTest extends TestCase ]) ); + $this->assertEquals(201, $response->getStatusCode(), (string) $response->getBody()); + $response = $this->send( $this->request('POST', '/api/posts', [ 'authenticatedAs' => 2,