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

Empty feed does not disable/delete existing elements #1363

Open
murphy1484 opened this issue Aug 31, 2023 · 5 comments
Open

Empty feed does not disable/delete existing elements #1363

murphy1484 opened this issue Aug 31, 2023 · 5 comments
Labels

Comments

@murphy1484
Copy link

murphy1484 commented Aug 31, 2023

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 murphy1484 added the bug label Aug 31, 2023
@sander-lameco
Copy link

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.

@jamiematrix
Copy link

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.

@johndwells
Copy link

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.

@maxpdesign
Copy link

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

Any update on this?

@strandofgenius
Copy link

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

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

No branches or pull requests

6 participants