]> BookStack Code Mirror - bookstack/commitdiff
Fixed issues found from tests
authorDan Brown <redacted>
Mon, 6 Feb 2023 20:41:33 +0000 (20:41 +0000)
committerDan Brown <redacted>
Mon, 6 Feb 2023 20:41:33 +0000 (20:41 +0000)
app/Exceptions/BookStackExceptionHandlerPage.php [moved from app/Exceptions/WhoopsBookStackPrettyHandler.php with 62% similarity]
app/Exceptions/Handler.php
app/Providers/AppServiceProvider.php
app/Uploads/ImageService.php
composer.json
composer.lock
tests/Entity/BookTest.php
tests/LanguageTest.php
tests/ThemeTest.php

similarity index 62%
rename from app/Exceptions/WhoopsBookStackPrettyHandler.php
rename to app/Exceptions/BookStackExceptionHandlerPage.php
index dcf50fa8e465e07d36180bfb38b42028402c97e2..78f586ad0c98d0f930a5c7f78882dbcfcdf5f614 100644 (file)
@@ -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)
index 9667944d4a4e330fe9621b9d042061f679653478..f2672cf5778a11e13046be41ca99a65a66ca2ae3 100644 (file)
@@ -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;
         }
index d0841059b992e186c499293c391f33b188a3f4bc..5d36d2c46a5479ad1df2999cf5de03926b1847e9 100644 (file)
@@ -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,
     ];
 
     /**
index a217287fd324d55b9f28e500839d3506f6d6dc9a..1d04582c094ef910cef05a33098ddda9819293a0 100644 (file)
@@ -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;
     }
 
     /**
index af3bce71993c1388ed3b2960675619bb1c74b74d..d6bb4e3e947d4d2bd4d88e126d85b217e856227d 100644 (file)
@@ -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",
index 34ff2e013764f5fdb278175c8159b7091845e415..8f883679c6fd55c6ccc92268b95ca11b6f6cb7b5 100644 (file)
@@ -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",
         },
         {
             "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": {
             "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",
         },
         {
             "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": {
             ],
             "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": [
                 {
                     "type": "github"
                 }
             ],
-            "time": "2023-01-15T23:15:59+00:00"
+            "time": "2022-08-10T22:54:19+00:00"
         },
         {
             "name": "dasprid/enum",
             ],
             "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",
         },
         {
             "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"
                 "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": {
             ],
             "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": [
                 {
                     "type": "tidelift"
                 }
             ],
-            "time": "2023-01-28T17:00:47+00:00"
+            "time": "2023-01-12T18:13:24+00:00"
         },
         {
             "name": "robrichards/xmlseclibs",
             },
             "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",
         }
     ],
     "aliases": [],
-    "minimum-stability": "dev",
+    "minimum-stability": "stable",
     "stability-flags": [],
     "prefer-stable": true,
     "prefer-lowest": false,
index 8435c534f5f76e46847921a635845bfa43f37e78..f124a1690e4fae57f554a35ff74349ee93a80c0c 100644 (file)
@@ -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é?',
index ba522a74e380c5de371899011500e703e83189d9..e5c3c0bff83f40b1ce04e2ac74d256ad32cbbff1 100644 (file)
@@ -12,7 +12,7 @@ class LanguageTest extends TestCase
     protected 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 TestCase
 
     public 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;
index ee4f20f3084ce3ece8f34c98d2535b28051da954..03ae7b307d4d594bb93e93934487185108e9c50a 100644 (file)
@@ -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;