Working with Feed API Module Installed
spiffyd - September 4, 2008 - 02:18
| Project: | Activity Stream |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
If I install the FeedAPI module, I sometimes get fatal errors (such as when I run cron) because simplepie is called twice (for both feedapi and activity stream).
The error message is like this:
Fatal error: Cannot redeclare class SimplePie in /sites/all/modules/feedapi/parser_simplepie/simplepie.inc on line 38Is there a workaround?

#1
I hit the same problem when using FeedAPI with Activitystream (which also includes the simplepie.inc file). Using both modules causes a PHP error, as the simplepie declarations are attempted twice. Require_once doesn't handle this because there are two different copies of simplepie.inc.
I have got around this my using the simplepie module that is in contrib and adapting FeedAPI simplepie parser, and activitystream to both require this module.
The required change for simplepie is to add this to activitystream_feed.info
dependencies[] = simplepie
in activitystream_feed.module change the line that references the simplepie.inc file to this (it appears twice in the module):
<?php$path = drupal_get_path('module', 'simplepie') .'/lib/simplepie.inc';
?>
The required changes for FeedAPI module are here: http://drupal.org/node/304782
#2
#3
Perhaps we should consider integrating Activitystream with the SimplePie module http://drupal.org/project/simplepie
Then just make simplepie.module a requirement for activitystream to install. That would make sure that we are no conflicting with other modules that use simplepie.inc so long as they are using simplepie.module as well.
#4
What we could do is check to see if one of the simplepie functions exists and only include the file if it doesn't
#5
I thought about doing it that way but my concern is that there may be other modules that use simplepie that are loaded latter in the cycle than activitystream. So you run into an issue where, we check to see if simplepie exists, if it doesn't we load it, then some other module comes along and tries to load it as well and fails. (Not much we can do about that)
Sort of a tricky problem. I guess the best we can do is try and make sure that activitystream plays nice with other modules, and hope, or attempt to update those other modules so they play nice too.
#6
Drupal 7 will solve this problem. There's a module registry and we can easily check to see if any modules have installed Simplepie.
In the meantime, I'm not thrilled about the idea of requiring an external module to make the feeds work. That's another barrier to installation.
Perhaps the module could check to see if the Simplepie module is installed and use that. Then check to see if FeedAPI is installed and use that. And if neither are installed, use it's own copy of simplepie.inc.
#7
Sounds like a reasonable solution. Especially since we'll be able to solve the problem for real once Drupal 7 comes out.
#8
@ comment #3 - that is what the code comment #2 achieves - adds dependency on simplepie module.
Best practice is to not include external code in Drupal CVS - http://drupal.org/node/124978 - adding the simplepie module dependency solves this and the problem of multiple includes of simplepie.
Adding a check for the simplepie module and a fallback to using local copy does reduce the barrier to installation, but at cost of adding extra unnecessary weight to the module.
#9
Adding a dependency also increases the complication of installation.
I think people might underestimate how hard it is for the average user to install modules already. Anything that requires them to go download additional modules manually, install those first, then install something else, is an issue. The Simplepie module doesn't include Simplepie. It requires the user to go get simplepie on their own and upload it to the right place. The only documentation or instructions for doing so are in a readme buried in a subdirectory. Those instructions merely state "Upload simplepie.inc to this directory." Wow, that's useful.
I'm aiming for maximum ease of use. Adding a few bytes to the module is certainly worth making it easy for someone to install and use.
#10
I think it is really nice that you want to make it easy to use.
In the end, though, those users may end up with FeedAPI, too, and then they will file support requests with all the module maintainers...or maybe just quit Drupal.
There is a bigger picture here.
#11
What if we put some effort into improving the installation instructions, and helpfulness of the SimplePie module, and then helped the maintainers of other modules that use the simplepie.inc migrate their modules to using SimplePie.module as well? In my opinion this would probably be the best bet overall.
darrenMK also brings up an important issue in his comment (#8).
#12
Not sure if this even where I need to be but I need some help.
I've been trying to figure out for hours how to setup a feeds, either with feedburner or aggregator-either mod is fine-i have no idea how at this point because I feel like I have to many overlapping mods trying to do the same thing. I'm on Drupal 6.4 a fresh install with the following activated
Aggregator 6.4
Common syndication parser 6.x-1.4
FeedAPI Inherit6.x-1.4
FeedAPI Node Views 6.x-1.3
FeedAPI 6.x-1.4
FeedAPI Node 6.x-1.
SimplePie parser6.x-1.4
Feedburner 6.x-1.0-bet
#13
This is somewhat off topic for this issue as it doesn't seem to be related to the Activity Stream module. You might want to try asking your question in the forums. You'll get a better response there.
Unless of course I'm misreading your question, and you are in fact having issues with the Activity Stream module.
#14
Feeds are available with Drupal core. For instance, feeds to your frontpage would be available at http://domain.com/rss.xml.
You don't need 3rd party modules unless you're trying to accomplish much more such as importing 3rd party feeds to create nodes with them and such. What are you exactly trying to do? All you did here was list a bunch of syndication modules.
#15
subscribing ... also coming across this issue, with FeedAPI's parser_simplepie module and Activity Stream enabled.
#16
subscribing, thanks
#17
I ran into this problem too. Simplifying user install is commendable, but realize that an additional module requirement with slim documentation is easier to deal with than running into this bug and trying to figure it out by searching google for the error string, and then trying to fix it by hacking the code.
#18
I've just run into this problem too, and found it under the Feed API Issue queue (http://drupal.org/node/311039). I had a quick sniff around the 2 modules and couldn't see the problem immediately, so have currently disabled ActivityStream :( Whilst D7 may offer a more elegant solution, waiting is not an option, so I'd vote for utlilizing a dependent SimplePie module, if it's pretty straightforward
#19
2.x now uses the SimplePie module if it's installed. It also checks to see if the simplepie.inc has already been loaded by another module before it includes the library.
The solution to other modules conflicting with Activity Stream will be to install SimplePie.module
#20
Oh you superstar!
#21
Automatically closed -- issue fixed for 2 weeks with no activity.
#22
Sorry to re-open this issue but here's my problem:
Fatal error: Call to undefined function simplepie_require() in /usr/www/virtual/USERNAME/www.NAMEOFSITE.com/sites/all/modules/activitystream/activitystream_feed/activitystream_feed.module on line 13
I have SimplePie module running because Simple Blogroll needs it. Could this be another one of those "battling simplepie modules" bug?
#23
i ran into this...i have activity stream and feed api installed.
feed api asks for the simplepie.inc file, but the result of adding it is the fatal error about the redeclare issue.
What to do?
Thanks,
Da.
#24
#22 - it looks like you don't have the simplepie module installed correctly. The simplepie.inc file may be missing.
#23 - Install the SimplePie module and things will work.
#25
That's not the case.
I encountered the "fatal error" after placing the simplepie.inc in the right place so there must be something else...
Thanks,
Da.
#26
This issue is getting off on a tangent from the original issue.
I've opened an issue about just this problem: #627814: Call to undefined function simplepie_require()