Fatal error: Cannot redeclare class OAuthException in sites/all/modules/oauth/oauth.lib.php on line 17

I am getting this WSOD error right after login in. If I refresh the page, it goes away. I have looked high and low for any possible conflict with OAuth within all my contrib modules and cannot find one BUT I have an installation of STATUS.NET in a subdirectory. Could this be the problem?

Comments

Same here,

getting this error in the logs, after every cron.

I have the same problem with my drupal 6 site. can't run cron and it gives this error. Any advice would be appreciated

Hi,
Have you found any solution for this, I am facing the same error

Error: Cannot redeclare class OAuthException in /sites/all/modules/oauth/oauth.lib.php, line 17
WD cron: Cron run exceeded the time limit and was aborted.

Fatal error: Cannot redeclare class OAuthException in /sites/all/modules/oauth/oauth.lib.php on line 17
Drush command terminated abnormally due to an unrecoverable error.

I had this issue, too. It was because I updated from 2.02 to 3.0b4 without removing the module directory, instead I just put all files into the existing directory. After deleting the oauth directory and placing a fresh version, the error is gone (see also #958126: Extra class OAuthException Declaration?)

ErikWegner

#4 -> BINGO!!!!! I cleaned the system tables from oauth and I install it again and it works with no error whatsoever

Error fixed after upgrading OAuth module to latest version, as both OAuth and OAuth common modules are merged to single OAuth module.

Thanks ErikWegner, post #4 worked for me.

Regards,
Build Your Box.
Any feedback appreciated.

Status:Active» Closed (won't fix)

I was getting the same error in 7.x-3.0 (and 7.x-3.0-dev). Single 'class OAuthException' instance in entire codebase, but 'cannot redeclare class' error being thrown. Turned out that my PHP installation was compiled with OAuth, so that's where the first copy of the class was coming from. Perhaps it's a good idea to move the OAuth.php file inclusion out of oauth_common.info and into the module, and wrap it in a if (!class_exists(...))?

//edit:

Wrapping just the OAuthException class declaration in a if (!class_exists(...)) did the trick for my system. In hindsight, using namespaces may be a possible solution here.

Status:Closed (won't fix)» Active

If PHP installation has OAuth extension, loading of OAuth.php fails with fatal error because OAuth extension already contains OAuthException class.
IMO, the solution from #9 (wrapping with class_exists()) is the right way. Because sometime, for instance on shared hosting, we have no ability to manage PHP extensions.

Priority:Normal» Major
Status:Active» Needs review
StatusFileSize
new632 bytes

@Leksat, fyi -

with

Core                         System (system)                                  Module  Enabled        7.15
OAuth                        OAuth (oauth_common)                             Module  Enabled        7.x-3.0+15-dev

and
php -i | grep -i oauth
  OAuth
  OAuth support => enabled
  source version => $Id: oauth.c 308063 2011-02-06 17:22:05Z jawed $

getting this error:

==> /var/log/apache2/drupsup.int.error_log <==
[Thu Aug 23 15:06:39.373665 2012] [proxy_fcgi:error] [pid 20730:tid 139942593435392] [client 127.0.0.1:50089] AH01071: Got error 'PHP message: PHP Fatal error:  Cannot redeclare class OAuthException in /home/drupsup/drupal7/sites/all/modules/contrib/oauth/lib/OAuth.php on line 8\n', referer: https://drupsup.int/user/login

applying patch @ #11; applies successfully to D7+OAuth7x3.

No more error.

Version:6.x-3.x-dev» 7.x-3.x-dev

I installed pecl OAuth for php in order to communicate with OAuth services, and Drupal site stopped working due to redeclaration of OAuthException.

Patch in comment #11 indeed works well and solved my problem. I am hoping to see it included in next version

applied patch and no more errors!! THAnKS!!! #11...D7

Status:Needs review» Fixed

Status:Fixed» Closed (fixed)

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

#4 works for me. Thanks for the clue. I removed the directory of oAuth and replaced with new version of the module. All worked.

Muhammad Tanweer
http://www.app-desk.com