Skip to content

[5.x]: Moving entries requires source section to be enabled for same sites as target section #16421

@jannisborgers

Description

@jannisborgers

What happened?

Description

When moving entries between sections, the source section must be enabled for the same sites as the target section. While it’s understandable that the target section needs to be enabled for the site that the entry originates from, it feels restrictive that the source section must be enabled for other sites as well.

This issue came up after an upgrade to Craft 5. We had different sections per site with identical entry types. I merged the entry types after the upgrade, and then decided to also merge the sections (pagesSiteA and pagesSiteB) into a unified pages section, setting the propagation method to Let each entry choose which sites it should be saved to.

When trying to move their entries to the new unified pages section, an error was thrown. I found it hard to identify the cause, until I also enabled the source section for the other sites, which solved the issue.

Steps to reproduce

  1. Add two sites: siteA and siteB
  2. Add section sectionForSiteA, enabled for siteA only, add an entry type
  3. Add section sectionForBothSites, enabled for siteA and siteB, add the same entry type
  4. Select sectionForSiteA inside siteA and add entry of common entry type
  5. Try to move the entry from sectionForSiteA to sectionForBothSites

Expected behavior

Entry is moved to sectionForBothSites, as a) its entry type is compatible with the target section and b) the target section is available for the current site

Actual behavior

Entry cannot be moved. Error Cannot find the entries to move to the new section. is logged. When logging $entries inside EntriesController, it is an empty array:

public function actionMoveToSection(): Response
{
$this->requireCpRequest();
$sectionId = $this->request->getRequiredParam('sectionId');
$section = Craft::$app->getEntries()->getSectionById($sectionId);
if (!$section) {
throw new BadRequestHttpException('Cannot find the section to move the entries to.');
}
$entryIds = $this->request->getRequiredParam('entryIds');
if (empty($entryIds)) {
throw new BadRequestHttpException('entryIds cannot be empty.');
}
$entries = Entry::find()
->id($entryIds)
->status(null)
->drafts(null)
->all();
if (empty($entries)) {
throw new BadRequestHttpException('Cannot find the entries to move to the new section.');
}

Craft CMS version

5.5.9

PHP version

8.3.12

Operating system and version

Darwin 24.1.0

Database type and version

MySQL 8.0.27

Image driver and version

Imagick 3.7.0 (ImageMagick 7.1.1-38)

Installed plugins and versions

  • Cloner: 3.0.1
  • Consume: 2.0.1
  • Dumper: 5.0.1
  • Knock Knock: 3.0.1
  • Redactor: 4.2.0
  • SEO: 5.0.0
  • Super Table: 4.0.2
  • Typed link field: 3.0.0-beta
  • Vite: 5.0.1

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions