Skip to content

Entry revision localizations include unauthorized sites #14697

Description

@msuphilipgales

Bug description

Entry create/edit screens build their localizations list through EntriesController::getAuthorizedSitesForCollection(), which filters collection sites to only sites the current user can view.

protectedfunctiongetAuthorizedSitesForCollection($collection)
{
return$collection
->sites()
->filter(fn ($handle) => User::current()->can('view', Site::get($handle)));
}

The entry revision preview endpoint does not use that same filtering. EntryRevisionsController builds localizations directly from every collection site:

'localizations' => $entry->collection()->sites()->map(function ($handle) use ($entry) {

Proposed fix:

- 'localizations' => $entry->collection()->sites()->map(function ($handle) use ($entry) {+ 'localizations' => $this->getAuthorizedSitesForCollection($entry->collection())->map(function ($handle) use ($entry) {
+ protected function getAuthorizedSitesForCollection($collection)+ {+ return $collection+ ->sites()+ ->filter(fn ($handle) => User::current()->can('view', Site::get($handle)));+ }

How to reproduce

  1. Enable multisite.
  2. Create a collection available on multiple sites.
  3. Create a user who can view the collection/entry but cannot view every site in the collection.
  4. Enable revisions for the collection.
  5. View an entry revision in the Control Panel.
  6. Inspect the revision preview response.

The localizations array includes all collection sites instead of only sites the user can view.

Logs

Environment

EnvironmentLaravel Version: 13.9.0PHP Version: 8.5.5Composer Version: 2.9.5Environment: localDebug Mode: ENABLEDMaintenance Mode: OFFTimezone: UTCLocale: enCacheConfig: NOT CACHEDEvents: NOT CACHEDRoutes: NOT CACHEDViews: CACHEDDriversBroadcasting: logCache: fileDatabase: mariadbLogs: stack / dailyMail: logQueue: databaseSession: fileStoragepublic/storage: NOT LINKEDStatamicAddons: 4License Key: SetSites: 1522 (Aardvark, Abbott Group, Abbott, Reichel and Schulist, and 1519 more)Stache Watcher: Enabled (auto)Static Caching: DisabledVersion: 6.19.0 PROStatamic Addonsndx/statamic-simple-redirects: 1.1.0statamic/audit-log: 1.1.0statamic/collaboration: 2.0.1statamic/eloquent-driver: 5.8.0Statamic Eloquent DriverAddon Settings: fileAsset Containers: eloquentAssets: eloquentBlueprints: eloquentCollection Trees: eloquentCollections: fileEntries: eloquentFieldsets: fileForm Submissions: eloquentForms: eloquentGlobal Sets: eloquentGlobal Variables: eloquentNavigation Trees: eloquentNavigations: eloquentRevisions: eloquentSites: eloquentTaxonomies: eloquentTerms: eloquentTokens: eloquent

Installation

Existing Laravel app

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions