It feels more like offset handling issue to me, i.e. offset either remains the same or isn’t shifted enough after processing each subsequent batch of tweets, so next page data contains less and less matching tweets (i.e. not retweets/replies) and eventually contains 0 matching tweets, so it stops.
I didn’t spend a lot of time digging in your code (which looks pretty nice, btw!), neither am I a PHP expert, but here’s a piece that could be problematic, if get_posts returns only records matching specific filter:
const POSTS_PER_BATCH = 50;
...
$found = get_posts( array(
'posts_per_page' => static::POSTS_PER_BATCH,
'offset' => $offset,
...
}
update_option( 'keyring_batch_processing_offset', $offset += count( $found ) );
What if it loads 50 tweets, but only 10 of them match the filter? Offset would be increased by 10, not 50, so next batch would load 10 new records, but 40 same ones, no? Again, I might be completely wrong here as I’m not aware of implementation details (I only spent like 15 minutes looking into your code; i.e. get_posts might not be returning filtered records even, in which case my assumption here is completely wrong), but if what I just said is indeed the case, then there might be an issue. And if that’s indeed what it is, wouldn’t it get fixed by simply always increasing offset by POSTS_PER_BATCH instead of number of records matching the filter?
I believe I have one kind-of-proof for this theory: if I choose to import ALL tweets – i.e. without skipping retweets/replies – it actually works perfectly and imports entire timeline (over 2600 tweets). The problem only occurs when I choose to NOT import retweets/replies (which is what I need for my case).
I hope this is helpful. Let me know once you got a chance to look at it. I’d love to use your awesome plugin for my WordPress installation b/c it’s exactly what I was looking for and I think it’s brilliant, except this one issue, which stops me from using it.
In either case – thanks a lot for your time and keep up the great job with the plugin!
~ Kion