Fatal error: Cannot redeclare class pear

Having trouble installing serendipity?
Post Reply
Nigel Lew
Regular
Posts: 8
Joined: Mon Oct 10, 2005 2:52 pm
Location: Just downhill from Aspen, Co.
Contact:

Fatal error: Cannot redeclare class pear

Post by Nigel Lew »

Fatal error: Cannot redeclare class pear in /home/httpd/vhosts/jnlew.com/httpdocs/blog/bundled-libs/PEAR.php on line 86

I am getting this error when I try to fetch a plugin. This happens on both sidepanel and the function plugins as well.

I am new to linux(ubuntu) so I may need to dig around for an editor with line numbers to post the required snip of code lol...

My site is running a content-management system/shopping cart one of my colleagues wrote. I am quite certain it is loading pear classes of its own so this may have something to do with it..

Thanks,
Nigel lew


Edit: Fixed via .htaccess less coffee, more thinking
jdrodrigues
Regular
Posts: 36
Joined: Sun Feb 12, 2006 9:27 pm
Location: London
Contact:

Post by jdrodrigues »

I thought I'd dig up another old post just for fun :D

While I don't have any issues with Serendipity itself running, I continue to add several bits to my Serendipity based site. I've ran into a PEAR problem.

The PEAR installation on my webhost is:
PEAR 1.3b3 beta
This seems very old and the code I need to use has problems with this default PEAR, but works fine with the bundled-libs PEAR or a brand new current version.

I installed a local version of PEAR, but had trouble getting some of my own code to work when I put this into the .htacces file:

Code: Select all

php_value include_path '/usr/www/users/myusername/mysitedir/pear/PEAR'
So, I took this out of the bundled-libs PEAR.php:

Code: Select all

// Serendipity-Patch
if (class_exists('PEAR')) {
    return false;
}
// Serendipity-Patch end
And things seem to be OK.

I would prefer to force Serendipity and everthing else to use my own current version local install of PEAR and its libraries, but don't know exactly what to put in the .htaccess file.

Any thoughts ?
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

It sounds like the PEAR libraries are being included multiple times. Perhaps the old PEAR libraries are in a system-wide include path that gets called before yours?
Judebert
---
Website | Wishlist | PayPal
jdrodrigues
Regular
Posts: 36
Joined: Sun Feb 12, 2006 9:27 pm
Location: London
Contact:

Post by jdrodrigues »

The system itself has PEAR, as I mentioned, an old version. But it doesn't seem to be interfering with the s9y bundled-libs PEAR. The discussion in :

http://www.s9y.org/forums/viewtopic.php ... torder=asc

indicates that the code:

Code: Select all

// Serendipity-Patch 
if (class_exists('PEAR')) { 
    return false; 
} 
// Serendipity-Patch end 
was put in by Garvin to deal with when a system level PEAR is called before the bundled-libs version.

So far I have not experienced any problems after removing the above code from bundled-libs PEAR.php

However I would like to find a way (I think it is through .htaccess) for all the files in my site that call PEAR to use the new, current version that I have installed within my hosting space.
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

I think we're in strenuous agreement, here. That code prevents Serendipity from including its own PEAR libraries when the system libraries already include PEAR.

You want to use the new PEAR libraries you downloaded yourself.

I could be mistaken, but I believe the include path is specified in the php.ini. That should affect all PHP calls. If you can change it to remove the old PEAR library path and point to yours instead, it should include your libraries instead of the old ones.

I checked Google, and found this .htaccess command, which might help:

Code: Select all

php_value include_path "newpath:other_paths:."
But I don't know if that will keep that old paths, or if it'll override the paths in the system-wide PHP configuration.

EDIT: a little more searching turns up that this depends at least partly on whether PHP is being run as an Apache module or as a CGI binary. The .htaccess method only works for Apache modules.
Judebert
---
Website | Wishlist | PayPal
Post Reply