<commit_before><?php

class Syndication extends \Movim\Widget\Base
{
    function load()
    {

    }

    function display()
    {
        ob_clean();

        $pd = new \modl\PostnDAO();
        $cd = new \modl\ContactDAO();
        $id = new \Modl\ItemDAO;

        if(!$this->get('s')) {
            return;
        }

        $from = $this->get('s');
        $item = null;

        if(filter_var($from, FILTER_VALIDATE_EMAIL)) {
            $node = 'urn:xmpp:microblog:0';
            $contact = $cd->get($from);
        } elseif(!$this->get('n')) {
            return;
        } else {
            $node = $this->get('n');
            $item = $id->getItem($from, $node);
        }

        $messages = $pd->getPublic($from, $node, 0, 20);
        header("Content-Type: application/atom+xml; charset=UTF-8");

        $dom = new \DOMDocument('1.0', 'UTF-8');
        $dom->formatOutput = true;
        $feed = $dom->createElementNS('http://www.w3.org/2005/Atom', 'feed');
        $dom->appendChild($feed);

        $feed->appendChild($dom->createElement('updated', date('c')));

        $feed->appendChild($self = $dom->createElement('link'));
        $self->setAttribute('rel', 'self');

        if($contact != null) {
            $feed->appendChild($dom->createElement('title', __('feed.title', $contact->getTrueName())));

            $feed->appendChild($author = $dom->createElement('author'));
            $author->appendChild($dom->createElement('name', $contact->getTrueName()));
            $author->appendChild($dom->createElement('uri', Route::urlize('blog', [$from]))));

            $feed->appendChild($dom->createElement('logo', $contact->getPhoto('l')));

            $self->setAttribute('href', Route::urlize('feed', [$from])));
        }

        if($item != null) {
            if($item->name) {
                $feed->appendChild($dom->createElement('title', $item->name));
            } else {
                $feed->appendChild($dom->createElement('title', $item->node));
            }

            if($item->description) {
                $feed->appendChild($dom->createElement('subtitle', $item->description));
            } else {
                $feed->appendChild($dom->createElement('subtitle', $item->server));
            }

            $self->setAttribute('href', Route::urlize('feed', [$from, $node]));
        }

        $feed->appendChild($generator = $dom->createElement('generator', 'Movim'));
        $generator->setAttribute('uri', 'https://movim.eu');
        $generator->setAttribute('version', APP_VERSION);

        foreach($messages as $message) {
            $feed->appendChild($entry = $dom->createElement('entry'));

            if($message->title) {
                $entry->appendChild($dom->createElement('title', $message->title));
            } else {
                $entry->appendChild($dom->createElement('title', __('post.default_title')));
            }
<commit_msg>Fix a PHP fatal error<commit_after><?php

class Syndication extends \Movim\Widget\Base
{
    function load()
    {

    }

    function display()
    {
        ob_clean();

        $pd = new \modl\PostnDAO();
        $cd = new \modl\ContactDAO();
        $id = new \Modl\ItemDAO;

        if(!$this->get('s')) {
            return;
        }

        $from = $this->get('s');
        $item = null;

        if(filter_var($from, FILTER_VALIDATE_EMAIL)) {
            $node = 'urn:xmpp:microblog:0';
            $contact = $cd->get($from);
        } elseif(!$this->get('n')) {
            return;
        } else {
            $node = $this->get('n');
            $item = $id->getItem($from, $node);
        }

        $messages = $pd->getPublic($from, $node, 0, 20);
        header("Content-Type: application/atom+xml; charset=UTF-8");

        $dom = new \DOMDocument('1.0', 'UTF-8');
        $dom->formatOutput = true;
        $feed = $dom->createElementNS('http://www.w3.org/2005/Atom', 'feed');
        $dom->appendChild($feed);

        $feed->appendChild($dom->createElement('updated', date('c')));

        $feed->appendChild($self = $dom->createElement('link'));
        $self->setAttribute('rel', 'self');

        if($contact != null) {
            $feed->appendChild($dom->createElement('title', __('feed.title', $contact->getTrueName())));

            $feed->appendChild($author = $dom->createElement('author'));
            $author->appendChild($dom->createElement('name', $contact->getTrueName()));
            $author->appendChild($dom->createElement('uri', Route::urlize('blog', [$from])));

            $feed->appendChild($dom->createElement('logo', $contact->getPhoto('l')));

            $self->setAttribute('href', Route::urlize('feed', [$from]));
        }

        if($item != null) {
            if($item->name) {
                $feed->appendChild($dom->createElement('title', $item->name));
            } else {
                $feed->appendChild($dom->createElement('title', $item->node));
            }

            if($item->description) {
                $feed->appendChild($dom->createElement('subtitle', $item->description));
            } else {
                $feed->appendChild($dom->createElement('subtitle', $item->server));
            }

            $self->setAttribute('href', Route::urlize('feed', [$from, $node]));
        }

        $feed->appendChild($generator = $dom->createElement('generator', 'Movim'));
        $generator->setAttribute('uri', 'https://movim.eu');
        $generator->setAttribute('version', APP_VERSION);

        foreach($messages as $message) {
            $feed->appendChild($entry = $dom->createElement('entry'));

            if($message->title) {
                $entry->appendChild($dom->createElement('title', $message->title));
            } else {
                $entry->appendChild($dom->createElement('title', __('post.default_title')));
            }

{'fraction_non_alphanumeric': 0.2019132217287325, 'fraction_numerical': 0.004441407584557568, 'mean_word_length': 2.276440962506995, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 115, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '4110105', 'n_tokens_mistral': 1688, 'n_tokens_neox': 1619, 'n_words': 236}