WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#18704 closed defect (bug) (invalid)

WP_Widget_RSS widget outputs error if 0 posts found in feed. Should output "No posts found"

Reported by: ericlewis Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: Widgets Keywords: has-patch dev-feedback
Focuses: Cc:

Description

The output function for WP_Widget_RSS does a conditional check to see if the feed has returned an error, by checking if $rss->get_item_quantity() returns false. If it does return false the output says "An error occurred," which may not be true if the feed just has no posts yet.

This can be remedied by changing the conditional as I have, to check if $rss->get_item_quantity() is identical to false, so if the method get_item_quantity returns 0 an alternate else if will output "No posts found."

Attachments (1)

18704.patch (718 bytes) - added by ericlewis 3 years ago.

Download all attachments as: .zip

Change History (5)

ericlewis3 years ago

comment:1 ericlewis2 years ago

  • Resolution set to invalid
  • Status changed from new to closed

comment:2 helenyhou2 years ago

  • Milestone Awaiting Review deleted

comment:3 SergeyBiryukov2 years ago

As far as I can see, get_item_quantity() always returns a number (which I assume is the reason for closing).

comment:4 ericlewis2 years ago

Yeah, the issue I was having was that if the fetch_rss() returned bad there would be a wp_error produced, whereas if the parsing of the feed gets far enough to check get_item_quantity(), it is a legitimate feed, that just may have no posts in it.

So perhaps the issue is just with the fact that is an RSS feed has 0 posts, the widget says there is an error with the feed, when it actually just has no posts in it. Not enough to reopen this ticket though, I'm not sure it's a legitimate concern.

Note: See TracTickets for help on using tickets.