NOW MANAGED ON CODEBERG
Addressed a range of deprecation warnings
Dan Brown78ebcb6f38ee
diff --git a/app/Entities/Tools/Markdown/MarkdownToHtml.php b/app/Entities/Tools/Markdown/MarkdownToHtml.phpindex 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.phpindex 8c793a109..54ed95ebb 100644--- a/app/Search/SearchIndex.php+++ b/app/Search/SearchIndex.php@@ -112,12 +112,12 @@ class SearchIndex** @returns array<string, int>*/- 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.phpindex f9ab666ac..227ec8e0b 100644--- a/app/Util/CspService.php+++ b/app/Util/CspService.php@@ -126,7 +126,7 @@ class CspServiceprotected 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.phpindex 8d5c77e09..8b9c529f2 100644--- a/database/factories/Actions/TagFactory.php+++ b/database/factories/Actions/TagFactory.php@@ -21,7 +21,7 @@ class TagFactory extends Factorypublic 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.phpindex 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.phpindex 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.phpindex 0613800a1..3bf157786 100644--- a/database/factories/Entities/Models/BookFactory.php+++ b/database/factories/Entities/Models/BookFactory.php@@ -22,9 +22,9 @@ class BookFactory extends Factorypublic 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.phpindex 4fcd69c39..36379866e 100644--- a/database/factories/Entities/Models/ChapterFactory.php+++ b/database/factories/Entities/Models/ChapterFactory.php@@ -22,9 +22,9 @@ class ChapterFactory extends Factorypublic 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.phpindex 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 = '<p>' . implode('</p>', $this->faker->paragraphs(5)) . '</p>';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.phpindex c6d0e0801..b66c0a52c 100644--- a/database/factories/Uploads/ImageFactory.php+++ b/database/factories/Uploads/ImageFactory.php@@ -21,9 +21,9 @@ class ImageFactory extends Factorypublic 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.mdindex 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 bOnce 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 StandardsPHP 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.phpindex 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') <span>{!! nl2br(htmlentities(session()->get('success'))) !!}</span><div class="dismiss">@icon('close')</div>+ @icon('check-circle') <span>@if(session()->has('success')){!! nl2br(htmlentities(session()->get('success'))) !!}@endif</span><div class="dismiss">@icon('close')</div></div><div component="notification"@@ -15,7 +15,7 @@style="display: none;"class="notification warning"role="alert">- @icon('info') <span>{!! nl2br(htmlentities(session()->get('warning'))) !!}</span><div class="dismiss">@icon('close')</div>+ @icon('info') <span>@if(session()->has('warning')){!! nl2br(htmlentities(session()->get('warning'))) !!}@endif</span><div class="dismiss">@icon('close')</div></div><div component="notification"@@ -25,5 +25,5 @@style="display: none;"class="notification neg"role="alert">- @icon('danger') <span>{!! nl2br(htmlentities(session()->get('error'))) !!}</span><div class="dismiss">@icon('close')</div>+ @icon('danger') <span>@if(session()->has('error')){!! nl2br(htmlentities(session()->get('error'))) !!}@endif</span><div class="dismiss">@icon('close')</div></div>\ No newline at end of filediff --git a/resources/views/exports/parts/meta.blade.php b/resources/views/exports/parts/meta.blade.phpindex 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 ?? ''),]) !!}<br>@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 ?? '')]) !!}</div>\ No newline at end of filediff --git a/resources/views/pages/parts/revisions-index-row.blade.php b/resources/views/pages/parts/revisions-index-row.blade.phpindex 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<br><div class="text-muted">- <small>{{ $revision->created_at->formatLocalized('%e %B %Y %H:%M:%S') }}</small>+ <small>{{ $revision->created_at->isoFormat('D MMMM Y HH:mm:ss') }}</small><small>({{ $revision->created_at->diffForHumans() }})</small></div></div>diff --git a/tests/Entity/ExportTest.php b/tests/Entity/ExportTest.phpindex 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.phpindex 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 = 'abc123<script>console.log("hello-test")</script>abc123';$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 = '<p onmouseenter="console.log(\'test\')">Hello</p>';$page->html = "escape {$script}";diff --git a/tests/TestCase.php b/tests/TestCase.phpindex 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();}/**