mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-10-12 10:09:58 +00:00
API: Fixed attachment list showing items on deleted pages
List endpoint would show attachments for pages which were in the recycle bin. This adds a deleted_at filter for related pages to the core permission application query. Added test to cover. For #6194
This commit is contained in:
@@ -198,6 +198,7 @@ class PermissionApplicator
|
||||
->leftJoin('entity_page_data', 'entities.id', '=', 'entity_page_data.page_id')
|
||||
->whereColumn('entities.id', '=', $fullPageIdColumn)
|
||||
->where('entities.type', '=', 'page')
|
||||
->whereNull('entities.deleted_at')
|
||||
->where(function (QueryBuilder $query) {
|
||||
$query->where('entity_page_data.draft', '=', false)
|
||||
->orWhere(function (QueryBuilder $query) {
|
||||
|
||||
@@ -61,6 +61,22 @@ class AttachmentsApiTest extends TestCase
|
||||
]]);
|
||||
}
|
||||
|
||||
public function test_index_does_not_show_attachments_for_pages_in_recycle_bin()
|
||||
{
|
||||
$this->actingAsApiEditor();
|
||||
$page = $this->entities->page();
|
||||
$attachment = $this->createAttachmentForPage($page, [
|
||||
'name' => 'My test attachment',
|
||||
'external' => true,
|
||||
]);
|
||||
$this->entities->sendToRecycleBin($page);
|
||||
|
||||
$resp = $this->getJson("{$this->baseEndpoint}?filter[id]={$attachment->id}");
|
||||
|
||||
$resp->assertJsonCount(0, 'data');
|
||||
$resp->assertJsonPath('total', 0);
|
||||
}
|
||||
|
||||
public function test_create_endpoint_for_link_attachment()
|
||||
{
|
||||
$this->actingAsApiAdmin();
|
||||
|
||||
Reference in New Issue
Block a user