<commit_before><?php
namespace verbb\feedme\queue\jobs;

use verbb\feedme\FeedMe;

use Craft;
use craft\queue\BaseJob;

class FeedImport extends BaseJob
{
    // Properties
    // =========================================================================

    public $feed;
    public $limit;
    public $offset;


    // Public Methods
    // =========================================================================

    public function execute($queue)
    {
        $errors = [];

        try {
            $feedData = $this->feed->getFeedData();

            if ($this->offset) {
                $feedData = array_slice($feedData, $this->offset);
            }

            if ($this->limit) {
                $feedData = array_slice($feedData, 0, $this->limit);
            }

            $totalSteps = count($feedData);

            // Do we even have any data to process?
            if (!$totalSteps) {
                FeedMe::info($this->feed, 'No feed items to process.');
                return;
            }

            $feedSettings = FeedMe::$plugin->process->beforeProcessFeed($this->feed, $feedData);

            foreach ($feedData as $key => $data) {
                $element = FeedMe::$plugin->process->processFeed($key, $feedSettings);

                $this->setProgress($queue, $key++ / $totalSteps);
            }

            FeedMe::$plugin->process->afterProcessFeed($feedSettings, $this->feed);
        } catch (\Throwable $e) {
            FeedMe::error($this->feed, $e->getMessage() . ' - ' . basename($e->getFile()) . ':' . $e->getLine());
        }
    }


    // Protected Methods
    // =========================================================================

    protected function defaultDescription(): string
    {
        return Craft::t('feed-me', 'Running {name} feed.', [ 'name' => $this->feed->name ]);
    }
}<commit_msg>Fix for feed items not continuing after encountering a processing error<commit_after><?php
namespace verbb\feedme\queue\jobs;

use verbb\feedme\FeedMe;

use Craft;
use craft\queue\BaseJob;

class FeedImport extends BaseJob
{
    // Properties
    // =========================================================================

    public $feed;
    public $limit;
    public $offset;


    // Public Methods
    // =========================================================================

    public function execute($queue)
    {
        $errors = [];

        try {
            $feedData = $this->feed->getFeedData();

            if ($this->offset) {
                $feedData = array_slice($feedData, $this->offset);
            }

            if ($this->limit) {
                $feedData = array_slice($feedData, 0, $this->limit);
            }

            $totalSteps = count($feedData);

            // Do we even have any data to process?
            if (!$totalSteps) {
                FeedMe::info($this->feed, 'No feed items to process.');
                return;
            }

            $feedSettings = FeedMe::$plugin->process->beforeProcessFeed($this->feed, $feedData);

            foreach ($feedData as $key => $data) {
                try {
                    $element = FeedMe::$plugin->process->processFeed($key, $feedSettings);
                } catch (\Throwable $e) {
                    // We want to catch any issues in each iteration of the loop (and log them), but this allows the
                    // rest of the feed to continue processing.
                    FeedMe::error($this->feed, $e->getMessage() . ' - ' . basename($e->getFile()) . ':' . $e->getLine());
                }

                $this->setProgress($queue, $key++ / $totalSteps);
            }

            FeedMe::$plugin->process->afterProcessFeed($feedSettings, $this->feed);
        } catch (\Throwable $e) {
            // Even though we catch errors on each step of the loop, make sure to catch errors that can be anywhere
            // else in this function, just to be super-safe and not cause the queue job to die.
            FeedMe::error($this->feed, $e->getMessage() . ' - ' . basename($e->getFile()) . ':' . $e->getLine());
        }
    }


    // Protected Methods
    // =========================================================================

    protected function defaultDescription(): string
    {
        return Craft::t('feed-me', 'Running {name} feed.', [ 'name' => $this->feed->name ]);
    }
}
{'fraction_non_alphanumeric': 0.2332042814848554, 'fraction_numerical': 0.0004554771122751082, 'mean_word_length': 2.1104815864022664, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5423949', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1098, 'n_words': 270}