Problem/Motivation

Can't delete a feed that has been orphaned, i.e. the feed type has been deleted. Here's the php error:

Drupal\Core\Entity\EntityStorageException: The feed type "my_feed_import" for feed XX no longer exists. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete() (row 758 of /backend/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Steps to reproduce

Create feed type and feed.
Delete feed type.
Try to delete feed.

Issue fork feeds-3224235

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

iamfredrik created an issue. See original summary.

iamfredrik’s picture

Issue summary: View changes
megachriz’s picture

How did you delete the feed type? Access for deleting a feed type is denied when there are still feed entities of it. Did you do that somewhere in the UI or programmatically?

I also tried to delete a feed type using a config import, but that resulted into the following warning:

Entities exist of type Feed and Feed type Foo. These entities need to be deleted before importing.

I do can delete the feed type programmatically:

$feed_type = \Drupal\feeds\Entity\FeedType::load('foo');
$feed_type->delete();

And then I can indeed reproduce the issue.

Workaround

A possible workaround is to recreate the feed type and then delete the feed that you want to delete.

I'm working on a fix.

megachriz’s picture

Status: Active » Needs review
Issue tags: +Needs tests

Code is available in the issue fork. I only did some minimal testing. Needs automated tests.

iamfredrik’s picture

Sorry, the feed type was apparently deleted with 8.x-3.0-alpha10. The error above came after updating to dev because of the related issue. If the problem is fixed by not allowing deletion of feed types, then this can be closed.

megachriz’s picture

@iamfredrik
Yeah, I think during normal user operations it should never happen. But the fact that it did happen in your case and I already wrote a possible fix, I think I might as well finish it off now.

I added a test for this case. Let's see if it passes.

  • MegaChriz committed 3488fa2 on 8.x-3.x
    Issue #3224235 by MegaChriz: Fixed fatal error when trying to delete an...
megachriz’s picture

Status: Needs review » Fixed
Issue tags: -Needs tests

I merged the code!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.