Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x]: Unable to delete Sections or Entry Types #16982

Open
lindseydiloreto opened this issue Mar 29, 2025 · 1 comment
Open

[4.x]: Unable to delete Sections or Entry Types #16982

lindseydiloreto opened this issue Mar 29, 2025 · 1 comment

Comments

@lindseydiloreto
Copy link
Contributor

What happened?

Description

It seems to be impossible to delete sections and entry types in Craft 4.

By the looks of it, the ‎Sections::deleteEntryType method isn't actually deleting anything...

cms/src/services/Sections.php

Lines 1323 to 1334 in 5d6f656

public function deleteEntryType(EntryType $entryType): bool
{
// Fire a 'beforeDeleteEntryType' event
if ($this->hasEventHandlers(self::EVENT_BEFORE_DELETE_ENTRY_TYPE)) {
$this->trigger(self::EVENT_BEFORE_DELETE_ENTRY_TYPE, new EntryTypeEvent([
'entryType' => $entryType,
]));
}
Craft::$app->getProjectConfig()->remove(ProjectConfig::PATH_ENTRY_TYPES . '.' . $entryType->uid, "Delete the “{$entryType->handle}” entry type");
return true;
}

Steps to reproduce

  1. In Craft 4, create a section and/or entry type.
  2. Try to delete that section and/or entry type.
  3. Refresh the page to see that it still exists!

Expected behavior

Deleting a section/entry type should delete the section/entry type.

Actual behavior

Deleting a section/entry type does not delete the section/entry type.

Craft CMS version

4.14.11.1

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

@brandonkelly
Copy link
Member

Both are deleting successfully on my end.

By the looks of it, the ‎Sections::deleteEntryType method isn't actually deleting anything...

That method removes the entry type’s config from the project config. craft\services\Sections::handleDeletedEntryType() will end up getting called in turn, which handles the actual database row (soft) deletion.

Refresh the page to see that it still exists!

Sounds like maybe your project config is out of sync with the database somehow. Can happen if the section/database is added to the database directly, for example.

Try running php craft pc/rebuild first, and then delete the section/entry type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants