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:
Dan Brown
2026-09-28 16:14:06 +01:00
parent 89978409cf
commit a09aa8aac6
2 changed files with 17 additions and 0 deletions
+1
View File
@@ -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) {
+16
View File
@@ -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();