feed-me icon indicating copy to clipboard operation
feed-me copied to clipboard

Empty feed does not disable/delete existing elements

Open murphy1484 opened this issue 1 year ago • 5 comments

Description

When a feed has "Disable/delete missing elements" enabled and the processed feed is empty no elements are disabled/deleted.

Steps to reproduce

  1. Feed with Disable/delete missing elements
  2. Run feed without results.

Additional info

I believe the following lines in the afterProcessFeed function in the Process service are responsible. In this case $processedElementIds is an empty array.

if ($processedElementIds) {
    $elementsToDeleteDisable = array_diff($settings['existingElements'], $processedElementIds);
    if ($elementsToDeleteDisable) {
        if (DuplicateHelper::isDisable($feed)) {
            $this->_service->disable($elementsToDeleteDisable);
            $message = 'The following elements have been disabled: ' . Json::encode($elementsToDeleteDisable) . '.';
        } elseif (DuplicateHelper::isDisableForSite($feed)) {
            $this->_service->disableForSite($elementsToDeleteDisable);
            $message = 'The following elements have been disabled for the target site: ' . Json::encode($elementsToDeleteDisable) . '.';
        } else {
            $this->_service->delete($elementsToDeleteDisable);
            $message = 'The following elements have been deleted: ' . Json::encode($elementsToDeleteDisable) . '.';
        }

        Plugin::info($message);
        Plugin::debug($message);
    }
}
  • Craft version: 4.5.3
  • PHP version: 8.1
  • Database driver & version: MySQL 5.7
  • Plugins & versions: Feed me 5.2.0

murphy1484 avatar Aug 31 '23 09:08 murphy1484

Just found out the same issue. Would be a nice feature to delete all entries if the data is empty. Weird it doesn't work like that out of the box.

sander-lameco avatar Sep 05 '23 12:09 sander-lameco

Also discovered this just now.

I would have thought the process would just take from settings e.g. if you chose to delete missing entries, then an empty feed will delete all missing entries ... same for disable.

jamiematrix avatar Apr 25 '24 08:04 jamiematrix

We've just run into this issue too.

It would be good to know if there's an intention to fix this bug, or if we need to consider a workaround solution for the future.

johndwells avatar May 13 '24 13:05 johndwells

Currently running into the same issue that missing entries don't get disabled when the feed is empty.

Any update on this?

maxpdesign avatar Jun 07 '24 14:06 maxpdesign

Also having this issue in Craft 5 and Feed me 6.1.0.

strandofgenius avatar Jun 11 '24 20:06 strandofgenius