NOW MANAGED ON CODEBERG
Fixed issues found from tests
Dan Brown5e8ec56196f9
diff --git a/app/Exceptions/WhoopsBookStackPrettyHandler.php b/app/Exceptions/BookStackExceptionHandlerPage.phpsimilarity index 62%rename from app/Exceptions/WhoopsBookStackPrettyHandler.phprename to app/Exceptions/BookStackExceptionHandlerPage.phpindex dcf50fa8e..78f586ad0 100644--- a/app/Exceptions/WhoopsBookStackPrettyHandler.php+++ b/app/Exceptions/BookStackExceptionHandlerPage.php@@ -2,25 +2,18 @@namespace BookStack\Exceptions;-use Whoops\Handler\Handler;+use Illuminate\Contracts\Foundation\ExceptionRenderer;-class WhoopsBookStackPrettyHandler extends Handler+class BookStackExceptionHandlerPage implements ExceptionRenderer{- /**- * @return int|null A handler may return nothing, or a Handler::HANDLE_* constant- */- public function handle()+ public function render($throwable){- $exception = $this->getException();-- echo view('errors.debug', [- 'error' => $exception->getMessage(),- 'errorClass' => get_class($exception),- 'trace' => $exception->getTraceAsString(),+ return view('errors.debug', [+ 'error' => $throwable->getMessage(),+ 'errorClass' => get_class($throwable),+ 'trace' => $throwable->getTraceAsString(),'environment' => $this->getEnvironment(),])->render();-- return Handler::QUIT;}protected function safeReturn(callable $callback, $default = null)diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.phpindex 9667944d4..f2672cf57 100644--- a/app/Exceptions/Handler.php+++ b/app/Exceptions/Handler.php@@ -98,6 +98,7 @@ class Handler extends ExceptionHandler];if ($e instanceof ValidationException) {+ $responseData['error']['message'] = 'The given data was invalid.';$responseData['error']['validation'] = $e->errors();$code = $e->status;}diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.phpindex d0841059b..5d36d2c46 100644--- a/app/Providers/AppServiceProvider.php+++ b/app/Providers/AppServiceProvider.php@@ -8,16 +8,16 @@ use BookStack\Entities\Models\Book;use BookStack\Entities\Models\Bookshelf;use BookStack\Entities\Models\Chapter;use BookStack\Entities\Models\Page;-use BookStack\Exceptions\WhoopsBookStackPrettyHandler;+use BookStack\Exceptions\BookStackExceptionHandlerPage;use BookStack\Settings\SettingService;use BookStack\Util\CspService;use GuzzleHttp\Client;+use Illuminate\Contracts\Foundation\ExceptionRenderer;use Illuminate\Database\Eloquent\Relations\Relation;use Illuminate\Support\Facades\Schema;use Illuminate\Support\Facades\URL;use Illuminate\Support\ServiceProvider;use Psr\Http\Client\ClientInterface as HttpClientInterface;-use Whoops\Handler\HandlerInterface;class AppServiceProvider extends ServiceProvider{@@ -26,7 +26,7 @@ class AppServiceProvider extends ServiceProvider* @var string[]*/public $bindings = [- HandlerInterface::class => WhoopsBookStackPrettyHandler::class,+ ExceptionRenderer::class => BookStackExceptionHandlerPage::class,];/**diff --git a/app/Uploads/ImageService.php b/app/Uploads/ImageService.phpindex a217287fd..1d04582c0 100644--- a/app/Uploads/ImageService.php+++ b/app/Uploads/ImageService.php@@ -547,7 +547,7 @@ class ImageService// Check the image file exists&& $disk->exists($imagePath)// Check the file is likely an image file- && strpos($disk->getMimetype($imagePath), 'image/') === 0;+ && strpos($disk->mimeType($imagePath), 'image/') === 0;}/**diff --git a/composer.json b/composer.jsonindex af3bce719..d6bb4e3e9 100644--- a/composer.json+++ b/composer.json@@ -20,7 +20,6 @@"barryvdh/laravel-dompdf": "^2.0","barryvdh/laravel-snappy": "^1.0","doctrine/dbal": "^3.5",- "filp/whoops": "^2.14","guzzlehttp/guzzle": "^7.4","intervention/image": "^2.7","laravel/framework": "^9.0",diff --git a/composer.lock b/composer.lockindex 34ff2e013..8f883679c 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": "58fa6b9181b7c117b88fdd2f1ae379b4",+ "content-hash": "7049e76ef5eed4fe73d86bb4ecb0db6a","packages": [{"name": "aws/aws-crt-php",@@ -58,16 +58,16 @@},{"name": "aws/aws-sdk-php",- "version": "3.258.3",+ "version": "3.258.4","source": {"type": "git","url": "https://github.com/aws/aws-sdk-php.git",- "reference": "57cbc06827148d0d4d3f5dbe4b948daa20f82d70"+ "reference": "c20d674f502ed96ed0de63e9da087eb5f0e95590"},"dist": {"type": "zip",- "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/57cbc06827148d0d4d3f5dbe4b948daa20f82d70",- "reference": "57cbc06827148d0d4d3f5dbe4b948daa20f82d70",+ "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/c20d674f502ed96ed0de63e9da087eb5f0e95590",+ "reference": "c20d674f502ed96ed0de63e9da087eb5f0e95590","shasum": ""},"require": {@@ -146,9 +146,9 @@"support": {"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80","issues": "https://github.com/aws/aws-sdk-php/issues",- "source": "https://github.com/aws/aws-sdk-php/tree/3.258.3"+ "source": "https://github.com/aws/aws-sdk-php/tree/3.258.4"},- "time": "2023-02-03T19:25:20+00:00"+ "time": "2023-02-06T19:28:40+00:00"},{"name": "bacon/bacon-qr-code",@@ -361,25 +361,26 @@},{"name": "brick/math",- "version": "0.11.0",+ "version": "0.10.2","source": {"type": "git","url": "https://github.com/brick/math.git",- "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478"+ "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f"},"dist": {"type": "zip",- "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478",- "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478",+ "url": "https://api.github.com/repos/brick/math/zipball/459f2781e1a08d52ee56b0b1444086e038561e3f",+ "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f","shasum": ""},"require": {- "php": "^8.0"+ "ext-json": "*",+ "php": "^7.4 || ^8.0"},"require-dev": {"php-coveralls/php-coveralls": "^2.2","phpunit/phpunit": "^9.0",- "vimeo/psalm": "5.0.0"+ "vimeo/psalm": "4.25.0"},"type": "library","autoload": {@@ -404,7 +405,7 @@],"support": {"issues": "https://github.com/brick/math/issues",- "source": "https://github.com/brick/math/tree/0.11.0"+ "source": "https://github.com/brick/math/tree/0.10.2"},"funding": [{@@ -412,7 +413,7 @@"type": "github"}],- "time": "2023-01-15T23:15:59+00:00"+ "time": "2022-08-10T22:54:19+00:00"},{"name": "dasprid/enum",@@ -1234,77 +1235,6 @@],"time": "2023-01-02T17:26:14+00:00"},- {- "name": "filp/whoops",- "version": "2.14.6",- "source": {- "type": "git",- "url": "https://github.com/filp/whoops.git",- "reference": "f7948baaa0330277c729714910336383286305da"- },- "dist": {- "type": "zip",- "url": "https://api.github.com/repos/filp/whoops/zipball/f7948baaa0330277c729714910336383286305da",- "reference": "f7948baaa0330277c729714910336383286305da",- "shasum": ""- },- "require": {- "php": "^5.5.9 || ^7.0 || ^8.0",- "psr/log": "^1.0.1 || ^2.0 || ^3.0"- },- "require-dev": {- "mockery/mockery": "^0.9 || ^1.0",- "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.3",- "symfony/var-dumper": "^2.6 || ^3.0 || ^4.0 || ^5.0"- },- "suggest": {- "symfony/var-dumper": "Pretty print complex values better with var-dumper available",- "whoops/soap": "Formats errors as SOAP responses"- },- "type": "library",- "extra": {- "branch-alias": {- "dev-master": "2.7-dev"- }- },- "autoload": {- "psr-4": {- "Whoops\\": "src/Whoops/"- }- },- "notification-url": "https://packagist.org/downloads/",- "license": [- "MIT"- ],- "authors": [- {- "name": "Filipe Dobreira",- "homepage": "https://github.com/filp",- "role": "Developer"- }- ],- "description": "php error handling for cool kids",- "homepage": "https://filp.github.io/whoops/",- "keywords": [- "error",- "exception",- "handling",- "library",- "throwable",- "whoops"- ],- "support": {- "issues": "https://github.com/filp/whoops/issues",- "source": "https://github.com/filp/whoops/tree/2.14.6"- },- "funding": [- {- "url": "https://github.com/denis-sokolov",- "type": "github"- }- ],- "time": "2022-11-02T16:23:29+00:00"- },{"name": "fruitcake/php-cors","version": "v1.2.0",@@ -4768,20 +4698,20 @@},{"name": "ramsey/uuid",- "version": "4.x-dev",+ "version": "4.7.3","source": {"type": "git","url": "https://github.com/ramsey/uuid.git",- "reference": "25c4faac19549ebfcd3a6a73732dddeb188eaf5a"+ "reference": "433b2014e3979047db08a17a205f410ba3869cf2"},"dist": {"type": "zip",- "url": "https://api.github.com/repos/ramsey/uuid/zipball/25c4faac19549ebfcd3a6a73732dddeb188eaf5a",- "reference": "25c4faac19549ebfcd3a6a73732dddeb188eaf5a",+ "url": "https://api.github.com/repos/ramsey/uuid/zipball/433b2014e3979047db08a17a205f410ba3869cf2",+ "reference": "433b2014e3979047db08a17a205f410ba3869cf2","shasum": ""},"require": {- "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11",+ "brick/math": "^0.8.8 || ^0.9 || ^0.10","ext-json": "*","php": "^8.0","ramsey/collection": "^1.2 || ^2.0"@@ -4818,7 +4748,6 @@"paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter","ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type."},- "default-branch": true,"type": "library","extra": {"captainhook": {@@ -4845,7 +4774,7 @@],"support": {"issues": "https://github.com/ramsey/uuid/issues",- "source": "https://github.com/ramsey/uuid/tree/4.x"+ "source": "https://github.com/ramsey/uuid/tree/4.7.3"},"funding": [{@@ -4857,7 +4786,7 @@"type": "tidelift"}],- "time": "2023-01-28T17:00:47+00:00"+ "time": "2023-01-12T18:13:24+00:00"},{"name": "robrichards/xmlseclibs",@@ -8013,6 +7942,77 @@},"time": "2022-12-13T13:54:32+00:00"},+ {+ "name": "filp/whoops",+ "version": "2.14.6",+ "source": {+ "type": "git",+ "url": "https://github.com/filp/whoops.git",+ "reference": "f7948baaa0330277c729714910336383286305da"+ },+ "dist": {+ "type": "zip",+ "url": "https://api.github.com/repos/filp/whoops/zipball/f7948baaa0330277c729714910336383286305da",+ "reference": "f7948baaa0330277c729714910336383286305da",+ "shasum": ""+ },+ "require": {+ "php": "^5.5.9 || ^7.0 || ^8.0",+ "psr/log": "^1.0.1 || ^2.0 || ^3.0"+ },+ "require-dev": {+ "mockery/mockery": "^0.9 || ^1.0",+ "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.3",+ "symfony/var-dumper": "^2.6 || ^3.0 || ^4.0 || ^5.0"+ },+ "suggest": {+ "symfony/var-dumper": "Pretty print complex values better with var-dumper available",+ "whoops/soap": "Formats errors as SOAP responses"+ },+ "type": "library",+ "extra": {+ "branch-alias": {+ "dev-master": "2.7-dev"+ }+ },+ "autoload": {+ "psr-4": {+ "Whoops\\": "src/Whoops/"+ }+ },+ "notification-url": "https://packagist.org/downloads/",+ "license": [+ "MIT"+ ],+ "authors": [+ {+ "name": "Filipe Dobreira",+ "homepage": "https://github.com/filp",+ "role": "Developer"+ }+ ],+ "description": "php error handling for cool kids",+ "homepage": "https://filp.github.io/whoops/",+ "keywords": [+ "error",+ "exception",+ "handling",+ "library",+ "throwable",+ "whoops"+ ],+ "support": {+ "issues": "https://github.com/filp/whoops/issues",+ "source": "https://github.com/filp/whoops/tree/2.14.6"+ },+ "funding": [+ {+ "url": "https://github.com/denis-sokolov",+ "type": "github"+ }+ ],+ "time": "2022-11-02T16:23:29+00:00"+ },{"name": "hamcrest/hamcrest-php","version": "v2.0.1",@@ -10325,7 +10325,7 @@}],"aliases": [],- "minimum-stability": "dev",+ "minimum-stability": "stable","stability-flags": [],"prefer-stable": true,"prefer-lowest": false,diff --git a/tests/Entity/BookTest.php b/tests/Entity/BookTest.phpindex 8435c534f..f124a1690 100644--- a/tests/Entity/BookTest.php+++ b/tests/Entity/BookTest.php@@ -247,7 +247,7 @@ class BookTest extends TestCase'name' => 'информация',]);- $this->assertEquals('informaciya', $book->slug);+ $this->assertEquals('informaciia', $book->slug);$book = $this->entities->newBook(['name' => '¿Qué?',diff --git a/tests/LanguageTest.php b/tests/LanguageTest.phpindex ba522a74e..e5c3c0bff 100644--- a/tests/LanguageTest.php+++ b/tests/LanguageTest.php@@ -12,7 +12,7 @@ class LanguageTest extends TestCaseprotected function setUp(): void{parent::setUp();- $this->langs = array_diff(scandir(resource_path('lang')), ['..', '.']);+ $this->langs = array_diff(scandir(lang_path('')), ['..', '.']);}public function test_locales_config_key_set_properly()@@ -58,7 +58,7 @@ class LanguageTest extends TestCasepublic function test_all_lang_files_loadable(){- $files = array_diff(scandir(resource_path('lang/en')), ['..', '.']);+ $files = array_diff(scandir(lang_path('en')), ['..', '.']);foreach ($this->langs as $lang) {foreach ($files as $file) {$loadError = false;diff --git a/tests/ThemeTest.php b/tests/ThemeTest.phpindex ee4f20f30..03ae7b307 100644--- a/tests/ThemeTest.php+++ b/tests/ThemeTest.php@@ -19,6 +19,7 @@ use Illuminate\Support\Facades\Artisan;use Illuminate\Support\Facades\File;use Illuminate\Support\Facades\Http;use League\CommonMark\ConfigurableEnvironmentInterface;+use League\CommonMark\Environment\Environment;class ThemeTest extends TestCase{@@ -57,7 +58,7 @@ class ThemeTest extends TestCase{$callbackCalled = false;$callback = function ($environment) use (&$callbackCalled) {- $this->assertInstanceOf(ConfigurableEnvironmentInterface::class, $environment);+ $this->assertInstanceOf(Environment::class, $environment);$callbackCalled = true;return $environment;