When the activitystream_flickr module is enabled on a site using other modules which take advantage of PEAR, retrieval fails if another module has already required the PEAR HTTP_Request class.

The error message is,

Fatal error: Cannot redeclare _pear_call_destructors() (previously declared in /home/www-home/apps/civicrm-3.1.2/civicrm/packages/PEAR.php:773) in /home/www-home/drupal6/sites/all/modules/activitystream/activitystream_flickr/PEAR/PEAR.php on line 783

(An example module which can trigger this conflict is CiviCRM.)

Solution is to check whether class_exists('HTTP_Request') before requiring the file. Because phpFlickr uses the directory path in its call to require_once, the previous require_once of another version of same does not get picked up.

Comments

xurizaemon’s picture

StatusFileSize
new5.08 KB

Looks like this patch applies to both 1.x and 2.x series. Check if class_exists() before require.

xurizaemon’s picture

Title: Conflicts with other modules using PEAR » activitystream_flickr's phpFlickr conflicts with other modules using PEAR HTTP_Request

Updating title

xurizaemon’s picture

Status: Active » Needs review
StatusFileSize
new4.99 KB

require_once() implements the if statement itself; the bug here is that the path to the required file has been artificially made unique, which makes the use of require_once() effectively a call to require() ...

Here's a better patch, which seems to play nicely with other systems using PEAR libs in the recommended manner.

PEAR standards* (which we should follow when in PEAR-specific code) add PEAR to the include_path and then reference the file from the top of the PEAR tree. Example fixed issue.

A similar fix appears to have been already applied to the phpFlickr code between v2.3.0.1 (currently included as part of ActivityStream_Flickr) and v2.3.1.1 (current release).

The patch below will only fix the issue reported here; I haven't tested upgrading to the latest phpFlickr release - that's probably worthy of a separate issue** (which would also resolve this one).

* as I understand them - can't find a reference right now - prove me wrong!
** #735406: Update phpFlickr include to current version

akalsey’s picture

Status: Needs review » Fixed

Latest phpLFickr doesn't use PEAR. Updated in dev.

akalsey’s picture

Status: Fixed » Closed (fixed)

In beta2