Ticket #1446 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

break when can't get RSS

Reported by: sewar Assigned to: anonymous
Priority: normal Milestone:
Component: General Version: 1.5.1.2
Severity: normal Keywords: rss
Cc:

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

06/20/05 04:18:03 changed by sewar

  • version changed from 1.5.1.1 to 1.5.1.2.
  • milestone set to 1.6.

08/14/05 23:22:42 changed by dalziel

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.

11/13/05 02:54:50 changed by matt

  • status changed from new to closed.
  • resolution set to fixed.

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

11/30/06 19:41:47 changed by

  • milestone deleted.

Milestone 2.0 deleted