Code Monkey home page Code Monkey logo

laminas-feed's Introduction

laminas-feed

Build Status Coverage Status

🇷🇺 Русским гражданам

Мы, участники Laminas, родились и живем в разных странах. У многих из нас есть друзья, родственники и коллеги как в России, так и в Украине. Некоторые из нас родились в России. Некоторые из нас живут в России. У некоторых бабушки и дедушки сражались с фашистами во Второй мировой войне. Здесь никто не поддерживает фашизм.

У одного из нас есть украинская родственница, которая спаслась из дома вместе с сыном. Поезд задержался из-за бомбежки на дороге впереди. У нас есть друзья, которые прячутся в бомбоубежищах. Мы с тревогой ждем весточки от них после воздушных налетов, которые беспорядочно наносят удары и попадают по больницам, школам, детским садам и домам. Мы не берем это из каких-либо СМИ. Мы наблюдаем это напрямую.

Вы доверяете нам достаточно, чтоб использовать наши программы, и мы просим вас довериться нам вновь. Мы нуждаемся в помощи. Выходите и протестуйте против этой бесполезной войны. Остановите кровопролитие. Скажите "Нет войне!"

🇺🇸 To Citizens of Russia

We at Laminas come from all over the world. Many of us have friends, family and colleagues in both Russia and Ukraine. Some of us were born in Russia. Some of us currently live in Russia. Some have grandparents who fought Nazis in World War II. Nobody here supports fascism.

One team member has a Ukrainian relative who fled her home with her son. The train was delayed due to bombing on the road ahead. We have friends who are hiding in bomb shelters. We anxiously follow up on them after the air raids, which indiscriminately fire at hospitals, schools, kindergartens and houses. We're not taking this from any media. These are our actual experiences.

You trust us enough to use our software. We ask that you trust us to say the truth on this. We need your help. Go out and protest this unnecessary war. Stop the bloodshed. Say "stop the war!"

Laminas\Feed provides functionality for consuming RSS and Atom feeds. It provides a natural syntax for accessing elements of feeds, feed attributes, and entry attributes. Laminas\Feed also has extensive support for modifying feed and entry structure with the same natural syntax, and turning the result back into XML.

laminas-feed's People

Contributors

akrabat avatar bakura10 avatar boesing avatar dasprid avatar evandotpro avatar ezimuel avatar freeaqingme avatar froschdesign avatar gsteel avatar koopzington avatar laminas-bot avatar maks3w avatar marc-mabe avatar michalbundyra avatar micheh avatar mikaelkael avatar mwillbanks avatar ocean avatar ocramius avatar padraic avatar prolic avatar ralphschindler avatar renovate[bot] avatar samsonasik avatar sgehrig avatar synchro avatar thinkscape avatar wdalmut avatar weierophinney avatar xerkus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laminas-feed's Issues

Workaround for blocked Laminas user agent

Not a bug report, just a workaround!

As per this issue, some feeds may reject requests from the Laminas Feed client because the user agent string contains backslash characters. This can be worked around by injecting an HTTP client instance with a different user agent before you import a feed, like this:

use Laminas\Http as LaminasHttp;
...
        Reader::setHttpClient(
            new LaminasHttp\Client(
                null,
                ['useragent' => 'My Client/1.0']
            )
        );
        $feed = Reader::import($url);

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

composer
composer.json
  • php ~8.1.0 || ~8.2.0 || ~8.3.0
  • laminas/laminas-escaper ^2.9
  • laminas/laminas-stdlib ^3.6
  • laminas/laminas-cache ^2.13.2 || ^3.12
  • laminas/laminas-cache-storage-adapter-memory ^1.1.0 || ^2.3
  • laminas/laminas-coding-standard ~2.5.0
  • laminas/laminas-db ^2.18
  • laminas/laminas-http ^2.19
  • laminas/laminas-servicemanager ^3.22.1
  • laminas/laminas-validator ^2.46
  • phpunit/phpunit ^10.5.5
  • psalm/plugin-phpunit ^0.18.4
  • psr/http-message ^2.0
  • vimeo/psalm ^5.18.0
github-actions
.github/workflows/continuous-integration.yml
.github/workflows/docs-build.yml
.github/workflows/release-on-milestone-closed.yml

  • Check this box to trigger a request for Renovate to run again on this repository

No CDATA block in content block of atom feed

Hello,

I wanted to provide feeds (via the Writer of Zend Feed) with the full content of an article (including some HTML5 markup) and thought to prefer atom over rss. But the writer is acting different and causes some trouble for me.

My code:

    $entry = $feed->createEntry();
    $entry->setContent($news->getText);

Output for RSS:

    <item>
      <content:encoded><![CDATA[<p>My content ...</p>]]></content:encoded>

Output for Atom:

  <entry xmlns:xhtml="http://www.w3.org/1999/xhtml">
    <content xmlns:xhtml="http://www.w3.org/1999/xhtml" type="xhtml">
      <xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">
        <xhtml:p>My content ...</xhtml:p>
      </xhtml:div>
    </content>
  </entry>

And if I add any image to it in HTML5-Style <img src="myimage.jpg"> instead of XHTML-Style <img src="myimage.jpg" />, I get a warning:

DOMDocument::loadXML(): Opening and ending tag mismatch: img line 1 and p in Entity, line: 1

In the atom example in the documentation there is the output:

        <content type="html">
            <![CDATA[I am not writing the article.
                     The example is long enough as is ;).]]>
        </content>

In _setDescription I found $dom->createCDATASection (Entry\Rss and Entry\Atom). But in Atom it's just the summary and in Rss the Content.

In Entry\Atom the _setContent is relevant for the content block, which I wanted to use to output the full content and not just a summary. And there I found $element->setAttribute('type', 'xhtml') in _setContent.

I doubt that the atom output of the example in the documentation is even possible with Zend Feed or am I wrong? It would be great, if the atom feed would also use the CDATA blockinstead of the xhtml for the content.


Originally posted by @av3 at zendframework/zend-feed#82

DateTime::createFromFormat(): Argument #2 ($datetime) must be of type string, bool given

Bug Report

Q A
Version(s) 2.21.0

Summary

DateTime::createFromFormat(): Argument #2 ($datetime) must be of type string, bool given {"exception":"[object] (TypeError(code: 0): DateTime::createFromFormat(): Argument #2 ($datetime) must be of type string, bool given at /var/www/html/releases/2/vendor/laminas/laminas-feed/src/Reader/Feed/Rss.php:285)

Current behavior

image

How to reproduce

I am searching for the feed it failed, will post the feed url later!

Expected behavior

Should not throw exception.

Class 'Laminas\Http\Client' not found

Bug Report

I tried to run Reader::import($url) and there appears to be an issue locating a class from within that class.

Q A
Version(s) 2.12.0

Summary

Here is the stack trace. I swapped out the true paths, class names and the URL to protect our client's privacy.

Exception 'Error' with message 'Class 'Laminas\Http\Client' not found'

in /path/to/site/vendor/laminas/laminas-feed/src/Reader/Reader.php:143

Stack trace:
#0 /path/to/site/vendor/laminas/laminas-feed/src/Reader/Reader.php(200): Laminas\Feed\Reader\Reader::getHttpClient()
#1 /path/to/site/modules/clientname/services/Feed.php(64): Laminas\Feed\Reader\Reader::import('https://example.com...')
#2 /path/to/site/modules/clientname/controllers/console/FeedController.php(33): modules\clientname\services\Feed->importPressReleases()
...

Current behavior

See the stack trace.

How to reproduce

I placed the following at the top of my class:

use Laminas\Feed\Reader\Reader;

In a function, I am calling import like:

$feed = Reader::import($url);

That line with "import" is #1 in the stack trace.

Expected behavior

No exception? Feed is parsed and stored in the $feed variable.

Psalm integration

Feature Request

Q A
QA yes

Summary

As decided during the Technical-Steering-Committee Meeting on August 3rd, 2020, Laminas wants to implement vimeo/psalm in all packages.

Implementing psalm is quite easy.

Required

  • Create a .psalm.xml.dist in the project root
  • Copy and paste the contents from this psalm.xml.dist
  • Run $ composer require vimeo/psalm
  • Run $ vendor/bin/psalm --set-baseline=psalm-baseline.xml
  • Add a composer script static-analysis with the command psalm --shepherd --stats
  • Add a new line to script: in .travis.yml: - if [[ $TEST_COVERAGE == 'true' ]]; then composer static-analysis ; fi
  • Remove phpstan from the project (phpstan.neon.dist, .travis.yml entry, composer.json require-dev and scripts)
Optional
  • Fix as many psalm errors as possible.

PHP 8.0 support

Feature Request

Q A
New Feature yes

Summary

To be prepared for the december release of PHP 8.0, this repository has some additional TODOs to be tested against the new major version.

In order to make this repository compatible, one has to follow these steps:

  • Modify composer.json to provide support for PHP 8.0 by adding the constraint ~8.0.0
  • Modify composer.json to drop support for PHP less than 7.3
  • Modify composer.json to implement phpunit 9.3 which supports PHP 7.3+
  • Modify .travis.yml to ignore platform requirements when installing composer dependencies (simply add --ignore-platform-reqs to COMPOSER_ARGS env variable)
  • Modify .travis.yml to add PHP 8.0 to the matrix (NOTE: Do not allow failures as PHP 8.0 has a feature freeze since 2020-08-04!)
  • Modify source code in case there are incompatibilities with PHP 8.0

CRLF in vendor/laminas/laminas-feed/CHANGELOG.md

The file CHANGELOG.md uses CRLF line endings. When I run a Drupal nstallation with Composer, I always get this warning (no other warnings from any other plugins):

warning: CRLF will be replaced by LF in vendor/laminas/laminas-feed/CHANGELOG.md.

The Composer installation uses 2.15.x but I tested the latest 2.17.x version and it still has CRLF line endings.

I don't know if I should count this as a bug but it seems odd that this file alone triggers this warning.

Change static interface to dynamic

I know it may be a bit too complicated due as part of migration to zf3. It makes sense to change static zend-feed interface to dynamic.

class Reader 
{
    public function __construct(HttpClient $http = null, CacheAdapter $cache = null)

    public function import()
    {
        $cache   = $this->getCache();
        $client  = $this->getHttpClient();
        $cacheId = 'Zend_Feed_Reader_' . md5($uri);
        ...
   }
}

It will break back comparability with version 2.*. But It's necessary changes if we want to have clear, easy management code that can be used in any application without global static variables.


Originally posted by @necromant2005 at zendframework/zend-feed#19

itunes:explicit values have changed

Bug Report

The values for the itunes:explicit tag on channel and episode level changed to "true/false".

Q A
Version(s) 2.12.2

Summary

According to Apple´s documentation the values for the itunes:explicit tag on channel and episode level are not "yes/clean" anymore but now "true/false".

itunes:explicit

The podcast parental advisory information.The explicit value can be one of the following:true.

If you specify true, indicating the presence of explicit content, Apple Podcasts displays an Explicit parental advisory graphic for your podcast.Podcasts containing explicit material aren’t available in some Apple Podcasts territories.

If you specify false, indicating that your podcast doesn’t contain explicit language or adult content, Apple Podcasts displays a Clean parental advisory graphic for your podcast.

See: https://help.apple.com/itc/podcasts_connect/#/itcb54353390

Current behavior

To mark a channel or episode as explicit "yes" is used. To mark a channel or episode as not explicit "clean" is used.

How to reproduce

Generate a feed with channel or an episode set as explicit.

Expected behavior

A channel or episode marked as explicit should have the value <itunes:explicit>true</itunes:explicit>.
A channel or episode marked as clean / not explicit should have the value <itunes:explicit>false</itunes:explicit>.

Itunes categories with same main category are overwritten

Bug Report

Q A
Version(s) 2.14.1

Summary

When setting multiple iTunes categories and two or more having the same "main" category the latter are overwritten.

Current behavior

$feed->setItunesCategories(['Arts' => 'Food]);
$feed->setItunesCategories(['Arts' => 'Visual Arts]);

only

    <itunes:category text="Arts">
      <itunes:category text="Visual Arts"/>
    </itunes:category>

ends up being in the rendered output

How to reproduce

Add two categories with the same main category.

Expected behavior

I´d expect both entries being shown in the feed.

    <itunes:category text="Arts">
      <itunes:category text="Food"/>
    </itunes:category>
    <itunes:category text="Arts">
      <itunes:category text="Visual Arts"/>
    </itunes:category>

The culprit seems to be

vendor/laminas/laminas-feed/src/Writer/Extension/ITunes/Feed.php

somewhere within method setItunesCategories()

Documentation section bloc Extensions for writers is empty

After updating zend-feed to v2.10.3, it seems that the setInvokableClass to add personnal writer has changed. Giving the following error :

Method by name of setInvokableClass does not exist in Zend\Feed\Writer\ExtensionManager

I tried to find more information into your doc, but the bloc is empty with a TODOmention.

Code to reproduce the issue

extensions = Writer::getExtensionManager();
$extensions->setInvokableClass('MyEntryName','PathToMyEntryClass');
Writer::registerExtension('MyExtensionName');

Expected results

My extension well registered.
And the section doc completed.

Actual results

Method by name of setInvokableClass does not exist in Zend\Feed\Writer\ExtensionManager

Originally posted by @gbouyge at zendframework/zend-feed#86

PHPDoc return types incorrect/outdated

Bug Report

Q A
Version(s) dev-master (currently 2.14.x)

Summary

Return types declared in phpdocs are often incorrect, probably because they are outdated.

For example, in laminas-feed/src/Reader/Entry/Rss.php the getEnclosure() method is declared as:

@return string

when it actually returns a stdClass instance. This is enough to trip up most IDEs and static analysers. I think in this particular case it used to return an array instead of a stdClass, but string is wrong for that too.

There are many examples of this, and it probably applies to other components too. Because it's so widespread, I didn't want to do a PR on spec in case you have some policy on such phpdocs, but I wanted to flag it anyway.

feedLink() is broken, returns invalid data if not found

Bug Report

Q A
Version(s) 2.15

Summary

The getFeedLink() method is broken and returns invalid data.

Current behavior

getFeedLink() on an RSS feed falls back to the Atom\Feed extension, and calls it's getFeedLink() method.

Atom\Feed::getLink() first looks for a <link rel="self" /> element to get a link. If it finds nothing, it gets an empty string. So far so good.

However, it then calls absolutiseUrl() on that value unconditionally, which when passed an empty string dutifully slaps the base domain of the feed onto the start of an empty string, giving you the domain of the site... Which is almost certainly not the self link of the feed, and may not even be related to the feed in the first place. But that's what then gets returned.

How to reproduce

Feed (no pun intended) any RSS feed with no self link into it and call getFeedLink().

Expected behavior

According to the method signatures, it should return null if there is no self link.

Laminas-http mishandles multiple headers causing failure

Bug Report

Q A
Version(s) 2.15.0

Summary

Header handling in the dependency for laminas/laminas-http has an error when it receives a header that it treats as a single string first followed by an array type header with the same data. Because the header has already been set like a string, the call to set it as an array fails.

I am fully aware that laminas/laminas-http is in security only support now which is why I'm posting the bug report to laminas-feed where the issue is manifesting. Laminas-Feed should be updated to use PSR-7 or the bug should be fixed.

Current behavior

When sending a request to an RSS feed that delivers the header twice, first as a string, then as an array, Laminas reports

PHP Error: [] operator not supported for strings in /var/www/vendor/laminas/laminas-http/src/Headers.php on line 454

How to reproduce

This occurs specifically when utilizing Google's news search to RSS feed approach. It returns two sets of Content-Security-Policy headers.

When set in the order of

require-trusted-types-for 'script';report-uri /_/DotsSplashUi/cspreport

followed by

script-src 'report-sample' 'nonce-e2kBBs8/LEHElepgO1hnkA' 'unsafe-inline'; object-src 'none'; base-uri 'self'; report-uri /_/DotsSplashUi/cspreport; worker-src 'self';

Laminas-http fails.

However, it does so inconsisently because the responding server does not always send the headers back in the same order. If the headers are sent back in the reverse order, the process succeeds, but actually overwrites the array header with the string header.

To reproduce, run this multiple times.

$url = 'https://news.google.com/rss/search?q=%22ecommerce%22+when%3A7d&hl=en-US&gl=US&ceid=US%3Aen';
$feed_result = \Laminas\Feed\Reader\Reader::import($feed_url);

Expected behavior

We should expect the headers to be assembled even if an array type is passed to the client after a string type.

Implement custom extensions

Hello,

I'm trying to build my own Extension like the ones provided in tree.
With this code and I'm able to register it:

$extensionManager = \Laminas\Feed\Writer\Writer::getExtensionManager();
$extensionManager->add('MyExtension\Renderer\Entry', \MyExtension\Renderer\Entry::class);
Laminas\Feed\Writer\Writer::registerExtension('MyExtension');

This is my class:

<?php


namespace MyExtension\Renderer;

use DOMDocument;
use DOMElement;
use Laminas\Feed\Writer\Extension;

/**
*/
class Entry extends Extension\AbstractRenderer
{
    /**
     * Set to TRUE if a rendering method actually renders something. This
     * is used to prevent premature appending of a XML namespace declaration
     * until an element which requires it is actually appended.
     *
     * @var bool
     */
    protected $called = false;

    /**
     * Render entry
     *
     * @return void
     */
    public function render()
    {
        if (strtolower($this->getType()) === 'rss') {
            return; // Atom 1.0 only
        }
        $this->_setImageLink($this->dom, $this->base);
        if ($this->called) {
            $this->_appendNamespaces();
        }
    }

    /**
     * Append namespaces to entry root
     *
     * @return void
     */
    // @codingStandardsIgnoreStart
    protected function _appendNamespaces()
    {
        // @codingStandardsIgnoreEnd
        $this->getRootElement()->setAttribute(
            'xmlns:solg',
            'http://example.it/atom/1.0'
        );
    }

    /**
     * Set image link
     *
     * @param  DOMDocument $dom
     * @param  DOMElement $root
     * @return void
     */
    // @codingStandardsIgnoreStart
    protected function _setImageLink(DOMDocument $dom, DOMElement $root)
    {
        // @codingStandardsIgnoreEnd
        $link = $this->getDataContainer()->getImageLink();
        if (! $link) {
            return;
        }
        $clink = $this->dom->createElement('image_link');
//         $clink->setAttribute('rel', 'replies');
//         $clink->setAttribute('type', 'text/html');
        $clink->setAttribute('href', $link);
//         $count = $this->getDataContainer()->getCommentCount();
//         if ($count !== null) {
//             $clink->setAttribute('thr:count', $count);
//         }
        $root->appendChild($clink);
        $this->called = true;
    }

}
?>

Unluckily it breaks on render:

[Fri Mar 06 17:14:45.214753 2020] [php7:notice] [pid 28374] [client 127.0.0.1:36146] PHP Fatal error:  Uncaught Laminas\\Feed\\Writer\\Exception\\BadMethodCallException: Method: getImageLink does not exist and could not be located on a registered Extension in /home/francesco/eclipse-workspace/project/vendor/laminas/laminas-feed/src/Writer/Entry.php:724
Stack trace:
#0 /home/francesco/eclipse-workspace/project/MyExtension/Renderer/Entry.php(70): Laminas\\Feed\\Writer\\Entry->__call('getImageLink', Array)
#1 /home/francesco/eclipse-workspace/project/MyExtension/Renderer/Entry.php(38): MyExtension\\Renderer\\Entry->_setImageLink(Object(DOMDocument), Object(DOMElement))
#2 /home/francesco/eclipse-workspace/project/vendor/laminas/laminas-feed/src/Writer/Renderer/Entry/Atom.php(59): MyExtension\\Renderer\\Entry->render()
#3 /home/francesco/eclipse-workspace/project/vendor/laminas/laminas-feed/src/Writer/Renderer/Feed/Atom.php(90): Laminas\\Feed\\Writer\\Renderer\\Entry\\Atom->render()
#4 /home/francesco/eclipse-workspace/project/vendor/laminas/laminas-feed/src/Writer/Feed.php(237): Laminas\\Feed\\Writer\\Renderer\\Feed\\Atom-> in /home/francesco/eclipse-workspace/project/vendor/laminas/laminas-feed/src/Writer/Entry.php on line 724

I'm not sure how to set the new property and how make it run without breaking on:

$feed->export('atom');

Any suggestion is welcome.
Many thanks
Cheers
Francesco

Atom Feed can’t read Entry content if type is application/xml

Feature Request

Q A
New Feature yes

Summary

I’m trying to get content of Atom Entry where content is with type="application/xml"

In documentation https://validator.w3.org/feed/docs/atom.html#contentElement
content can have type attribute ends in +xml or /xml , then an xml document of this type is contained inline.

I have this xml:

<entry>
    <content type="application/xml">
        <m:properties>
            <d:Code>10</d:Code>
            <d:shopCode/>
            <d:Description>Some description here</d:Description>
        </m:properties>
    </content>
</entry>

When we use \Laminas\Feed\Reader\Extension\Atom\Entry::getContent method we get empty string.
I’m expecting to get an array with keys and values.

In the code

public function getContent()
{
if (array_key_exists('content', $this->data)) {
return $this->data['content'];
}
$content = null;
$el = $this->getXpath()->query($this->getXpathPrefix() . '/atom:content');
if ($el->length > 0) {
$el = $el->item(0);
$type = $el->getAttribute('type');
switch ($type) {
case '':
case 'text':
case 'text/plain':
case 'html':
case 'text/html':
$content = $el->nodeValue;
break;
case 'xhtml':
$this->getXpath()->registerNamespace('xhtml', 'http://www.w3.org/1999/xhtml');
$xhtml = $this->getXpath()
->query($this->getXpathPrefix() . '/atom:content/xhtml:div')
->item(0);
$d = new DOMDocument('1.0', $this->getEncoding());
$deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true;
$xhtmls = $d->importNode($xhtml, $deep);
$d->appendChild($xhtmls);
$content = $this->collectXhtml(
$d->saveXML(),
$d->lookupPrefix('http://www.w3.org/1999/xhtml')
);
break;
}
}
if (! $content) {
$content = $this->getDescription();
}
$this->data['content'] = trim($content);
return $this->data['content'];
}
we can see there is no case for this.

Error 500 when rendering a feed with some set*() methods

BC Break Report

Q A
Version 2.18.1

Summary

Hello,

When I call setItunesEpisode(), i got this errror:

image

Since This PR, declare(strict_types=1); was added and broke some pieces of code when argument of createTextNode() is not a string. Same behavior with setItunesSeason() (and maybe others)

Previous behavior

All good with v2.17, i can render an RSS feed with iTunes attributes.

Current behavior

Error 500, because of a wrong parameter type.

How to reproduce

Just Write a simple feed :

    $feed = new \Laminas\Feed\Writer\Feed ();

    $feed->setTitle('Serie Name')
        ->setDescription('Description')
        ->setLink('https//www.example.com');

    $item = $feed->createEntry();
    $item->setTitle('Episode Title')
        ->setItunesEpisode(3);

    $feed->addEntry($item);

    $feed->export('rss');

Methods of CoreExtensions expected in own writer extension

Thank you for your writer example, froschdesign. I tested it and am getting an error message. This time I created a separate issue, because it's not related to the documentation ;)

I created an Entry class (extends Extension\AbstractRenderer) and registered it in my handler. But the output of my atom feed fails (using the export method). I get the error message:

call_user_func_array() expects parameter 1 to be a valid callback, class 'Webfeed\Writer\Renderer\Entry' does not have a method 'getItunesAuthors'

I can see that $authors = $this->getDataContainer()->getItunesAuthors(); of Writer/Extension/ITunes/Renderer/Entry.php is executed, before it fails. Why should my own Renderer need getItunesAuthors?

I assume on reason is that registerCoreExtensions() is called in the AbstractFeed constructor. Unfortunately I can't see a method to unregister the extension. When removing iTunes in the registerCoreExtensions method, the method getPlayPodcastBlock is expected. It would work if I remove everything except Atom.

Is this an unexpected behavior or am I doing something wrong?


Originally posted by @av3 at zendframework/zend-feed#87

An item should not include both author and dc:creator

Using the W3C Feed Validation Service:

In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendations.
line 19, column 6: An item should not include both author and dc:creator (10 occurrences) [help]

      <dc:creator>Tina "jnienow" Pfannerstill</dc:creator>

Code to reproduce the issue

n/a

Expected results

Only one of author and dc:creator is included.

Actual results

Both are included.


Originally posted by @glen-84 at zendframework/zend-feed#90

Method getDateModified of RSS reader doesn't iterate over different formats

Bug Report

Q A
Version(s) 2.13.0

Summary

The current code suggest that when retrieving the date modified variable it will attempt to create it from 3 different formats: RSS, RFC822 and RFC2822. This doesn't happen because the method used date_create_from_format doesn't throw an exception.
This also means that if the format is not recognised at all the exception won't be thrown.

Current behavior

If the given date doesn't match the first format tested (RSS) the variable will resolve into false and the loop will break there.

How to reproduce

Read an RSS feed with a date modified format different from RSS (D, d M Y H:i:s O).

Expected behavior

The code will iterate over all 3 different formats and if unable to create the datetime object it will throw an exception saying the date format was not recognised.

For reference, the piece of code with the bug:
https://github.com/laminas/laminas-feed/blob/2.13.x/src/Reader/Feed/Rss.php#L205

$dateStandards = [
    DateTime::RSS,
    DateTime::RFC822,
    DateTime::RFC2822,
    null,
];

foreach ($dateStandards as $standard) {
    try {
        $date = date_create_from_format($standard, $dateModified);
        break;
    } catch (\Exception $e) {
        if ($standard === null) {
            throw new Exception\RuntimeException(
                'Could not load date due to unrecognised format'
                . ' (should follow RFC 822 or 2822): ' . $e->getMessage(),
                0,
                $e
            );
        }
    }
}

Getting "failed to open stream: No such file or directory in /autoload.php on line 5" when loading package

Bug Report

Q A
Version(s) 2.12

Summary

I am seeing the following error message when using a stock install via Composer. Here's my composer file.

{
    "name": "test-app",
    "type": "project",
    "require": {
        "laminas/laminas-feed": "^2.12"
    }
}

And here is my PHP file that autoloads the Composer dependencies:

<?php

require_once '../vendor/autoload.php';

echo "Hello";

I'm seeing this issue in craftcms/cms#6773, but posting it here as it seems to be occurring due to the laminas/laminas-feed package.

Current behavior

Instead of echoing "Hello", the browser outputs the following:

Warning: require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5

Fatal error: require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.3/lib/php') in /autoload.php on line 5

How to reproduce

This is a bit tricky because it works locally, but doesn't on a Digital Ocean server. However:

  1. Setup a basic composer.json
  2. Install laminas/laminas-feed
  3. Autoload deps

Expected behavior

The dependency should load correctly and echo my "Hello" text.

PubSubHubbub/Publisher not sending requests to hubs

Bug Report

Q A
Version(s) 2.14.0

Summary

It seems like the publishing always fails, and the requests to the hubs are never sent.

Current behavior

Calling $publisher->notifyAll(); results in no requests being sent.

How to reproduce

I've created a repository to reproduce the bug here: https://github.com/jabinb/laminas-feed-bug
To run it:

$ composer install
$ php -S localhost:9090 server.php
# another terminal window
$ php test.php

You'll notice no requests get sent to the built-in webserver.

Outside of the repository the steps are pretty simple, try to follow the documentation and use notifyHub or notifyAll and set a breakpoint to inspect the $response object -- you'll see it's an empty response.

Expected behavior

The Publisher class sends the proper requests.

Fix

foreach ($hubs as $url) {
$client->setUri($url);
$response = $client->getResponse();
if ($response->getStatusCode() !== 204) {
$this->errors[] = [
'response' => $response,
'hubUrl' => $url,
];
}
}

Seems like on line 258 there's a missing call to $client->send() to actually trigger the request (adding it fixes the problem). Instead they just grab an empty request and return it immediately.

Add support for laminas/laminas-servicemanager 4.0 so this library can be used on PHP 8.2 + psr/container 2.0.

I maintain a Drupal module called "Feeds". Wit that module you can import content on a Drupal site. It uses laminas/laminas-feed to parse RSS feeds.

The issue is that Feeds cannot be installed currently on Drupal 10 + PHP 8.2 because Drupal 10 requires psr/container ~2.0.2 and only laminas/laminas-servicemanager 4.0.x is compatible with PHP 8.2 + psr/container ~2.0.2. (For some reason though laminas/laminas-servicemanager 3.15 is compatible with psr/container 2.0.2 too, but not with PHP 8.2, hence the reason why my module is installable on Drupal 10 + PHP 8.1.)

Anyway, it would help if this project can declare a compatibility with laminas/laminas-servicemanager ^4.0.

See also https://www.drupal.org/project/feeds/issues/3325568

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.