Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#9273 closed defect (bug) (fixed)

Add RSS Error handling functionality to RSS Widget displays

Reported by: DD32 Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.8
Component: General Keywords: has-patch
Focuses: Cc:


Upon hitting a SimplePie(and thus, WP_Error) error condition, The RSS widgets die with a fatal error.

Attached patch checks for WP_Error, and exits the function as expected (from pervious behaviour). If the user is an admin (Or its on the dashboard), The user recieves a message along the lines of "RSS Error: WP HTTP: no route to host"

Of course, The check for is_admin() can be removed.. Which might suit it better for cases where non-admins/non-staff access such pages.. Wasnt sure at the time of writing the patch.

Attachments (2)

9273.diff (1.6 KB) - added by DD32 7 years ago.
9273.2.diff (4.9 KB) - added by DD32 7 years ago.

Download all attachments as: .zip

Change History (7)

@DD327 years ago

comment:1 @DD327 years ago

Uh... I might've done that stupidly.

if ( !$rss = fetch_feed($rss['url']) )

Of course, The problem is that fetch_feed() is returning a WP_Error now instead of false.. Since fetch_feed is going to return a simplepie object from now on, I've got a feeling it might be better to just continue to return a WP_Error, and ignore the back-compat since its already gone..

comment:2 @ryan7 years ago

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

(In [10697]) Add RSS Error handling functionality to RSS Widget displays. Props DD32. fixes #9273

comment:3 @DD327 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened


1540	1540	function wp_widget_rss_output( $rss, $args = array() ) { 
1541	1541	    if ( is_string( $rss ) ) { 
1542	1542	        if ( !$rss = fetch_feed($rss) ) 
1543	1543	            return; 
1544	1544	    } elseif ( is_array($rss) && isset($rss['url']) ) { 
1545	1545	        $args = $rss; 
1546	1546	        if ( !$rss = fetch_feed($rss['url']) ) 
1547	1547	            return; 
1548	1548	    } elseif ( !is_object($rss) ) { 
 	1549	        return; 
 	1550	    } 

needs to be cleaned up a bit more, Mainly refactoring the !$rss cases, Might need to check the rest of core for similar uses of fetch_feed().

I'll take a look later.

@DD327 years ago

comment:4 @DD327 years ago

attachment 9273.2.diff added

  • Fixes this ticket.
  • Completes error handling for all current core usage of fetch_feed()
  • s/strstr/stristr/ to handle capitalised feed URL's past the first character(ie, it now handles feed-HTTP://SITE/ as well as feed-http://)
  • changes some crazy wp-includes logic for the rss.png icon for the RSS Widget
    • I dont know why it expects the custom rss.png to be in /wp-includes/ to start with.. Eitherway, The new code is readable..

comment:5 @azaozz7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [10739]) Add RSS Error handling functionality to RSS Widget displays, props DD32, fixes #9273

Note: See TracTickets for help on using tickets.