Behavior if link if isPermaLink is false #365

Open
B0rner opened this Issue May 15, 2014 · 1 comment

Projects

None yet

1 participant

@B0rner
B0rner commented May 15, 2014

Hi,
i use simplePie (1.3.1) with different feeds. Some feeds, like podcasts, does not publish an valid item-link to an webpage. In this situation simplePie has its sepcial, own behavior, I think.

Scenario 1:
The RSS feed item does have an <link> tag, but isPermaLink is false.
Example:
<link>http://wb.page</link> <guid isPermaLink="false">123</guid>. In this case, get_permalink() returns an link, that is an combination of link and id, like: http://wb.page/123

Scenario 2:
The RSS feed item does not have an <link> tag and isPermaLink is false <guid isPermaLink="false">123</guid>.
Here simplepie get_permalink() returns the content of the global <link> Element. That mostly points to the page of the publisher, but have "nothing" todo with the content itself.

From my point of view, the result of get_permalink() is not correct in both cases. If isPermaLink="false" so get_permalink() should not return something else, that could (perhaps) be a link. Maybe false is an more adequate return value?

Btw: is there a way to get the state of the attribute isPermaLink? So i could write an workaround for my application, like: provide the attached media, if this is an podcast and no permaLink is available.

Thank you.

@B0rner
B0rner commented May 16, 2014

If someone gets the same situation: i made a workaround, that works for me. If you iterate trough an feed, so you can access every single feed. This is $item in the following listing.

public function isPermaLink($item)
{
    $isPermalink = true;      //set Default
    $guid = $item->get_item_tags('','guid');   //grap  <guid> element
    $arrIt = new RecursiveIteratorIterator(new RecursiveArrayIterator($guid[0]));
    foreach ($arrIt as $sub) {      //iterate trough element
       $subArray = $arrIt->getSubIterator();
       //if you find an 'isPermaLink' sttribute, set value to false, if it is false
       if (isset($subArray['isPermaLink']) && $subArray['isPermaLink'] == "false") 
           {$isPermalink = false ;break;}    
    }
    return $isPermalink;

 }

//Update:
one notice: the problem in processing the isPermaLink attribute is, that different RSS providers use that attribute from different point of view. Sometime isPermaLink is set to false, if there is no link present, sometime it's set to false, if the link of an items points to the global webpage, where no item specific content exists and sometimes,it's set to false, if the provider likes to give you the hint/informatione: this link is valid, but not permanent (not until the end of time)
So as long as the RSS feed provider use this isPermaLink with different intension, it's nearly impossible to filter out the real "bad links", which are not points to the full article.
:-(

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