Ticket #3527 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

wp-includes/rss-functions.php function get_rss has a bug

Reported by: zuzara Assigned to: anonymous
Priority: low Milestone: 2.0.8
Component: General Version: 2.0.6
Severity: minor Keywords: get_rss
Cc:

Description

Version 2.0.6 has a typo bug in wp-include/rss-functions.php ( Revision 4495, wp-includes/rss.php )

*** rss-functions.php   2007-01-05 22:30:06.000000000 +0900
--- rss-functions.php.new       2007-01-05 22:32:49.000000000 +0900
***************
*** 838,844 ****
  }

  function get_rss ($uri, $num = 5) { // Like get posts, but for RSS
!       $rss = fetch_rss($url);
        if ( $rss ) {
                $rss->items = array_slice($rss->items, 0, $num_items);
                foreach ($rss->items as $item ) {
--- 838,845 ----
  }

  function get_rss ($uri, $num = 5) { // Like get posts, but for RSS
!       $num_items = $num;
!       $rss = fetch_rss($uri);
        if ( $rss ) {
                $rss->items = array_slice($rss->items, 0, $num_items);
                foreach ($rss->items as $item ) {

Change History

(follow-up: ↓ 2 ) 01/06/07 10:24:15 changed by markjaquith

  • status changed from new to closed.
  • resolution set to worksforme.
  • milestone deleted.

Looks fine to me in /branches/2.0/ and /trunk/

(in reply to: ↑ 1 ) 01/11/07 03:00:23 changed by yskin

  • status changed from closed to reopened.
  • version set to 2.0.6.
  • resolution deleted.
  • summary changed from wp-include/rss-functions.php function get_rss has a bug to wp-includes/rss-functions.php function get_rss has a bug.

Replying to markjaquith:

Looks fine to me in /branches/2.0/ and /trunk/

In the end of /trunk/wp-includes/rss.php

function get_rss ($uri, '''$num = 5''') { // Like get posts, but for RSS 
     $rss = fetch_rss($url); 
     if ( $rss ) { 
         $rss->items = array_slice($rss->items, 0, '''$num_items'''); 
         foreach ($rss->items as $item ) { 
             echo "<li>\n"; 
             echo "<a href='$item[link]' title='$item[description]'>"; 
             echo htmlentities($item['title']); 
             echo "</a><br />\n"; 
             echo "</li>\n"; 
         } 
         return $posts; 
     } else { 
         return false; 
     } 
 } 

$num_items should be $num.

This is a typo bug in both 2.0.6 and 2.1

(follow-up: ↓ 8 ) 01/11/07 03:05:33 changed by foolswisdom

yskin, providing the symptom / how the problem shows itself is also often useful.

01/11/07 03:06:04 changed by foolswisdom

  • milestone set to 2.1.

01/11/07 03:21:38 changed by ryan

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

(In [4718]) Fix typos in get_rss(). Props zuzara. fixes #3527

01/11/07 03:22:00 changed by ryan

  • status changed from closed to reopened.
  • resolution deleted.
  • milestone changed from 2.1 to 2.0.8.

01/11/07 03:22:19 changed by ryan

Fixed in 2.1. Reopening for 2.0.8 consideration.

(in reply to: ↑ 3 ; follow-up: ↓ 10 ) 01/11/07 06:27:34 changed by yskin

Replying to foolswisdom:

yskin, providing the symptom / how the problem shows itself is also often useful.

I was light on this ticket, and than take a look at source code. I thought it is a manifest typo bug, so I reopened it.

I think no problems was cause by this bug, because function get_rss is not be used(called) in wordpress 2.0.6 source code.

My english is poor and my php is poor too, so I am apologise if I make any mistakes.

(follow-up: ↓ 11 ) 01/11/07 19:02:47 changed by Otto42

The function immediately above it, wp_rss(), is basically identical except that it also outputs <UL> tags around the list of links, and does not have the same bug. It should probably be modified to call get_rss() to do its actual work, instead of duplicating the code.

(in reply to: ↑ 8 ; follow-up: ↓ 12 ) 01/11/07 20:47:14 changed by foolswisdom

Replying to yskin:

My english is poor and my php is poor too, so I am apologise if I make any mistakes.

Your bug report and sticking to it when markjaquith missed the problem is fantastic!

I was just providing another tip. Thanks for participating in WordPress!

(in reply to: ↑ 9 ) 01/11/07 20:49:21 changed by foolswisdom

Replying to Otto42:

The function immediately above it, wp_rss(), is basically identical except that it also outputs <UL> tags around the list of links, and does not have the same bug. It should probably be modified to call get_rss() to do its actual work, instead of duplicating the code.

If the problem is on trunk and you are able submit a patch. Probably best to create a new ticket, because I start to get confused when there are new problems added later to a ticket.

(in reply to: ↑ 10 ) 01/12/07 03:04:21 changed by markjaquith

Replying to foolswisdom:

Replying to yskin:

My english is poor and my php is poor too, so I am apologise if I make any mistakes.

Your bug report and sticking to it when markjaquith missed the problem is fantastic!

Doh! I reverted to how the code was and looked again. I was looking at the wp_rss() function right above it which is VERY similar, but did not have the bug described. Nice catch, yskin.

01/30/07 18:11:06 changed by markjaquith

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

(In [4835]) Fix typos in get_rss(). Props zuzara. fixes #3527