Skip to content

Commit 7017a1c

Browse files
committed
Update URL Command: Added revisions table support
For #5292 Added test to cover.
1 parent 8120278 commit 7017a1c

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

app/Console/Commands/UpdateUrlCommand.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function handle(Connection $db): int
4949
'chapters' => ['description_html'],
5050
'books' => ['description_html'],
5151
'bookshelves' => ['description_html'],
52+
'page_revisions' => ['html', 'text', 'markdown'],
5253
'images' => ['url'],
5354
'settings' => ['value'],
5455
'comments' => ['html', 'text'],
@@ -77,6 +78,12 @@ public function handle(Connection $db): int
7778
$this->info('URL update procedure complete.');
7879
$this->info('============================================================================');
7980
$this->info('Be sure to run "php artisan cache:clear" to clear any old URLs in the cache.');
81+
82+
if (!str_starts_with($newUrl, url('/'))) {
83+
$this->warn('You still need to update your APP_URL env value. This is currently set to:');
84+
$this->warn(url('/'));
85+
}
86+
8087
$this->info('============================================================================');
8188

8289
return 0;

tests/Commands/UpdateUrlCommandTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,26 @@ public function test_command_updates_array_settings()
8787
$this->assertEquals('a https://cats.example.com/donkey/cat url', $settingVal[0]['name']);
8888
}
8989

90+
public function test_command_updates_page_revisions()
91+
{
92+
$page = $this->entities->page();
93+
94+
for ($i = 0; $i < 2; $i++) {
95+
$this->entities->updatePage($page, [
96+
'name' => $page->name,
97+
'markdown' => "[A link {$i}](https://example.com/donkey/cat)"
98+
]);
99+
}
100+
101+
$this->runUpdate('https://example.com', 'https://cats.example.com');
102+
setting()->flushCache();
103+
104+
$this->assertDatabaseHas('page_revisions', [
105+
'markdown' => '[A link 1](https://cats.example.com/donkey/cat)',
106+
'html' => '<p id="bkmrk-a-link-1"><a href="https://cats.example.com/donkey/cat">A link 1</a></p>' . "\n"
107+
]);
108+
}
109+
90110
protected function runUpdate(string $oldUrl, string $newUrl)
91111
{
92112
$this->artisan("bookstack:update-url {$oldUrl} {$newUrl}")

0 commit comments

Comments
 (0)