Hi

I'm getting this error whenever I try to access the /admin page:
Fatal error: Cannot redeclare class Facebook in /myweb/sites/all/modules/fb/facebook-platform/php/facebook.php on line 37

facebook connect and the rest of the pages work fine, even the inside of administration (i.e. admin/build/modules) but the "front admin" crashes with that error.

I have the facebook platform in sites/all/modules/fb/facebook-platform/php/facebook.php and I've even stated it in the settings.php with this: $conf['fb_api_file'] = 'sites/all/modules/fb/facebook-platform/php/facebook.php';

The problem only affects to fb connect, if I disable it, the error doesn't occur.

Any idea of what can be happening?

Thanks

Comments

Dave Cohen’s picture

Status: Active » Needs review

I have a patch, will check in shortly.

Workaround #1 is to disable the facebook connect login block on your admin theme.

Workaround #2 is to apply this patch...

Index: fb.module                                                                
===================================================================
--- fb.module   (revision 2470)                                                 
+++ fb.module   (working copy)                                                  
@@ -153,7 +153,7 @@
   // or at least not overwrite previously declared handler.                    
   set_exception_handler('fb_handle_exception');                                
                                                                                
-  if (!count($cache)) {                                                        
+  if (!count($cache) && !class_exists('Facebook')) {                           
     $filename = variable_get('fb_api_file', 'facebook-platform/php/facebook.ph\
p');                                                                            
     if (!include($filename)) {                                                 
       $message = t('Failed to find the Facebook client libraries at %filename.\
  Read the !readme and follow the instructions carefully.', array(              
Index: fb.install                                                               
===================================================================
--- fb.install  (revision 2470)                                                 
+++ fb.install  (working copy)                                                  
@@ -44,7 +44,12 @@
   $status = array('title' => $t('Facebook Client API'));                       
   $fb_platform = variable_get('fb_api_file', 'facebook-platform/php/facebook.p\
hp');                                                                           
                                                                                
-  if (include($fb_platform)) { // include() better than file_exists().         
+  if (class_exists('Facebook')) {                                              
+    $status['description'] = $t('Facebook Client API loaded.');                
+    $status['severity'] = REQUIREMENT_OK;                                      
+    $status['value'] = $t('Loaded');                                           
+  }                                                                            
+  elseif (include($fb_platform)) { // include() better than file_exists().     
     $status['description'] = $t('Facebook client API found at %path',          
                                 array('%path' => $fb_platform));               
     $status['severity'] = REQUIREMENT_OK;                                      




pcambra’s picture

Status: Needs review » Fixed

With the patch all seems to work fine, thanks Dave!

rontec76’s picture

Status: Fixed » Needs review
StatusFileSize
new819 bytes
new620 bytes

Hi Dave,

I've manually patched and tested. Your suggested code changes seem copacetic.

I tried using your patch pasted above but couldn't get it to work. So I manually made the edits and rerolled the two separate patches.

Thanks for your work on FB module it was great to meet you at the FB BoF session at Drupalcon. I'll probably be seeing you around the issue queues.

Dave Cohen’s picture

Status: Needs review » Reviewed & tested by the community
romina’s picture

Also I have had a 500 internal server error accessing the /admin page and the status report page. Bravenet, my provider, found that it was Fb Connect module. Now, with your patch, everithing works perfectly. Romina

suddenfire’s picture

How do I install the patch I'm a newbie and the code is very confusing for me. I tried putting it at the end fb.module folder and fb.install with it not working of the file but it didn't work. Any advise or links would be greatly appreciated

suddenfire’s picture

Changing line 48 in fb.install from
if (include($fb_platform)) {
to
if (file_exists($fb_platform)) {
solves it.
or

(require_once($fb_platform)) {

rontec76’s picture

Hi Suddenfire,

You need to download the patch files into sites/all/modules/fb and apply them individually using a patch program.

This link should help...

http://drupal.org/patch/apply

Dave Cohen’s picture

Status: Reviewed & tested by the community » Fixed

fixed in rc2

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.