Search code examples
phprsssimplepie

SimplePie through CraftCMS adding #? to feed URL


Okay - simple details first:

Feed URL: http://feeds.wired.com/wired/index

When I access this directly through simplepie and not CraftCMS, the feed loads without issue. When I access it through the CMS template system it throws an error saying the returned XML is effectively garbage. Looking into this, its because the feed host is returning a page not found.

I have dug through the code to find out why it is a page not found on a valid URL and found that in the file:

/library/simplepie/registry.php
public function &create($type, $parameters = array()) (around line 160)

Now in this function I see that a new reflection class is created and new InstanceArgs are sent the parameters. At this point the Feed URL gets changed from:

http://feeds.wired.com/wired/index
to
http://feeds.wired.com/wired/index?#

Effectively this new URL with the added ?# on the end is causing the feed site to return a page not found. And hence all my errors...

This is beginning to hit the end of my abilities - and I would like to know what is causing the ?# to be added and if there is a way to prevent it? Or any other possible solutions to my problem.


Solution

  • I can't explain why it works outside of Craft and not inside, but it definitely looks like a SimplePie bug to me.

    Just created an issue and pull request with the fix for them (https://github.com/simplepie/simplepie/issues/366) and will see about updating it in Craft itself.

    Update: looks my fix didn't broke some of their tests, so we won't be putting that into Craft, but they have acknowledged it needs to be fixed.