mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
Added regenerate-references command test
Also updated model resolvers to only fetch model ID, to prevent bringing back way more data from database than desired.
This commit is contained in:
@ -19,7 +19,7 @@ class BookLinkModelResolver implements CrossLinkModelResolver
|
||||
$bookSlug = $matches[1];
|
||||
|
||||
/** @var ?Book $model */
|
||||
$model = Book::query()->where('slug', '=', $bookSlug)->first();
|
||||
$model = Book::query()->where('slug', '=', $bookSlug)->first(['id']);
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class BookshelfLinkModelResolver implements CrossLinkModelResolver
|
||||
$shelfSlug = $matches[1];
|
||||
|
||||
/** @var ?Bookshelf $model */
|
||||
$model = Bookshelf::query()->where('slug', '=', $shelfSlug)->first();
|
||||
$model = Bookshelf::query()->where('slug', '=', $shelfSlug)->first(['id']);
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class ChapterLinkModelResolver implements CrossLinkModelResolver
|
||||
$chapterSlug = $matches[2];
|
||||
|
||||
/** @var ?Chapter $model */
|
||||
$model = Chapter::query()->whereSlugs($bookSlug, $chapterSlug)->first();
|
||||
$model = Chapter::query()->whereSlugs($bookSlug, $chapterSlug)->first(['id']);
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class PageLinkModelResolver implements CrossLinkModelResolver
|
||||
$pageSlug = $matches[2];
|
||||
|
||||
/** @var ?Page $model */
|
||||
$model = Page::query()->whereSlugs($bookSlug, $pageSlug)->first();
|
||||
$model = Page::query()->whereSlugs($bookSlug, $pageSlug)->first(['id']);
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class PagePermalinkModelResolver implements CrossLinkModelResolver
|
||||
|
||||
$id = intval($matches[1]);
|
||||
/** @var ?Page $model */
|
||||
$model = Page::query()->find($id);
|
||||
$model = Page::query()->find($id, ['id']);
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class ReferenceService
|
||||
{
|
||||
Reference::query()
|
||||
->where('from_type', '=', (new Page())->getMorphClass())
|
||||
->truncate();
|
||||
->delete();
|
||||
|
||||
Page::query()->select(['id', 'html'])->chunk(100, function(Collection $pages) {
|
||||
$this->updateForPages($pages->all());
|
||||
|
Reference in New Issue
Block a user