<commit_before><?php

class Zfplanet_CallbackController extends Zend_Controller_Action
{

    public function indexAction()
    {
        $this->_helper->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender();
        $storage = Doctrine_Core::getTable('Zfplanet_Model_Subscription');
        $callback = new Zend_Feed_Pubsubhubbub_Subscriber_Callback;
        $callback->setStorage($storage);
        $callback->setSubscriptionKey($this->_getParam('subscriptionKey'));
        $callback->handle();
        if ($callback->hasFeedUpdate()) {
            $data = $callback->getFeedUpdate();
            /*$key = md5($data);
            file_put_contents(APPLICATION_PATH . '/../data/tmp/' . $key, $data);
            $this->_helper->getHelper('Spawn')
                ->setScriptPath(APPLICATION_PATH . '/../scripts/zf-cli');
            $this->_helper->spawn(
                array('--key'=>$key), 'process', 'callback'
            );*/
            $feed = Zend_Feed_Reader::importString($data);
            $feedModel = Doctrine_Core::getTable('Zfplanet_Model_Feed')->find($feed->getId());
            $feedModel->synchronise($feed);
        }
        $callback->sendResponse();
    }

    public function processAction()
    {
        if (!$this->getRequest() instanceof ZFExt_Controller_Request_Cli) {
            throw new Exception('Access denied from HTTP');
        }
        $this->getInvokeArg('bootstrap')->addOptionRules(
            array('key|k=s' => 'File keyname for task data (required)')
        );
        $options = $this->getInvokeArg('bootstrap')->getGetOpt();
        $path = APPLICATION_PATH . '/../data/tmp/' . $options->key;
        $data = file_get_contents($path);
        $feed = Zend_Feed_Reader::importString($data);
        unlink($path);
        $feedModel = Doctrine_Core::getTable('Zfplanet_Model_Feed')->find($feed->getId());
        if ($feedModel) {
            $feedModel->synchronise($feed);
        } else {
            // log the problem
        }
    }


}<commit_msg>Updated callback controller<commit_after><?php

class Zfplanet_CallbackController extends Zend_Controller_Action
{

    public function indexAction()
    {
        $this->_helper->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender();
        $storage = Doctrine_Core::getTable('Zfplanet_Model_Subscription');
        $callback = new Zend_Feed_Pubsubhubbub_Subscriber_Callback;
        $callback->setStorage($storage);
        $callback->setSubscriptionKey($this->_getParam('subscriptionKey'));
        $callback->handle();
        if ($callback->hasFeedUpdate()) {
            $data = $callback->getFeedUpdate();
            $key = md5($data);
            file_put_contents(APPLICATION_PATH . '/../data/tmp/' . $key, $data);
            $this->_helper->getHelper('Spawn')
                ->setScriptPath(APPLICATION_PATH . '/../scripts/zf-cli');
            $this->_helper->spawn(
                array('--key'=>$key), 'process', 'callback'
            );
        }
        $callback->sendResponse();
    }

    public function processAction()
    {
        if (!$this->getRequest() instanceof ZFExt_Controller_Request_Cli) {
            throw new Exception('Access denied from HTTP');
        }
        $this->getInvokeArg('bootstrap')->addOptionRules(
            array('key|k=s' => 'File keyname for task data (required)')
        );
        $options = $this->getInvokeArg('bootstrap')->getGetOpt();
        $path = APPLICATION_PATH . '/../data/tmp/' . $options->key;
        $data = file_get_contents($path);
        $feed = Zend_Feed_Reader::importString($data);
        unlink($path);
        $feedModel = Doctrine_Core::getTable('Zfplanet_Model_Feed')->find($feed->getId());
        if ($feedModel) {
            $feedModel->synchronise($feed);
        } else {
            throw new Exception('Unable to parse feed containing: ' . $data);
        }
    }


}
{'fraction_non_alphanumeric': 0.15719745222929937, 'fraction_numerical': 0.0005095541401273885, 'mean_word_length': 2.536936936936937, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 64, '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': '5106376', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1100, 'n_words': 166}