Make WordPress Core

Opened 21 years ago

Closed 21 years ago

Last modified 20 years ago

#1446 closed defect (bug) (fixed)

break when can't get RSS

Reported by: sewar Owned by:
Priority: normal Milestone:
Component: General Version: 1.5.1.2
Severity: normal Keywords: rss
Cc: Focuses:

Description

(Sorry for my not-so-perfect english)

When you open Dashboard in localhost without internet connection, MagpieRSS trying get RSS feeds but it can't, so the page break and you don't see your drafts and the footer.

(in WP1.5.1.2 rss-functions.php)

When MagpieRSS can't get RSS feed it call error function but error function isn't available.

The solution is copy error function from RSSCache class to after fetch_rss function.

The error function will be:

function error ($errormsg, $lvl=E_USER_WARNING) {
	// append PHP's error message if track_errors enabled
	if ( isset($php_errormsg) ) {
		$errormsg .= " ($php_errormsg)";
	}
	if ( MAGPIE_DEBUG ) {
		trigger_error( $errormsg, $lvl);
	}
	else {
		error_log( $errormsg, 0);
	}
}

So now we can use MagpieRSS to get RSS from other sites like Del.icio.us and Flickr without fear of page break.

To get links from Del.icio.us and display they in sidebar, use this:

<?php
	require_once (ABSPATH . WPINC . '/rss-functions.php');

	$delicious_rss = @fetch_rss('http://del.icio.us/rss/sewar/');
	if ( isset($delicious_rss->items) && 0 != count($delicious_rss->items) ) {
		$delicious_rss->items = array_slice($delicious_rss->items, 0, 5);
		foreach ($delicious_rss->items as $item ) {
			echo '<li><a href="' . wp_filter_kses($item['link']) . '">' . wp_specialchars($item['title']) . '</a></li>';
		}
		echo '<li><a href="http://del.icio.us/sewar/">more ...</a></li>';
	} else {
    		echo 'Sorry, there are error when get rss feed.<br />';
		echo '<a href="http://del.icio.us/sewar/">click here to show links in Del.icio.us site.</a> .';
    }
?>

Change History (4)

#1 @sewar
21 years ago

  • Milestone → 1.6
  • Version 1.5.1.1 → 1.5.1.2

#2 @dalziel
21 years ago

I've taken to including the following in any of my plugins that use the Magpie RSS Class:

if(!function_exists('error')) {
	function error ($errormsg, $lvl=E_USER_WARNING) {
	    // append PHP's error message if track_errors enabled
	    if ( $php_errormsg ) { 
	        $errormsg .= " ($php_errormsg)";
	    }
	    if ( MAGPIE_DEBUG ) {
	        trigger_error( $errormsg, $lvl);        
	    }
	    else {
	        error_log( $errormsg, 0);
	    }
	    
	    $notices = E_USER_NOTICE|E_NOTICE;
	    if ( $lvl&$notices ) {
	        $this->WARNING = $errormsg;
	    } else {
	        $this->ERROR = $errormsg;
	    }
	}
}

this way I don't need to edit core files, and it won't conflict with anyone else using the function.

#3 @matt
21 years ago

  • Resolution → fixed
  • Status new → closed

(In [3057]) Add error function back, fixes #1446

#4 @(none)
20 years ago

  • Milestone 2.0

Milestone 2.0 deleted

Note: See TracTickets for help on using tickets.