Problem/Motivation

Drupal core currently has not one but two RSS serializers, and one RSS parser. There's core's RSS generator, portions of which date back to 2001(!) according to Git blame. There's Views' RSS display plugin, which shares almost no code with the other core generator. And then there's aggregator module.

Come on, Drupal. RSS is cool, but not so cool that we need 3 different home-grown half-arsed libraries for it. :-)

Proposed resolution

The most widely used existing library for handling RSS is Zend Feed, part of Zend Framework 2:

http://framework.zend.com/manual/2.0/en/modules/zend.feed.introduction.html

As part of ZF2, it is MIT licensed (same as Symfony2, so safe for us to use), uses PSR-0, uses Composer... it's totally easy for us to drop in and use. It's also a fairly robust library, offering support for RSS, Atom, and the Pubsubhubbub Atom extension.

The plan is to:

1) Add Zend\Feed to core via composer. (DONE)
2) Port Aggregator.module to use Zend\Feed, ripping out its ancient parsing code along the way. (DONE)
3) Gut and replace the Views RSS display plugin to be a thin shell around Zend\Feed. #2003108: Switch Views RSS to use Serializer/Zend
4) Rip out the core RSS support entirely. We have Views. Views kicks core's ass on this front. This will happen automatically once those 2 conversions issues are in:

Contrib modules like Feeds would also then be able to build off of Zend\Feed very easily.

Remaining tasks

There is already an rtbc'ed patch with aggregator replacement. Commit this and then after that move off to standarize views rss plugin on it.

User interface changes

RSS functionality in core outside of Views and Aggregator will be removed. Views' RSS support would probably look mostly the same to the end-user, but that's up to the Views team.

API changes

All RSS parsing will be handled by Zend\Feed directly. That will be the new API for handling RSS and Atom.

Original report by catch

There are some very old functions in common.inc for formatting RSS items, some of the very oldest code still in core most likely - see the git blame!

0d78e98 includes/common.inc      (Dries Buytaert       2004-07-13 07:21:14 +0000 1639)  * Arbitrary elements may be added using the $args associative array.
50d78e98 includes/common.inc      (Dries Buytaert       2004-07-13 07:21:14 +0000 1640)  */
36e87e19 includes/common.inc      (Gábor Hojtsy         2007-05-29 14:37:49 +0000 1641) function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) {
9a0367fa core/includes/common.inc (Dries                2012-08-09 16:17:01 -0400 1642)   $langcode = $langcode ? $langcode : language(LANGUAGE_TYPE_CONTENT)->langcode;
f8329dd4 includes/common.inc      (Dries Buytaert       2002-04-27 13:19:37 +0000 1643)
009b1afe includes/common.inc      (Dries Buytaert       2003-12-13 14:59:55 +0000 1644)   $output = "<channel>\n";
56d2664a includes/common.inc      (Dries Buytaert       2008-04-14 17:48:46 +0000 1645)   $output .= ' <title>' . check_plain($title) . "</title>\n";
56d2664a includes/common.inc      (Dries Buytaert       2008-04-14 17:48:46 +0000 1646)   $output .= ' <link>' . check_url($link) . "</link>\n";
9a014043 includes/common.inc      (Steven Wittens       2006-03-01 21:30:17 +0000 1647)
9a014043 includes/common.inc      (Steven Wittens       2006-03-01 21:30:17 +0000 1648)   // The RSS 2.0 "spec" doesn't indicate HTML can be used in the description.
9a014043 includes/common.inc      (Steven Wittens       2006-03-01 21:30:17 +0000 1649)   // We strip all HTML tags, but need to prevent double encoding from properly
9a014043 includes/common.inc      (Steven Wittens       2006-03-01 21:30:17 +0000 1650)   // escaped source data (such as &amp becoming &amp;amp;).
56d2664a includes/common.inc      (Dries Buytaert       2008-04-14 17:48:46 +0000 1651)   $output .= ' <description>' . check_plain(decode_entities(strip_tags($description))) . "</description>\n";
56d2664a includes/common.inc      (Dries Buytaert       2008-04-14 17:48:46 +0000 1652)   $output .= ' <language>' . check_plain($langcode) . "</language>\n";
0fef1502 includes/common.inc      (Steven Wittens       2006-07-17 15:42:55 +0000 1653)   $output .= format_xml_elements($args);
d852a999 includes/common.inc      (Dries Buytaert       2001-12-01 15:20:48 +0000 1654)   $output .= $items;
d852a999 includes/common.inc      (Dries Buytaert       2001-12-01 15:20:48 +0000 1655)   $output .= "</channel>\n";
d852a999 includes/common.inc      (Dries Buytaert       2001-12-01 15:20:48 +0000 1656)
d852a999 includes/common.inc      (Dries Buytaert       2001-12-01 15:20:48 +0000 1657)   return $output;
d852a999 includes/common.inc      (Dries Buytaert       2001-12-01 15:20:48 +0000 1658) }
d852a999 includes/common.inc      (Dries Buytaert       2001-12-01 15:20:48 +0000 1659)
50d78e98 includes/common.inc      (Dries Buytaert       2004-07-13 07:21:14 +0000 1660) /**
9727bd09 core/includes/common.inc (catch                2011-12-05 21:52:27 +0900 1661)  * Formats a single RSS item.
50d78e98 includes/common.inc      (Dries Buytaert       2004-07-13 07:21:14 +0000 1662)  *
50d78e98 includes/common.inc      (Dries Buytaert       2004-07-13 07:21:14 +0000 1663)  * Arbitrary elements may be added using the $args associative array.
50d78e98 includes/common.inc      (Dries Buytaert       2004-07-13 07:21:14 +0000 1664)  */
f8329dd4 includes/common.inc      (Dries Buytaert       2002-04-27 13:19:37 +0000 1665) function format_rss_item($title, $link, $description, $args = array()) {
009b1afe includes/common.inc      (Dries Buytaert       2003-12-13 14:59:55 +0000 1666)   $output = "<item>\n";
56d2664a includes/common.inc      (Dries Buytaert       2008-04-14 17:48:46 +0000 1667)   $output .= ' <title>' . check_plain($title) . "</title>\n";
56d2664a includes/common.inc      (Dries Buytaert       2008-04-14 17:48:46 +0000 1668)   $output .= ' <link>' . check_url($link) . "</link>\n";
56d2664a includes/common.inc      (Dries Buytaert       2008-04-14 17:48:46 +0000 1669)   $output .= ' <description>' . check_plain($description) . "</description>\n";
0fef1502 includes/common.inc      (Steven Wittens       2006-07-17 15:42:55 +0000 1670)   $output .= format_xml_elements($args);
0fef1502 includes/common.inc      (Steven Wittens       2006-07-17 15:42:55 +0000 1671)   $output .= "</item>\n";
0fef1502 includes/common.inc      (Steven Wittens       2006-07-17 15:42:55 +0000 1672)
0fef1502 includes/common.inc      (Steven Wittens       2006-07-17 15:42:55 +0000 1673)   return $output;
0fef1502 includes/common.inc      (Steven Wittens       2006-07-17 15:42:55 +0000 1674) }

We could/should use the new Serializer stuff for this.

This means:

- replacing those functions
- refactoring node_feed() to use it
- refactoring Views to use it (Views currently uses it's own completely custom RSS formatting instead of core's).

CommentFileSizeAuthor
#100 drupal-aggregator-zend-followup-1839468-98.patch1.52 KBParisLiakos
#96 drupal-aggregator-zend-1839468-96.patch1.59 KBParisLiakos
#91 drupal-zend-reader-proxy-1839468-91.patch12.83 KBtwistor
#87 drupal-zend-reader-proxy-1839468-85.patch8.31 KBtwistor
#86 drupal-aggregator-zend-1839468-86.patch1.29 KBParisLiakos
#60 drupal-zend_feed-1839468-60.patch817.93 KBParisLiakos
#60 zend-for-review-do-not-test.patch20.97 KBParisLiakos
#59 1839468-59-composer-only.patch403 bytesdamiankloip
#56 1839468-56.patch20.04 KBdamiankloip
#56 interdiff-1839468-56.txt20.04 KBdamiankloip
#54 drupal-zend_feed-1839468-54.patch769.62 KBParisLiakos
#53 drupal-zend_feed-1839468-53.patch769.63 KBParisLiakos
#53 zend-for-review-do-not-test.patch21.13 KBParisLiakos
#49 zend-for-review-do-not-test.patch21.09 KBParisLiakos
#49 drupal-zend_feed-1839468-49.patch769.6 KBParisLiakos
#49 interdiff.txt1.36 KBParisLiakos
#48 zend-for-review-do-not-test.patch20.42 KBParisLiakos
#43 drupal-zend_feed-1839468-43.patch768.93 KBParisLiakos
#43 interdiff.txt664 bytesParisLiakos
#39 for-review-do-not-test.patch20.41 KBParisLiakos
#39 drupal-zend_feed-1839468-39.patch768.92 KBParisLiakos
#39 interdiff.txt5.56 KBParisLiakos
#33 for-review-33-do-not-test.patch20.21 KBParisLiakos
#33 interdiff.txt5.3 KBParisLiakos
#33 drupal-zend_feed-1839468-33.patch768.72 KBParisLiakos
#31 for-review-do-not-test.patch20.89 KBParisLiakos
#28 drupal-zend_feed-1839468-28.patch769.4 KBParisLiakos
#28 interdiff.txt945 bytesParisLiakos
#24 interdiff.txt19.43 KBjibran
#23 drupal-zend_feed-1839468-23.patch768.48 KBParisLiakos
#15 drupal-zend_feed-1839468-15.patch749.04 KBParisLiakos
#7 drupal-zend_feed-1839468-7.patch1.97 MBParisLiakos
#6 composer.patch776 bytesdawehner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Crell’s picture

In the Symfony world, everyone uses the Zend_Feed library from Zend Framework.

http://framework.zend.com/manual/2.0/en/modules/zend.feed.introduction.html

I've not used but did review it for a project earlier this year and largely liked it. It does RSS and Atom, and supports Pubsubhubbub.

IMO that would be the most robust way to handle RSS and Atom handling. No need to write our own serializer at all.

(For Atom, we may want to use a serializer for the payload itself, since Atom doesn't specify that. But the Atom parts in particular we should use Zend_Feed for.)

Anonymous’s picture

From a cursory review, Zend_Feed looks pretty solid. While it would be nice to not have 2 different serializing tools in core, Zend_Feed seems like it would save us a lot of work for this subset of serializations.

Crell’s picture

Title: Use the Serializer for RSS » Replace core and Views RSS handling with Zend Feed
Component: base system » views.module

Talked some with the Views folks, too. Based on that, and Lin's comment, I'm going to suggest we refocus this issue to ripping out all existing RSS support in core (we have 2 systems now, including Views), and replacing it with Zend Feed and a single Views display plugin. Revised issue summary coming momentarily.

Anonymous’s picture

I took my first good look at NormalizerAwareInterface today, and I'm realizing that we could actually use Zend_Feed from within an Encoder. This would allow us to provide the same interface on top of RSS and Atom as we do on all other formats, Serializer.

Crell’s picture

I have no strong preference regarding using the serializers as a thin wrapper around Zend Feed. Whatever gets the job done easiest. We still need someone to roll the Composer patch for it, though.

dawehner’s picture

FileSize
776 bytes

I'm not sure about the composer.json codestyle, but this patch pulls in the full zend framework at the moment, see https://github.com/composer/composer/issues/1063 and maybe https://github.com/zendframework/zf2/pull/1934

At least the full zend framework is too big for drupal.org at the moment.

ParisLiakos’s picture

Status: Active » Needs review
FileSize
1.97 MB

This does not pull the whole framework but zend feed requires a few components:

    "require": {
        "php": ">=5.3.3",
        "zendframework/zend-escaper": "self.version",
        "zendframework/zend-stdlib": "self.version",
        "zendframework/zend-servicemanager": "self.version",
        "zendframework/zend-uri": "self.version",
        "zendframework/zend-version": "self.version"
    },

Patch is pretty big, so maybe pull Zend Feed first and then cleanup views and aggregator?

xjm’s picture

IMO it's way too late in the release cycle for this and it should be moved to D9.

xjm’s picture

Assigned: Unassigned » catch

We chatted about this a bit in IRC. Let's see what catch thinks since he filed the issue. :) D9?

Anonymous’s picture

I'm not assigning this to myself or anything... but if previous experience is any indication, it would be a relatively simple patch once we know how we're going to get the Zend Feed dependency in. I personally think we could still keep it as a maybe for D8.

xjm’s picture

Well, it's not a matter of just adding it--we'd also need to make Views support it, etc. And then the swath of conversion issues.

Anonymous’s picture

Since we already have two RSS serializers, we could limit the scope to replacing one of the serializers (the not-Views one) with something that builds on the serialization system. Then, if that is successful we could have another issue to swap out the Views one.

Since there is already integration between the serialization system and Views (and Damian has experience with both), I imagine this second part would probably go smoothly, but even if it doesn't happen we still have a win.

ParisLiakos’s picture

i just went through this, and i dont think the conversion issues are that many...after we convert taxonomy_term_feed to a view then we can get rid of node_feed, which leaves us with two places to convert:

  1. Rss style plugin in views
  2. Aggregator

I already started converting aggregator in my sandbox..you know just getting to know zend feed, so even if this doesnt make it, i dont have any problem:)
Here is how awesome aggregator's parser looks after conversion
http://drupalcode.org/sandbox/rootatwc/1969260.git/blob/7f4ffe6:/core/mo...

thats 320 less LOC for me to maintain:)

ParisLiakos’s picture

here is the full list of dependencies:

  1. zendframework/zend-version (2.1.5)
  2. zendframework/zend-stdlib (2.1.5)
  3. zendframework/zend-servicemanager (2.1.5)
  4. zendframework/zend-i18n (2.1.5)
  5. zendframework/zend-validator (2.1.5)
  6. zendframework/zend-escaper (2.1.5)
  7. zendframework/zend-uri (2.1.5)
  8. zendframework/zend-feed (2.1.5)
ParisLiakos’s picture

thanks to the awesome guys at Zend and Crell for contacting them, the dependency list, just got way smaller:) yay!

Crell’s picture

The patch in #15 is down to only two dependencies: stdlib and escaper. IMO that's small enough to be acceptable. Huge thanks to MWOP and Padriac from Zend for making that happen!

twistor’s picture

Awesome, MWOP, Padriac, and Crell ++

I would love to help with this.

Aside:
I notice that this uses ctype_*. I remember that being discouraged before, but it looks like lots of things that we've pulled in now depend on it. Is this documented somewhere?

ParisLiakos’s picture

Assigned: catch » ParisLiakos
Status: Needs review » Needs work

I am gonna post a patch with the conversion of aggregator parser, if i find time in weekend i ll convert views too

Anonymous’s picture

Paris, thanks for the work on this. I just want to point out the discussion earlier in the thread, I think it would be good to explore whether Serializer could be used as a thin wrapper around this, which would make it possible to request RSS on REST requests.

I don't know if you're coming to DrupalCon, but I'll be there and would be happy to talk about how Serializer works and figure out whether my suggestion can be implemented in a sane way.

ParisLiakos’s picture

sure, i am not familiar at all yet with serialization module, but i will study it tonight, and see how i can combine them

edit: no i wont be on DrupalCon unfortuantely, but i am on irc most of the time

Crell’s picture

For my part, I'm happy with whatever gets us using this library fastest. :-)

ParisLiakos’s picture

so, what i fail to understand after going through serialization and rest modules is why someone would want to output an entity alone in rss or atom format? or does it support outputting lists of entities and i couldn't find this possibility?

ParisLiakos’s picture

Assigned: ParisLiakos » Unassigned
Status: Needs work » Needs review
FileSize
768.48 KB

here is the aggregator conversion
i got stuck in views, so i let someone more familiar to do the job there

jibran’s picture

FileSize
19.43 KB

@ParisLiakos great work.
This made me smile

 use Drupal\Core\Database\Database;
 use Drupal\Core\SystemListingInfo;
 use Drupal\Core\Template\Attribute;
+use Zend\Feed\Writer\Writer;
+use Zend\Feed\Reader\Reader;

Great patches need interdiffs :D

Status: Needs review » Needs work

The last submitted patch, drupal-zend_feed-1839468-23.patch, failed testing.

ParisLiakos’s picture

Status: Needs work » Needs review

#23: drupal-zend_feed-1839468-23.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, drupal-zend_feed-1839468-23.patch, failed testing.

ParisLiakos’s picture

Status: Needs work » Needs review
FileSize
945 bytes
769.4 KB

seems Reader is caching some stuff:)
this should fix tests

thanks jibran for the interdiff!

about views:

i have the writer plugins registered already in views.services.yml
The conversion should probably happen in \Drupal\views\Plugin\views\style\Rss::render() right?
anywhere thats where i got stuck, just leaving notes, might be helpful for someone

jibran’s picture

Issue tags: +VDC

Tagging.

Crell’s picture

Can you post a -for-review-do-not-test patch as well that doesn't include the Zend libs? That will make it easier to review.

ParisLiakos’s picture

FileSize
20.89 KB

sure!

Crell’s picture

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/parser/DefaultParser.php
@@ -26,353 +29,48 @@
+    foreach ($channel as $item) {
+      // Move the values to an array as expected by processors.
+      $parsed_item['title'] = $item->getTitle();
+      $parsed_item['guid'] = $item->getId();
+      $parsed_item['link'] = $item->getLink();
+      $parsed_item['description'] = $item->getDescription();
+      $parsed_item['author'] = '';
+      if ($author = $item->getAuthor()) {
+        $parsed_item['author'] = $author['name'];
+      }
+      $parsed_item['timestamp'] = '';
+      if ($date = $item->getDateModified()) {
+        $parsed_item['timestamp'] = $date->getTimestamp();

Since some of these keys are conditionally set, you need to explicitly reset $parsed_item at the start of the loop.

That said, why the translation? Why not just pass it up to the caller directly?

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/parser/DefaultParser.php
@@ -26,353 +29,48 @@
+    // Clear the page and block caches.
+    Cache::invalidateTags(array('content' => TRUE));

Uh, why? We're moving the cache to be short-lived anyway. We need to blast the cache less, not more. :-)

We should also register the Zend feed services in core.services.yml, since core is providing them. Views and Aggregator don't "own" them, and I should be able to use it directly without enabling those modules.

ParisLiakos’s picture

That said, why the translation? Why not just pass it up to the caller directly?

Well, to do that all potential processors/parser plugins should standarize on Zend Feed, dunno if we want that? this way anyone can use whatever implementation sees fit to parse items.

Uh, why? We're moving the cache to be short-lived anyway. We need to blast the cache less, not more. :-)

Well, that was in the old code, as cache_invalidate_tags(), i just used the class directly, so, yay! now the parser is unit-testable!
i would remove it, but dunno if it will bring problems, given that aggregator test coverage is not the best:P

Fixed the other two points!:)

Status: Needs review » Needs work
Issue tags: -VDC

The last submitted patch, drupal-zend_feed-1839468-33.patch, failed testing.

ParisLiakos’s picture

Status: Needs work » Needs review
Issue tags: +VDC

#33: drupal-zend_feed-1839468-33.patch queued for re-testing.

ParisLiakos’s picture

Anonymous’s picture

I took a look at the patch, I don't think it makes sense to look at using serialization module in the aggregator part yet.

dawehner and I talked about the Views part of this issue today and we both think it would make sense to use a thin wrapping layer around Zend for that, just so that Views is handling all data serializations in the same way.

It might make sense to change the scope of this issue to focus on the Aggregator integration, since it is already passing. Then we could get the library in and move the Views refactoring to a different issue.

dawehner’s picture

Just in general this looks really great. It removes like a ton of custom code, even on the other hand the full framework is pretty big.

+++ b/core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.phpundefined
@@ -0,0 +1,86 @@
+   * @param  string $name

Sorry about the nitpick: there are two spaces after @param

+++ b/core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.phpundefined
@@ -0,0 +1,86 @@
+    // this is just for performance instead of using str_replace

"This" ... "."

+++ b/core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.phpundefined
@@ -0,0 +1,86 @@
+  /**
+   * Injects the service container used by this object.
+   *
+   * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
+   *   The service container this object should use.

We could just use @inheritdoc

ParisLiakos’s picture

thanks for the review..fixed above, also merged the fix for the plugins, so that the bridge can manage both reader and writer ones

Status: Needs review » Needs work
Issue tags: -VDC

The last submitted patch, drupal-zend_feed-1839468-39.patch, failed testing.

ParisLiakos’s picture

Status: Needs work » Needs review

#39: drupal-zend_feed-1839468-39.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +VDC

The last submitted patch, drupal-zend_feed-1839468-39.patch, failed testing.

ParisLiakos’s picture

Status: Needs work » Needs review
FileSize
664 bytes
768.93 KB

forgot to update aggregator accordingly

Status: Needs review » Needs work
Issue tags: -VDC

The last submitted patch, drupal-zend_feed-1839468-43.patch, failed testing.

ParisLiakos’s picture

Status: Needs work » Needs review
Issue tags: +VDC

#43: drupal-zend_feed-1839468-43.patch queued for re-testing.

dawehner’s picture

Title: Replace core and Views RSS handling with Zend Feed » Replace aggregator rss parsing with Zend Feed

Adapt title.

Anonymous’s picture

I've created a follow up issue to handle the Views RSS, #2003108: Switch Views RSS to use Serializer/Zend

ParisLiakos’s picture

here is a just for review patch, that i forgot to post in #43

ParisLiakos’s picture

here is the patch with added legal info on some copy pasted code from Zend's ServiceManager

Status: Needs review » Needs work
Issue tags: -VDC

The last submitted patch, drupal-zend_feed-1839468-49.patch, failed testing.

ParisLiakos’s picture

Status: Needs work » Needs review
Issue tags: +VDC

#49: drupal-zend_feed-1839468-49.patch queued for re-testing.

Crell’s picture

Assigned: Unassigned » Dries
Status: Needs review » Reviewed & tested by the community

I think the only thing blocking this now is Dries' approval to proceed. Dries, please proceed. :-)

ParisLiakos’s picture

here is a reroll since patch above does not apply anymore

ParisLiakos’s picture

no longer applies, reroll

mwop’s picture

Just a quick note: at the time the patch was originally created, we were still in RC phase for ZF 2.2.0; at this time, we've actually released 2.2.1 already, and the composer.json should more correctly use the version ">=2.2.0".

damiankloip’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
20.04 KB
20.04 KB

Thanks! Let's update that dependency.

Status: Needs review » Needs work

The last submitted patch, 1839468-56.patch, failed testing.

ParisLiakos’s picture

thanks mwop!
i guess we can remove the
"minimum-stability": "dev"
bit from our composer.json now too.

This is gonna conflict with #1989230: Update to Symfony 2.3 though, so maybe wait?

damiankloip’s picture

FileSize
403 bytes

Yeah, sounds good to me. Here is a patch just containing the composer.json changes, just to make it easier later on..

ParisLiakos’s picture

Component: views.module » aggregator.module
Status: Needs work » Needs review
FileSize
20.97 KB
817.93 KB

symfony update committed, here is a reroll of #54 with the stable zend version

Berdir’s picture

+++ b/composer.jsonundefined
@@ -19,7 +19,8 @@
-    "phpunit/phpunit": "3.7.*"
+    "phpunit/phpunit": "3.7.*",
+    "zendframework/zend-feed": "2.2.*"

I *thought* that we always specify exact dependencies so that the result is stable.

For example, let's say I want to update guzzle, then doing a composer update will not only update guzzle but also zend-feed because there was a new minor version.

*thought* because I thought that we were already doing this but the examples above show that we don't?

ParisLiakos’s picture

Status: Needs review » Needs work
Issue tags: -VDC

The last submitted patch, drupal-zend_feed-1839468-60.patch, failed testing.

ParisLiakos’s picture

Status: Needs work » Needs review
Issue tags: +VDC

#60: drupal-zend_feed-1839468-60.patch queued for re-testing.

ParisLiakos’s picture

Status: Needs review » Reviewed & tested by the community

back to rtbc

damiankloip’s picture

Status: Reviewed & tested by the community » Needs review

I'm sorry, you just can't rtbc your own patches :)

Plus this does update a few deps.

ParisLiakos’s picture

i rerolled a rtbc'ed patch to resolve conflicts, usually thats fine
but anyway

Crell’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +WSCCI

OK, I will then.

damiankloip’s picture

Issue tags: -WSCCI

Super, thanks. sorry Paris.

Crell’s picture

Issue tags: +WSCCI

Restoring tag.

effulgentsia’s picture

Can someone update the issue summary explaining what is already done by the RTBC patch, and what follow ups will be needed if this is committed?

effulgentsia’s picture

Issue tags: +WSCCI

.

Dries’s picture

Before I commit this, I'd love to know what follow-ups are required. Thanks!

Dries’s picture

Issue summary: View changes

Added issue summary with implementation plan.

ParisLiakos’s picture

there is just one direct..the other two where already there
#2003108: Switch Views RSS to use Serializer/Zend
I updated the issue summary

ParisLiakos’s picture

Issue summary: View changes

Update isssue summary with newest plan of action

catch’s picture

afaik the serializer parts of this aren't required once this gets in. If they didn't happen it'd mean we ship with either one or two home-grown RSS serializers (no change from now) and use Zend Feed for parsing (this patch).

catch’s picture

Issue summary: View changes

Update aggregator view conversion link

ParisLiakos’s picture

to better explain catch's comment meaning:

Moving on with this patch means:

- Worst case: we ship with 2 serializers and a parser each using its own API.. Which is the status exactly right now... But with this patch we get a much more solid parser for aggregator.
- Best case: this patch makes #2003108: Switch Views RSS to use Serializer/Zend possible, which in combination with views conversions in the issue summary, will unify our RSS handling to Zend Feed.

So nothing to lose here, whatever the outcome of other issues is.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x.

jibran’s picture

Title: Replace aggregator rss parsing with Zend Feed » Change notice: Replace aggregator rss parsing with Zend Feed
Assigned: Dries » Unassigned
Priority: Normal » Critical
Status: Fixed » Active
Issue tags: +Needs change record

Let's add change notification.

Crell’s picture

Title: Change notice: Replace aggregator rss parsing with Zend Feed » Replace aggregator rss parsing with Zend Feed
Priority: Critical » Normal
Status: Active » Fixed
Issue tags: -Needs change record

Change notice added: https://drupal.org/node/2023905

quicksketch’s picture

Although it's clearly too late for this issue, I'll retroactively voice my opinion that THIS IS CRAZY.

So we removed 500 lines of custom code in this patch. Yay!

Then we added an external library that is 25,000 lines of new code!? Did we benchmark how much inevitably slower and more resource intensive this is? It seems, like everything else we've done in D8, that this inevitably will lead to slower, more expensive code. Even after we replace the Views code, is there any chance we'd be able to recoup the cost of a bloated library like this?

catch’s picture

Status: Fixed » Active
Issue tags: +needs profiling

For profiling I'm not that concerned about this patch because it only replaces aggregator feed parsing. The frequency is configurable, the network requests make it guaranteed to be slow anyway, it should only happen in cron/queue, and it's an optional core module.

Using this for generating our own RSS feeds it definitely needs profiling though, but that's not done here.

While we're here though, I I don't understand this hunk, or why it's in _drupal_bootstrap_code(). Nothing should be added to _drupal_bootstrap_code() at this point for a start. Also why defining a writer service when nothing uses it yet. Feels like jumping the gun on the other patches and it's just dead/unused services at the moment which is not nice.

  // Set our bridge extension manager to Zend Feed.
  Reader::setExtensionManager(Drupal::service('feed.bridge.reader'));
  Writer::setExtensionManager(Drupal::service('feed.bridge.writer'));
twistor’s picture

@catch

I discussed converting the ZfExtensionManagerSfContainer into a real service that proxies the calls to Read::*() with ParisLaikos. It would also hide some of calls that aren't supported since we didn't pull in ZendHttp.

Also, #2025643: Add proxy services to Zend\Reader and Zend\Writer for better DX.

ParisLiakos’s picture

with the calls in _drupal_bootstrap_code:

Overall Summary	
Total Incl. Wall Time (microsec):	270,042 microsecs
Total Incl. CPU (microsecs):	264,000 microsecs
Total Incl. MemUse (bytes):	16,078,680 bytes
Total Incl. PeakMemUse (bytes):	16,176,320 bytes
Number of Function Calls:	31,464

Without them

Overall Summary	
Total Incl. Wall Time (microsec):	257,130 microsecs
Total Incl. CPU (microsecs):	252,000 microsecs
Total Incl. MemUse (bytes):	15,995,624 bytes
Total Incl. PeakMemUse (bytes):	16,094,304 bytes
Number of Function Calls:	31,264

I am not sure where else to set the serviceManager though..the proxy solution, we discussed with twistor is maybe the best one

catch’s picture

Is that really 200 function calls removed?

We could just move the services to aggregator module for now, don't see any need for them to be provided as core services.

Crell’s picture

Assuming Feeds module survives to Drupal 8, I'm sure it would want to leverage these services without enabling Aggregator and its UI. Having a service in the DIC has virtually no overhead at runtime unless it's used.

ParisLiakos’s picture

Title: Replace aggregator rss parsing with Zend Feed » [Followup] Replace aggregator rss parsing with Zend Feed
Status: Active » Needs review
FileSize
1.29 KB

lets just do that..it might not be DX frendly, but it restores performance till me or twistor finds time to work on the proxy

twistor’s picture

Title: [Followup] Replace aggregator rss parsing with Zend Feed » Replace aggregator rss parsing with Zend Feed
FileSize
8.31 KB

Here's a really quick sketch.

The issue isn't where the service is defined as much as when we set the extension manager. That said, if we define the service in aggregator, then any module that wants to use it will have to depend on aggregator, or redefine it :/

This definitely needs work, I ignored the writer for now. ZfExtensionManagerSfContainer should be broken up into just a bridge class that is extended/proxied in separate classes for the Reader and Writer.

This also includes part of #2025643: Add proxy services to Zend\Reader and Zend\Writer for better DX so that we can avoid the reset calls.

twistor’s picture

Title: Replace aggregator rss parsing with Zend Feed » [Followup] Replace aggregator rss parsing with Zend Feed

Bah, cross post.

catch’s picture

@Crell Feeds could register it's own service, in the same way as Aggregator no?

twistor’s picture

It just dawned on me that we could expose Zend\Feed\Reader\Reader directly as a service, and call setExtensionManager() from there. But, that seems even uglier. Either way we're faking a static class as an object. The proxy approach gives us a little more control and doesn't hide the facts as much as just using Reader as an object in the container. Either way *should* work though. It also allows us a place to document the methods we actually support as I don't think there are any plans to implement bridges for Zend\Http and Zend\Cache

twistor’s picture

Ok, this is pretty fleshed out.

twistor’s picture

As an API consumer, this is how I would like things to look. It allows me to easily register new extensions (which I already have some planned) and easily discover the supported methods. It took quite a bit of time trawling through Zend\Feed for me to get this far.

As to where the service should be defined. It's not just Aggregator and Feeds. It's any module that consumes or creates feeds. I'm not sure how many there are in contrib ATM, but I know there's more than a few. Each module would have to copy/paste 65 lines of Yaml. This also duplicates objects in memory, if for example, you are running Aggregator and Feeds on the same site. During cron both modules would pull in duplicate dependencies. Not a huge deal, granted.

twistor’s picture

@Crell, Feeds is already ported.

catch’s picture

This patch also broke the installer check for when there's an existing database. Rather than 'Drupal is already installed' you now get

The service definition "feed.bridge.reader" does not exist.

https://drupal.org/node/1987262#comment-7615763

catch’s picture

Category: task » bug
Priority: Normal » Critical

This patch also broke the installer check for when there's an existing database. Rather than 'Drupal is already installed' you now get

The service definition "feed.bridge.reader" does not exist.

https://drupal.org/node/1987262#comment-7615763

Note to reproduce this you need everything set up correctly for install, then add a database that's already been installed to in the database settings. Other bugs elsewhere get triggered for different variations (like no settings.php).

ParisLiakos’s picture

ok, we should get proxy to #2025643: Add proxy services to Zend\Reader and Zend\Writer for better DX, this issue is start getting huge. lets go forward with the simple solution here

catch’s picture

Priority: Critical » Normal
Status: Needs review » Reviewed & tested by the community

#95 is resolvable by fixing other parts of the install process but still it exposes that this is a strange place to put it.

Downgrading from critical again. I like #96 to close this one out, then we can continue in #2025643: Add proxy services to Zend\Reader and Zend\Writer for better DX.

RTBC if the bot comes back green.

catch’s picture

Issue tags: -WSCCI, -needs profiling, -VDC

Status: Reviewed & tested by the community » Needs work
Issue tags: +WSCCI, +needs profiling, +VDC

The last submitted patch, drupal-aggregator-zend-1839468-96.patch, failed testing.

ParisLiakos’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
1.52 KB

just rerolling

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

fix remaining tasks