Remove PHP warning when there is no items to remove

This commit is contained in:
Frederic Guillot 2013-07-16 19:28:20 -04:00
parent 7de72b41e4
commit 6bd2e32615
1 changed files with 11 additions and 8 deletions

View File

@ -577,16 +577,19 @@ function update_items($feed_id, array $items)
// Keep a buffer of 2 items
// It's workaround for buggy feeds (cache issue with some Wordpress plugins)
$items_to_remove = array_slice($removed_items, 2);
if (is_array($removed_items)) {
if (! empty($items_to_remove)) {
$items_to_remove = array_slice($removed_items, 2);
\PicoTools\singleton('db')
->table('items')
->in('id', $items_to_remove)
->eq('status', 'removed')
->eq('feed_id', $feed_id)
->remove();
if (! empty($items_to_remove)) {
\PicoTools\singleton('db')
->table('items')
->in('id', $items_to_remove)
->eq('status', 'removed')
->eq('feed_id', $feed_id)
->remove();
}
}
}