Trying to post to Twitter and after I create a node that is supposed to tweet, I get a blank white page. I checked the server error log and found this error:

PHP Fatal error: Cannot redeclare class OAuthSignatureMethod_HMAC_SHA1 in
/var/www/html/newsome/sites/all/modules/oauth/lib/OAuth.php on line 120

The node saves, but clearly chokes on trying to tweet.


tibbsa’s picture

I just spent an hour and a half trying to track this one down. It is related, I assume, to issues #958126: Extra class OAuthException Declaration?, #1334528: Fatal error: Cannot redeclare class OAuthException, #1498642: GAR install results in Fatal error: Cannot redeclare class OAuthException , and #1892612: Problem accessing Google Analytics Reports after installation, which all seem to suggest that the error stems from a conflict between the PHP "OAuth" extension and this module.

From my research and my troubleshooting:

Suggestion #1 is to disable the PHP OAuth module if possible. (Wasn't possible for me.)

Suggestion #2 is to pull the latest development version which, for some classes (OAuthException), includes wrappers to prevent multiple declarations. (Didn't solve it for me: it shut up the OAuthException error, but then I began getting OAuthSignatureMethod_HMAC_SHA1 when attempting to delete a user account.)

Suggestion #3 was to eradicate the entire OAuth module folder and reinstall fresh. That did the trick for me.

Evidently if you've upgraded this module (simply by unpacking a new tarball over the existing files) a few times, "something" might be left behind that breaks things. I doubt it is worth the effort to determine exactly what that was, but try these steps and see if that helps matters.

Countzero’s picture

I get this error too, and it prevents Twitter authentication. I'm using latest D7 version.

Uninstalling everything is barely an option for me, so I ended up wrapping all class declarations in sites/all/modules/oauth/lib/OAuth.php in conditional statements like :

if (!class_exists('OAuthSignatureMethod_HMAC_SHA1')) {
     // Class declaration goes here

It seems to work OK, but is absolutely awful, of course.

minorOffense’s picture

Issue summary: View changes

This error occurs if you try to use Hybridauth and OAuth common together. What really needs to happen is have each library properly namespace their class definitions. That way we don't get conflicts like this.

EgbertB’s picture

Totally agree with minorOffense.