diff --git a/app/Entities/Tools/Markdown/MarkdownToHtml.php b/app/Entities/Tools/Markdown/MarkdownToHtml.php index f3cf7ab2f..06587ce1f 100644 --- a/app/Entities/Tools/Markdown/MarkdownToHtml.php +++ b/app/Entities/Tools/Markdown/MarkdownToHtml.php @@ -5,10 +5,10 @@ namespace BookStack\Entities\Tools\Markdown; use BookStack\Facades\Theme; use BookStack\Theming\ThemeEvents; use League\CommonMark\Block\Element\ListItem; -use League\CommonMark\CommonMarkConverter; use League\CommonMark\Environment; use League\CommonMark\Extension\Table\TableExtension; use League\CommonMark\Extension\TaskList\TaskListExtension; +use League\CommonMark\MarkdownConverter; class MarkdownToHtml { @@ -26,7 +26,7 @@ class MarkdownToHtml $environment->addExtension(new TaskListExtension()); $environment->addExtension(new CustomStrikeThroughExtension()); $environment = Theme::dispatch(ThemeEvents::COMMONMARK_ENVIRONMENT_CONFIGURE, $environment) ?? $environment; - $converter = new CommonMarkConverter([], $environment); + $converter = new MarkdownConverter($environment); $environment->addBlockRenderer(ListItem::class, new CustomListItemRenderer(), 10); diff --git a/app/Search/SearchIndex.php b/app/Search/SearchIndex.php index 8c793a109..54ed95ebb 100644 --- a/app/Search/SearchIndex.php +++ b/app/Search/SearchIndex.php @@ -112,12 +112,12 @@ class SearchIndex * * @returns array */ - protected function generateTermScoreMapFromText(string $text, int $scoreAdjustment = 1): array + protected function generateTermScoreMapFromText(string $text, float $scoreAdjustment = 1): array { $termMap = $this->textToTermCountMap($text); foreach ($termMap as $term => $count) { - $termMap[$term] = $count * $scoreAdjustment; + $termMap[$term] = floor($count * $scoreAdjustment); } return $termMap; diff --git a/app/Util/CspService.php b/app/Util/CspService.php index f9ab666ac..227ec8e0b 100644 --- a/app/Util/CspService.php +++ b/app/Util/CspService.php @@ -126,7 +126,7 @@ class CspService protected function getAllowedIframeHosts(): array { - $hosts = config('app.iframe_hosts', ''); + $hosts = config('app.iframe_hosts') ?? ''; return array_filter(explode(' ', $hosts)); } diff --git a/database/factories/Actions/TagFactory.php b/database/factories/Actions/TagFactory.php index 8d5c77e09..8b9c529f2 100644 --- a/database/factories/Actions/TagFactory.php +++ b/database/factories/Actions/TagFactory.php @@ -21,7 +21,7 @@ class TagFactory extends Factory public function definition() { return [ - 'name' => $this->faker->city, + 'name' => $this->faker->city(), 'value' => $this->faker->sentence(3), ]; } diff --git a/database/factories/Actions/WebhookFactory.php b/database/factories/Actions/WebhookFactory.php index 662f64f8b..c7393b32c 100644 --- a/database/factories/Actions/WebhookFactory.php +++ b/database/factories/Actions/WebhookFactory.php @@ -18,7 +18,7 @@ class WebhookFactory extends Factory { return [ 'name' => 'My webhook for ' . $this->faker->country(), - 'endpoint' => $this->faker->url, + 'endpoint' => $this->faker->url(), 'active' => true, 'timeout' => 3, ]; diff --git a/database/factories/Auth/UserFactory.php b/database/factories/Auth/UserFactory.php index 805782fd8..6ff62a975 100644 --- a/database/factories/Auth/UserFactory.php +++ b/database/factories/Auth/UserFactory.php @@ -22,11 +22,11 @@ class UserFactory extends Factory */ public function definition() { - $name = $this->faker->name; + $name = $this->faker->name(); return [ 'name' => $name, - 'email' => $this->faker->email, + 'email' => $this->faker->email(), 'slug' => Str::slug($name . '-' . Str::random(5)), 'password' => Str::random(10), 'remember_token' => Str::random(10), diff --git a/database/factories/Entities/Models/BookFactory.php b/database/factories/Entities/Models/BookFactory.php index 0613800a1..3bf157786 100644 --- a/database/factories/Entities/Models/BookFactory.php +++ b/database/factories/Entities/Models/BookFactory.php @@ -22,9 +22,9 @@ class BookFactory extends Factory public function definition() { return [ - 'name' => $this->faker->sentence, + 'name' => $this->faker->sentence(), 'slug' => Str::random(10), - 'description' => $this->faker->paragraph, + 'description' => $this->faker->paragraph(), ]; } } diff --git a/database/factories/Entities/Models/ChapterFactory.php b/database/factories/Entities/Models/ChapterFactory.php index 4fcd69c39..36379866e 100644 --- a/database/factories/Entities/Models/ChapterFactory.php +++ b/database/factories/Entities/Models/ChapterFactory.php @@ -22,9 +22,9 @@ class ChapterFactory extends Factory public function definition() { return [ - 'name' => $this->faker->sentence, + 'name' => $this->faker->sentence(), 'slug' => Str::random(10), - 'description' => $this->faker->paragraph, + 'description' => $this->faker->paragraph(), ]; } } diff --git a/database/factories/Entities/Models/PageFactory.php b/database/factories/Entities/Models/PageFactory.php index c83e0f828..319d97880 100644 --- a/database/factories/Entities/Models/PageFactory.php +++ b/database/factories/Entities/Models/PageFactory.php @@ -24,7 +24,7 @@ class PageFactory extends Factory $html = '

' . implode('

', $this->faker->paragraphs(5)) . '

'; return [ - 'name' => $this->faker->sentence, + 'name' => $this->faker->sentence(), 'slug' => Str::random(10), 'html' => $html, 'text' => strip_tags($html), diff --git a/database/factories/Uploads/ImageFactory.php b/database/factories/Uploads/ImageFactory.php index c6d0e0801..b66c0a52c 100644 --- a/database/factories/Uploads/ImageFactory.php +++ b/database/factories/Uploads/ImageFactory.php @@ -21,9 +21,9 @@ class ImageFactory extends Factory public function definition() { return [ - 'name' => $this->faker->slug . '.jpg', - 'url' => $this->faker->url, - 'path' => $this->faker->url, + 'name' => $this->faker->slug() . '.jpg', + 'url' => $this->faker->url(), + 'path' => $this->faker->url(), 'type' => 'gallery', 'uploaded_to' => 0, ]; diff --git a/dev/docs/development.md b/dev/docs/development.md index 1611de578..b68f2664a 100644 --- a/dev/docs/development.md +++ b/dev/docs/development.md @@ -29,6 +29,8 @@ The testing database will also need migrating and seeding beforehand. This can b Once done you can run `composer test` in the application root directory to run all tests. Tests can be ran in parallel by running them via `composer t`. This will use Laravel's built-in parallel testing functionality, and attempt to create and seed a database instance for each testing thread. If required these parallel testing instances can be reset, before testing again, by running `composer t-reset`. +If the codebase needs to be tested with deprecations, this can be done via uncommenting the relevant line within the TestCase@setUp function. + ## Code Standards PHP code standards are managed by [using PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer). diff --git a/resources/views/common/notifications.blade.php b/resources/views/common/notifications.blade.php index e06bd5fd1..8b76a8dd5 100644 --- a/resources/views/common/notifications.blade.php +++ b/resources/views/common/notifications.blade.php @@ -5,7 +5,7 @@ style="display: none;" class="notification pos" role="alert"> - @icon('check-circle') {!! nl2br(htmlentities(session()->get('success'))) !!}
@icon('close')
+ @icon('check-circle') @if(session()->has('success')){!! nl2br(htmlentities(session()->get('success'))) !!}@endif
@icon('close')
\ No newline at end of file diff --git a/resources/views/exports/parts/meta.blade.php b/resources/views/exports/parts/meta.blade.php index 02a39e78c..d4128898b 100644 --- a/resources/views/exports/parts/meta.blade.php +++ b/resources/views/exports/parts/meta.blade.php @@ -4,13 +4,13 @@ @endif @icon('star'){!! trans('entities.meta_created' . ($entity->createdBy ? '_name' : ''), [ - 'timeLength' => $entity->created_at->formatLocalized('%e %B %Y %H:%M:%S'), + 'timeLength' => $entity->created_at->isoFormat('D MMMM Y HH:mm:ss'), 'user' => e($entity->createdBy->name ?? ''), ]) !!}
@icon('edit'){!! trans('entities.meta_updated' . ($entity->updatedBy ? '_name' : ''), [ - 'timeLength' => $entity->updated_at->formatLocalized('%e %B %Y %H:%M:%S'), + 'timeLength' => $entity->updated_at->isoFormat('D MMMM Y HH:mm:ss'), 'user' => e($entity->updatedBy->name ?? '') ]) !!} \ No newline at end of file diff --git a/resources/views/pages/parts/revisions-index-row.blade.php b/resources/views/pages/parts/revisions-index-row.blade.php index 597b53234..fdc6a772d 100644 --- a/resources/views/pages/parts/revisions-index-row.blade.php +++ b/resources/views/pages/parts/revisions-index-row.blade.php @@ -17,7 +17,7 @@ @if($revision->createdBy) {{ $revision->createdBy->name }} @else {{ trans('common.deleted_user') }} @endif
- {{ $revision->created_at->formatLocalized('%e %B %Y %H:%M:%S') }} + {{ $revision->created_at->isoFormat('D MMMM Y HH:mm:ss') }} ({{ $revision->created_at->diffForHumans() }})
diff --git a/tests/Entity/ExportTest.php b/tests/Entity/ExportTest.php index 0f80bdd49..68c70e6c0 100644 --- a/tests/Entity/ExportTest.php +++ b/tests/Entity/ExportTest.php @@ -160,9 +160,9 @@ class ExportTest extends TestCase $page = $this->entities->page(); $resp = $this->asEditor()->get($page->getUrl('/export/html')); - $resp->assertSee($page->created_at->formatLocalized('%e %B %Y %H:%M:%S')); + $resp->assertSee($page->created_at->isoFormat('D MMMM Y HH:mm:ss')); $resp->assertDontSee($page->created_at->diffForHumans()); - $resp->assertSee($page->updated_at->formatLocalized('%e %B %Y %H:%M:%S')); + $resp->assertSee($page->updated_at->isoFormat('D MMMM Y HH:mm:ss')); $resp->assertDontSee($page->updated_at->diffForHumans()); } diff --git a/tests/Entity/PageContentTest.php b/tests/Entity/PageContentTest.php index 0c9854206..53107d14d 100644 --- a/tests/Entity/PageContentTest.php +++ b/tests/Entity/PageContentTest.php @@ -310,7 +310,7 @@ class PageContentTest extends TestCase { $this->asEditor(); $page = $this->entities->page(); - config()->push('app.allow_content_scripts', 'true'); + config()->set('app.allow_content_scripts', 'true'); $script = 'abc123abc123'; $page->html = "no escape {$script}"; @@ -355,7 +355,7 @@ class PageContentTest extends TestCase { $this->asEditor(); $page = $this->entities->page(); - config()->push('app.allow_content_scripts', 'true'); + config()->set('app.allow_content_scripts', 'true'); $script = '

Hello

'; $page->html = "escape {$script}"; diff --git a/tests/TestCase.php b/tests/TestCase.php index d0dd7d772..d9a614fc6 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -43,6 +43,10 @@ abstract class TestCase extends BaseTestCase { $this->entities = new EntityProvider(); parent::setUp(); + + // We can uncomment the below to run tests with failings upon deprecations. + // Can't leave on since some deprecations can only be fixed upstream. + // $this->withoutDeprecationHandling(); } /**