Bad return value for $item->get_enclosures() method for "simplepie/simplepie": "^1.4" #460

Open
florinj opened this Issue Aug 1, 2016 · 2 comments

Projects

None yet

2 participants

@florinj
florinj commented Aug 1, 2016 edited

Hi guys,

I'm just started to use simplepie an I am very pleased with its functionalities.
Nice job. You have saved me from "reinventing the wheel".
So I have refactored my little app to use simplepie but I have encountered o small bug related to enclosures...
On zero enclosures the $item->get_enclosures() method returns:
array ( 0 => SimplePie_Enclosure::__set_state(array( 'bitrate' => NULL, 'captions' => NULL, 'categories' => NULL, 'channels' => NULL, 'copyright' => NULL, 'credits' => NULL, 'description' => NULL, 'duration' => NULL, 'expression' => NULL, 'framerate' => NULL, 'handler' => NULL, 'hashes' => NULL, 'height' => NULL, 'javascript' => NULL, 'keywords' => NULL, 'lang' => NULL, 'length' => NULL, 'link' => NULL, 'medium' => NULL, 'player' => NULL, 'ratings' => NULL, 'restrictions' => array ( 0 => SimplePie_Restriction::__set_state(array( 'relationship' => 'allow', 'type' => NULL, 'value' => 'default', )), ), 'samplingrate' => NULL, 'thumbnails' => NULL, 'title' => NULL, 'type' => NULL, 'width' => NULL, )), ),
It should return:
null
( or maybe an empty array() ? )
I use PHP Version 5.5.9-1ubuntu4.17.

@florinj
florinj commented Aug 1, 2016

As a temporary measure I had to comment (in item.php) this piece of code line ~2880:
/*
if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width))
{
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
$this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
}
*/

@mblaney
Member
mblaney commented Aug 2, 2016

hi @florinj, something must be set in the lines you've commented out, otherwise the assignment wouldn't happen and the function would return null as you've suggested. $restrictions_parent looks like the obvious candidate for what's causing your problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment