Getting a Fatal Error when activating Ultimate Facebook

When I try to activate Ultimate Facebook I get a fatal error:

Plugin could not be activated because it triggered a fatal error
Fatal error: Cannot redeclare class FacebookApiException in {directory}/wp-content/plugins/wpmu-dev-facebook/lib/external/base_facebook.php on line 107

The reason for the error is that a second Facebook plugin was also active - so the two plugins are clashing because they both declare the same function. My temporary solution is to deactivate the other plugin. But this isn't ideal because I want to use some of the functionality from that other plugin, so want to run both.

I found someone else with the same error and they had a solution:
http://wordpress.org/support/topic/plugin-wordpress-social-login-fatal-error-cannot-redeclare-class-facebookapiexception

It's a simple line of code that ensures the function is only declared once.

Just replace:

include(facebook.php);

With this code:

if (!class_exists('FacebookApiException')) {
include_once('facebook.php');
}

Two questions:
1) Where do I add this code to Ultimate Facebook?
2) When Ultimate Facebook updates, it will overwrite my adjusted code, so how can this line of code please be added to Ultimate Facebook, so it gets along nicely with other Facebook plugins?

Thanks

Josh

  • Tom Eagles
    • Syntax Hero

    @Josh

    I am going to defer to the developer @Vladislav on this, but normally looking at the code it would have gone in the main plugin file. And yes when UFB updates it would overwrite it. However maybe he can offer a solution which could be incorporated into the next release, What was the other facebook plugin and do you have a link for it,

    Kindest regards

    Tom

  • Vladislav
    • Dead Eye Dev

    Hello,

    Ultimate Facebook actually checks if the Facebook implementation class exists before requiring the third-party SDK library (although it doesn't check for the exception class - if the implementation class exists, the SDK has been already loaded). The plugin you mentioned however doesn't include the implementation class and works off it's own implementation, hence the conflict. The next Ultimate Facebook release will make sure to safeguard against these kinds of conflicts as well, and if you want I can post a fixed working beta in the meanwhile. However, having said all that, please note that mixing Facebook plugins might not be a very good idea, depending on case by case basis. For an example, the other plugin you tried uses an older Facebook SDK library, which might introduce subtle (or even not so subtle, depending on the bundled version) issues with both plugins.

  • Josh
    • Design Lord, Child of Thor

    Thanks for the reply and explanation. Don't worry about the beta version. I'm happy to just wait until the next update comes out as I have disabled the other one for now.

    Will be good to get that extra code in there. Even though the error was actually due to a different plugin not doing things correctly, it makes WPMUdev look bad when the plugin throws an error when activating!

    Thanks for your help.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.