summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2013-03-30 10:59:10 -0400
committerDavid Rothstein <drothstein@gmail.com>2013-03-30 10:59:10 -0400
commit0bcf41a3c45f095a5ecb43fa3ec437cab8e68830 (patch)
treec4bd4243472e35ffcf316b3011a30e7c8d2c356d
parent6cb8c8a05220a334ee8542097b48cf0a2a5dced2 (diff)
downloadbrdo-0bcf41a3c45f095a5ecb43fa3ec437cab8e68830.tar.gz
brdo-0bcf41a3c45f095a5ecb43fa3ec437cab8e68830.tar.bz2
Issue #1379056 by Barrett: Fixed if more than one hook_openid() implementation returns a given parameter, the resulting value is an array and request is invalid.
-rw-r--r--CHANGELOG.txt3
-rw-r--r--modules/openid/openid.module16
2 files changed, 18 insertions, 1 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index df3ddccd0..dac2e19a4 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,6 +1,9 @@
Drupal 7.22, xxxx-xx-xx (development version)
-----------------------
+- Fixed OpenID errors when more than one module implements hook_openid(). The
+ behavior is now changed so that if more than one module tries to set the same
+ parameter, the last module's change takes effect.
- Fixed a serious documentation bug: The $name variable in the
taxonomy-term.tpl.php theme template was incorrectly documented as being
sanitized when in fact it is not.
diff --git a/modules/openid/openid.module b/modules/openid/openid.module
index a3f4fc8e0..1f764e04b 100644
--- a/modules/openid/openid.module
+++ b/modules/openid/openid.module
@@ -787,7 +787,21 @@ function openid_authentication_request($claimed_id, $identity, $return_to = '',
$request = array_merge($request, module_invoke_all('openid', 'request', $request));
- return $request;
+ // module_invoke_all() uses array_merge_recursive() which might return nested
+ // arrays if two or more modules alter a given parameter, resulting in an
+ // invalid request format. To ensure this doesn't happen, we flatten the returned
+ // value by taking the last entry in the array if an array is returned.
+ $flattened_request = array();
+ foreach ($request as $key => $value) {
+ if (is_array($value)) {
+ $flattened_request[$key] = end($value);
+ }
+ else {
+ $flattened_request[$key] = $value;
+ }
+ }
+
+ return $flattened_request;
}
/**