1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Queries: Addressed failing test cases from recent changes

This commit is contained in:
Dan Brown
2024-02-08 17:18:03 +00:00
parent ed21a6d798
commit ed9c013f6e
8 changed files with 18 additions and 12 deletions

View File

@ -329,13 +329,14 @@ class PageContent
protected function getContentProviderClosure(bool $blankIncludes): Closure
{
$contextPage = $this->page;
$queries = $this->pageQueries;
return function (PageIncludeTag $tag) use ($blankIncludes, $contextPage): PageIncludeContent {
return function (PageIncludeTag $tag) use ($blankIncludes, $contextPage, $queries): PageIncludeContent {
if ($blankIncludes) {
return PageIncludeContent::fromHtmlAndTag('', $tag);
}
$matchedPage = $this->pageQueries->findVisibleById($tag->getPageId());
$matchedPage = $queries->findVisibleById($tag->getPageId());
$content = PageIncludeContent::fromHtmlAndTag($matchedPage->html ?? '', $tag);
if (Theme::hasListeners(ThemeEvents::PAGE_INCLUDE_PARSE)) {

View File

@ -38,7 +38,8 @@ class PageEditorData
$templates = $this->queries->pages->visibleTemplates()
->orderBy('name', 'asc')
->take(10)
->get();
->paginate()
->withPath('/templates');
$draftsEnabled = auth()->check();
@ -51,7 +52,7 @@ class PageEditorData
}
// Check for a current draft version for this user
$userDraft = $this->queries->revisions->findLatestCurrentUserDraftsForPageId($page->id)->first();
$userDraft = $this->queries->revisions->findLatestCurrentUserDraftsForPageId($page->id);
if (!is_null($userDraft)) {
$page->forceFill($userDraft->only(['name', 'html', 'markdown']));
$isDraftRevision = true;

View File

@ -14,6 +14,7 @@ class SiblingFetcher
{
public function __construct(
protected EntityQueries $queries,
protected ShelfContext $shelfContext,
) {
}
@ -38,7 +39,7 @@ class SiblingFetcher
// Book
// Gets just the books in a shelf if shelf is in context
if ($entity instanceof Book) {
$contextShelf = (new ShelfContext())->getContextualShelfForBook($entity);
$contextShelf = $this->shelfContext->getContextualShelfForBook($entity);
if ($contextShelf) {
$entities = $contextShelf->visibleBooks()->get();
} else {