diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-01-25 19:49:52 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-01-25 19:49:52 -0800 |
commit | 804614711ab79a739539fa0052e527d8c2152a90 (patch) | |
tree | 1f3b6ee2c9cf0589947161ebba4eaf12d179d55e /modules/gallery/libraries | |
parent | 1606961153fca681895a4f0145f7794000337539 (diff) |
Make only one attempt to restore the old identity provider in case of
failure. Else, we can get into an infinite recursion.
Diffstat (limited to 'modules/gallery/libraries')
-rw-r--r-- | modules/gallery/libraries/IdentityProvider.php | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/modules/gallery/libraries/IdentityProvider.php b/modules/gallery/libraries/IdentityProvider.php index 79151154..c6b393ec 100644 --- a/modules/gallery/libraries/IdentityProvider.php +++ b/modules/gallery/libraries/IdentityProvider.php @@ -86,18 +86,28 @@ class IdentityProvider_Core { auth::login($provider->admin_user()); Session::instance()->regenerate(); } catch (Exception $e) { - // Make sure new provider is not in the database - module::uninstall($new_provider); - - // Lets reset to the current provider so that the gallery installation is still - // working. - module::set_var("gallery", "identity_provider", null); - IdentityProvider::change_provider($current_provider); - module::activate($current_provider); - message::error( - t("Error attempting to enable \"%new_provider\" identity provider, " . - "reverted to \"%old_provider\" identity provider", - array("new_provider" => $new_provider, "old_provider" => $current_provider))); + static $restore_already_running; + + // In case of error, make an attempt to restore the old provider. Since that's calling into + // this function again and can fail, we should be sure not to get into an infinite recursion. + if (!$restore_already_running) { + $restore_already_running = true; + + // Make sure new provider is not in the database + module::uninstall($new_provider); + + // Lets reset to the current provider so that the gallery installation is still + // working. + module::set_var("gallery", "identity_provider", null); + IdentityProvider::change_provider($current_provider); + module::activate($current_provider); + message::error( + t("Error attempting to enable \"%new_provider\" identity provider, " . + "reverted to \"%old_provider\" identity provider", + array("new_provider" => $new_provider, "old_provider" => $current_provider))); + + $restore_already_running = false; + } throw $e; } } |