I got an unexpected error each time i try to access the badge list.

Error log shows :

Recoverable fatal error : Argument 1 passed to drupal_http_build_query() must be an array, string given, called in /XXX/XXX/www/includes/common.inc on line 2222 and defined dans drupal_http_build_query() (ligne 486 dans /XXX/XXX/www/includes/common.inc).

preceded by three occurences of :

Notice : Undefined variable: account dans theme_user_badge() (ligne 1237 dans /XXX/XXX/www/sites/all/modules/user_badges/user_badges.module).

Line 1237 of the file user_badges.module looks this way :
$href = token_replace($href, array('userbadge' => $badge, 'user' => $account));
full file attached to the issue.

Error occurred just after i added a new badge. I can still access to the tabs image, roles, and settings, though the autocomplete on badges causes HTTP AJAX 500 error, but only if the last badge i added is supposed to appear in the completion (other completions works just fine).

So i guess the problem is linked to the last badge i added. Is there also a way to delete this specific badge manually (without using the badge list which is broken due to this issue) ?

NB: i use drupal 7.23

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

SdG ct’s picture

Version: 7.x-1.0 » 7.x-3.x-dev
Status: Active » Needs review

I was able to identify the problem source.
It came from the last badge i created which included a link to an external URL in its description, and i solved it by modifying manually the badge entry in the db.
drupaluser_badges_badges, and setting href field to NULL for the concerned badge.

NB : Before doing that, I tried replacing my module version (7.x-1.0) with the 7.x-3.x-dev, which didn't solved the problem, so i assume the 7.x-3.x-dev version is also concerned by the issue and changed the module version of this post accordingly.

shabana.navas’s picture

FileSize
28.96 KB

I have tried to replicate this issue by adding a link to the description url, but I am not getting any errors as you have suggested. I have included a screen shot of the badge I tried to add. Let me know if you are doing anything differently.

SdG ct’s picture

Thanks for the answer.
I did upload my own image instead of using and image URL, and the link i used was external (can't see on screenshot if you tested directly on drupal.org or not). apart from that i'm not sure what could have messed things up, i think it has to do with the description link since everything started working again when i removed it into the db. I'll do more testing on my side and try to reproduce the error, I'll keep you informed.

SdG ct’s picture

Found it !

Just use a link containing a GET request :

https://www.google.fr/?q=test

It caused the issue every time.

shabana.navas’s picture

Patch for the 7.x-3.x-dev version is submitted below. Please test it out.

SdG ct’s picture

The patch seems to work perfectly fine for me.
I wasn't sure about the status i should give to this post so i didn't changed it.

jlandfried’s picture

+    $queries_array = array();
+    foreach($queries as $q) {
+      $query = explode('=', $q);
+      //Add the individual query strings into an associative array
+      $queries_array[$query[0]] = $query[1];
+    }
+    //Now, set $pieces['query'] as an associative array
+    $pieces['query'] = $queries_array;

We can use drupal_get_query_array to do this for us :-)

+    $pieces['query'] = drupal_get_query_array($pieces['query']);
jlandfried’s picture

Whoops, that last patch threw a notice when the url didn't have query parameters, this one should fix that

shabana.navas’s picture

Awesome! I knew there was a Drupally way of getting this done. @jiff: Thanks, really appreciate it. Will test it out and if everything works out okay, will commit it to the dev version.

shabana.navas’s picture

Status: Needs review » Fixed

Committed to 7.x-3.x version.

Status: Fixed » Closed (fixed)

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