3

I have installed the latest Simplepie code (1.2.1) and I am using the demo code they provide:

<?php

require 'simplepie.inc';

$url = 'http://news.google.com/news?ned=us&topic=h&output=rss';

$feed = new SimplePie();
$feed->set_feed_url($url);
$feed->init();

// default starting item
$start = 0;

// default number of items to display. 0 = all
$length = 0; 

// if single item, set start to item number and length to 1
if(isset($_GET['item']))
{
    $start = $_GET['item'];
    $length = 1;
}

// set item link to script uri
$link = $_SERVER['REQUEST_URI'];

// loop through items
foreach($feed->get_items($start,$length) as $key=>$item)
{

    // set query string to item number
    $queryString = '?item=' . $key;

    // if we're displaying a single item, set item link to itself and set query string to nothing
    if(isset($_GET['item']))
    {
            $link = $item->get_link();
            $queryString = '';        
    }

    // display item title and date    
    echo '<a href="' . $link . $queryString . '">' . $item->get_title() . '</a>';
    echo ' <small>'.$item->get_date().'</small><br>';

    // if single item, display content
    if(isset($_GET['item']))
    {
            echo ' <small>'.$item->get_content().'</small><br>';
    }
    echo '<br>';
}

?>

However, when I load the page in my browser, I get dozens of lines saying:

Deprecated: Assigning the return value of new by reference is deprecated in /home/pliggs/public_html/rss/simplepie.inc on line 7722

Anyone know what's wrong?

I ran their compatibility test and it shows all things have passed.

Zsolt Botykai
  • 50,406
  • 14
  • 85
  • 110
Darrell
  • 37
  • 3
  • 1
    possible duplicate of [Assigning the return value of new by reference is deprecated](http://stackoverflow.com/questions/1086539/assigning-the-return-value-of-new-by-reference-is-deprecated) – Wooble Feb 04 '12 at 14:51

3 Answers3

2

This is a result of SimplePie's PHP 4 compatibility and is nothing in your code. If you want to stop seeing these errors, exclude E_DEPRECATED from your error_reporting:

error_reporting(E_ALL & ~E_DEPRECATED);

If you'd like to fix the errors themselves, you can grab a copy of SimplePie 1.3-dev (which drops PHP 4 compatibility) from GitHub, although keep in mind this is a development version and is unstable.

Ryan McCue
  • 1,628
  • 14
  • 23
  • This is the correct answer. Also see [WP bug database](http://core.trac.wordpress.org/ticket/12709). Simplepie may have been adjusted in the meantime, but i.e. Compare Revisions still isn't with WP 3.4.2... so one still has to mute deprecated warnings. At least for production. – Frank N Nov 14 '12 at 10:06
  • WordPress 3.5 will include SimplePie 1.3.1, which has all of these fixed (as it drops PHP 4 support). – Ryan McCue Nov 14 '12 at 10:12
2

You need to find every instance of "=& new" in the code and delete the "&" which is now deprecated. There are approximately 116 occurrences in the code. It has to do with copies and references of object instantiation.

0

The only occurrence of error_reporting I could find in Version 1.2.1 was this line:

if ((ini_get('error_reporting') & $level) > 0)

This was in simplepie.inc

I'm still not sure how to disable all these warnings short of going with the dev version which I'd prefer not to as I have enough code to debug as is.

Muskie
  • 577
  • 3
  • 21