Skip to content

[5.x]: Element select modals shows all site entries when switching to a site without any sources #14956

@mmikkel

Description

@mmikkel

What happened?

Description

It looks like the fix for #14923 might have introduced (or exposed?) a different bug:

In element select modals, when switching to a site that has no sources, the element index will become populated with (as far as I can tell) every single entry in that site, including nested entries.

In the screencast below, I have a section called "Pages" that is only enabled for the site "Craft 5", and an entries field that has "Pages" as its only source. In the entry select modal for that entries field, I switch the site from "Craft 5" to "Another site" (which doesn't have the "Pages" section enabled and hence, no sources to display entries from). At that point, Craft outputs all entries from that site.

CleanShot.2024-05-07.at.22.12.02.mp4

The above behaviour does not occur if the entry select modal has the site without sources active when it opens – it specifically happens when using the site menu to switch to a site without sources:

CleanShot.2024-05-07.at.22.17.11.mp4

Steps to reproduce

  1. Create two sites, "Site A" and "Site B"
  2. Create a section "Foo" that is only enabled for Site A
  3. Create an entries field that has the "Foo" section as its only source. Enable the "Show site menu" setting.
  4. Add the entries field to a field layout and create an entry with that field layout, with "Site A" active.
  5. In that entry, click the "Add an entry" button in the entries field.
  6. In the entry select modal that appears, switch the site from "Site A" to "Site B"

Expected behavior

No entries should display for sites without any sources, which is the case in Craft 4.

(Ideally, I wish that element select modal site menus excluded sites without sources, but I'm aware that this has never been the case - maybe a FR 🙂).

Actual behavior

When switching to a site without sources, the element select modal lists all entries from that site.

Craft CMS version

5.1.2

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

None

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions