Add a buffer of 2 items when we remove them from the database (WP cache issue)
This commit is contained in:
parent
3573c621fc
commit
2636cde275
18
model.php
18
model.php
@ -565,13 +565,29 @@ function update_items($feed_id, array $items)
|
||||
// and not present inside the feed
|
||||
if (! empty($items_in_feed)) {
|
||||
|
||||
\PicoTools\singleton('db')
|
||||
$removed_items = \PicoTools\singleton('db')
|
||||
->table('items')
|
||||
->columns('id')
|
||||
->notin('id', $items_in_feed)
|
||||
->eq('status', 'removed')
|
||||
->eq('feed_id', $feed_id)
|
||||
->desc('updated')
|
||||
->findAllByColumn('id');
|
||||
|
||||
// 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 (! empty($items_to_remove)) {
|
||||
|
||||
\PicoTools\singleton('db')
|
||||
->table('items')
|
||||
->in('id', $items_to_remove)
|
||||
->eq('status', 'removed')
|
||||
->eq('feed_id', $feed_id)
|
||||
->remove();
|
||||
}
|
||||
}
|
||||
|
||||
$db->closeTransaction();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user