The $field which gets passed to the theme function is not always an array... The Author Facet block passed just the uid over. Assuming it is an array causes the wrong digit to be pulled out.
The fix? In theme_apachesolr_breadcrumb_uid
Change:

$uid = $field['#value'];

to

$uid = is_array($field) ? $field['#value'] : $field;

Without this, the Author Facet block reports the wrong username.

The function appears the same in DRUPAL-6--2 as well... although i haven't tested if the bug is present in that branch yet.

CommentFileSizeAuthor
#2 apachesolr-656044-D5.patch716 bytesclaudiu.cristea

Comments

robertdouglass’s picture

Since we're not observing any problems with this in the higher branches I suggest fixing it as needed in this branch only.

claudiu.cristea’s picture

StatusFileSize
new716 bytes

I confirm the bug. Here's the patch.

claudiu.cristea’s picture

Title: Bug with theme_apachesolr_breadcrumb_uid - $field not always array » Bug with theme_apachesolr_breadcrumb_uid - $field not array
Version: 5.x-2.x-dev » 6.x-1.x-dev
Status: Needs review » Patch (to be ported)

Committed to DRUPAL-5--2 in #318534.

This is affecting also 6.x-1.x-dev. Porting needed.

pwolanin’s picture

This patch cannot be right for 6.x-1.x: are you sure you are pulling the code into 5.x?


/**
 * Return the username from $uid
 */
function theme_apachesolr_breadcrumb_uid($uid) {
  if ($uid == 0) {
    return variable_get('anonymous', t('Anonymous'));
  }
  else {
    return db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $uid));
  }
}
claudiu.cristea’s picture

At some point I've backported some patch from 6.x-2.x-dev that changed the way arguments are passed to the theme function. I don't recall why I did this but I use the 6.2 way: $field instead of $uid.

/**
 * Return the username from $uid
 */
function theme_apachesolr_breadcrumb_uid($field) {
  if ($field['#value'] == 0) {
    return variable_get('anonymous', t('Anonymous'));
  }
  else {
    return db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $field['#value']));
  }
}
pwolanin’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Patch (to be ported) » Fixed

have we verified this is a bug in 6.x-1.x at all? I think this is fixed in all relevant branches.

Status: Fixed » Closed (fixed)

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