Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There is currently no check to determine if the description tag is empty, therefore it gets overwritten by content:encoded, summary, and content respectively (if they are present).
The comment: // Atom feeds have a content and/or summary tag instead of a description tag.
implies mutual exclusion, however I have come across some feeds with both tags (with description containing a summary, but content:encoded containing the whole long article).
I propose a check before overwriting:
aggregator.parser.inc: function aggregator_parse_feed(&$data, $feed)
126
+ if (empty($item['description'])) {
if (!empty($item['content:encoded'])) {
$item['description'] = $item['content:encoded'];
}
elseif (!empty($item['summary'])) {
$item['description'] = $item['summary'];
}
elseif (!empty($item['content'])) {
$item['description'] = $item['content'];
}
+ }
Comment | File | Size | Author |
---|---|---|---|
#3 | 1977830-content-encoded_and_summary_tags_overwrite_description_tag_only_if_not_present.patch | 4.46 KB | samuel.sirois |
Comments
Comment #1
conan_payne CreditAttribution: conan_payne commentedI've found WordPress feeds appear to contain both description and content:encoded.
For example: http://ma.tt/feed/
Open the url in Firefox (just to display it formatted using the feed handler), and the description will be shown correctly. However Aggregator ends up saving the full contents in content:encoded.
Comment #2
conan_payne CreditAttribution: conan_payne commentedLooking at some references to the Atom format, if content:encoded exists, then it should contain the full content; however, if a description also exists then the description element is even more likely to contain the summary/excerpt we want, and that without a check, gets overwritten:
http://www.rssboard.org/rss-profile#namespace-elements-content-encoded
http://www.atomenabled.org/developers/syndication/#contentElement
http://www.xml.com/pub/a/2004/04/07/dive.html
Comment #3
samuel.sirois CreditAttribution: samuel.sirois commentedHere is a patch implementing what @conan_payne has proposed in this issue summary.
Patch includes new test cases & sample XML file.
Applying the patch gives us the same behaviour as Mozilla Firefox on the new test file (aggregator_test_content_and_description_cohabitation.xml).
Comment #4
samuel.sirois CreditAttribution: samuel.sirois commentedComment #6
samuel.sirois CreditAttribution: samuel.sirois commentedChanging status to "Needs review" since tests all pass under PHP 5.5 & MySQL 5.5