Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#24 | cannot_redeclare_class-1334528-24.patch | 353 bytes | fuzzy76 |
#11 | oauth-fatal_error_class_OAuthException-1334528-11.patch | 632 bytes | Leksat |
Comments
Comment #1
karlitos CreditAttribution: karlitos commentedSame here,
getting this error in the logs, after every cron.
Comment #2
psykomf CreditAttribution: psykomf commentedI have the same problem with my drupal 6 site. can't run cron and it gives this error. Any advice would be appreciated
Comment #3
ravi.kumar CreditAttribution: ravi.kumar commentedHi,
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.
Comment #4
ErikWegner CreditAttribution: ErikWegner commentedI 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?)
Comment #5
karlitos CreditAttribution: karlitos commentedErikWegner
#4 -> BINGO!!!!! I cleaned the system tables from oauth and I install it again and it works with no error whatsoever
Comment #6
ravi.kumar CreditAttribution: ravi.kumar commentedError fixed after upgrading OAuth module to latest version, as both OAuth and OAuth common modules are merged to single OAuth module.
Comment #7
buildyourbox CreditAttribution: buildyourbox commentedThanks ErikWegner, post #4 worked for me.
Regards,
Build Your Box.
Any feedback appreciated.
Comment #8
kylebrowning CreditAttribution: kylebrowning commentedComment #9
yuriy.babenko CreditAttribution: yuriy.babenko commentedI 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 aif (!class_exists(...))
did the trick for my system. In hindsight, using namespaces may be a possible solution here.Comment #10
Leksat CreditAttribution: Leksat commentedIf 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.
Comment #11
Leksat CreditAttribution: Leksat commentedComment #12
drupsup CreditAttribution: drupsup commented@Leksat, fyi -
with
and
getting this error:
applying patch @ #11; applies successfully to D7+OAuth7x3.
No more error.
Comment #13
drupsup CreditAttribution: drupsup commentedComment #14
alandarev CreditAttribution: alandarev commentedI 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
Comment #15
ppfranco CreditAttribution: ppfranco commentedapplied patch and no more errors!! THAnKS!!! #11...D7
Comment #16
juampynr CreditAttribution: juampynr commentedUntil propper PECL support is implemented, I have committed the patch of comment #11.
Committed to 7.x-3.x, 6.x-3.x and Github.
Many thanks.
http://drupalcode.org/project/oauth.git/commitdiff/72a7d8e
http://drupalcode.org/project/oauth.git/commitdiff/89f9658
http://drupalcode.org/project/oauth.git/commitdiff/ab17363
https://github.com/juampy72/OAuth-PHP/commit/61ab0a3f284e3c7b93e53a3e85f...
Comment #18
muhammad.tanweer CreditAttribution: muhammad.tanweer commented#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
Comment #19
sahirmathur CreditAttribution: sahirmathur commentedI tried this and it didnt work for me, replaced the oauth directory with a new latest copy from https://www.drupal.org/project/oauth
Does anyone know how to install the patch file? I am on a shared host
Comment #20
ErikWegner CreditAttribution: ErikWegner commentedYou can either
a) download the file from the repository ( go to http://cgit.drupalcode.org/oauth/tree/lib/OAuth.php and select your module version, then use the whole file) or
b) download your current file from your shared host (sites/all/modules/oauth/lib/OAuth.php
), download the diff, apply the diff and upload the modified file to the shared host. Because the diff is small, you can even edit the OAuth.php by hand. Just look into the diff file, it is plain text.
Good luck.
Comment #21
zhouhana CreditAttribution: zhouhana as a volunteer commentedI can't read PHP very well myself, so I just want to double check. Because of the recent security release to OAuth I'm trying to update the module for a few sites, and now I'd like to reapply the patches that were previously applied, so the sites don't lose any important functionality.
The release notes for OAuth say nothing about this patch being included in the non-dev branch. When I try to apply it through the command line I get this:
(By the way, why did I need to enter the path manually? It's the same path as specified in the patch.)
What should I do now? I'm thinking that since the patch is so old maybe there's some kind of mismatch between it and the code that is now in 7.x-3.3 that would need to be reviewed?
Comment #22
ErikWegner CreditAttribution: ErikWegner commentedJust a guess here: do not use
-p1
, as-p
means: ignore directory levels in the patch file, and the digit means one level. Effectively you loose the sites path. Either use-p0
or do not use it at all.Comment #23
zhouhana CreditAttribution: zhouhana as a volunteer commentedThanks for the info about
-p1
– I had no idea. I still get the same result without it, though.Comment #24
fuzzy76 CreditAttribution: fuzzy76 commentedFWIW, here's a patch rolled against 6.x-2.02.