Error description
Our PHP error logs are getting filled with the following notice:
PHP Notice: Undefined index: #name in [my project name]/htdocs/profiles/acquia/modules/apachesolr/Solr_Base_Query.php on line 219.
This error happens when any of our customers visit our one of our search pages.
This is the code where the error is caused:
protected function unset_filter(&$fields, $name, $value) {
if (!isset($value)) {
foreach ($fields as $pos => $values) {
if ($values['#name'] == $name) {
unset($fields[$pos]);
}
}
}
else {
foreach ($fields as $pos => $values) {
if ($values['#name'] == $name && $values['#value'] == $value) { // This is line 219.
unset($fields[$pos]);
}
}
}
}
Below is a stack trace:
http://[my site]/worksheets/?filters=im_28_field_grade_level:19 (suspended)
add_filter(): /[my site]/profiles/acquia/modules/apachesolr/Solr_Base_Query.php at line 219
add_filter(): /[my site]/profiles/acquia/modules/apachesolr/Solr_Base_Query.php at line 191
apachesolr_search_nested_facet_items(): /[my site]/profiles/acquia/modules/apachesolr/apachesolr_search.module at line 1180
apachesolr_search_taxonomy_facet_block(): /[my site]/profiles/acquia/modules/apachesolr/apachesolr_search.module at line 1089
apachesolr_search_block_view(): /[my site]/profiles/acquia/modules/apachesolr/apachesolr_search.module at line 938
module_invoke(): /[my site]/includes/module.inc at line 793
_block_render_blocks(): /[my site]/modules/block/block.module at line 828
block_list(): /[my site]/sites/all/modules/contrib/context/plugins/context_reaction_block.inc at line 352
block_get_blocks_by_region(): /[my site]/sites/all/modules/contrib/context/plugins/context_reaction_block.inc at line 316
execute(): /[my site]/sites/all/modules/contrib/context/plugins/context_reaction_block.inc at line 222
context_page_build(): /[my site]/sites/all/modules/contrib/context/context.core.inc at line 248
drupal_render_page(): /[my site]/includes/common.inc at line 5480
drupal_deliver_html_page(): /[my site]/includes/common.inc at line 2536
drupal_deliver_page(): /[my site]/includes/common.inc at line 2431
menu_execute_active_handler(): /[my site]/includes/menu.inc at line 516
/[my site]/index.php at line 22
And below is a snapshot of the variables received in the unset_filter() function:
$fields Array [1]
im_36_field_themes Array [5]
0 (string:2) 46
1 (string:2) 46
2 (string:2) 47
3 (string:2) 48
4 (string:2) 49
$name (string:18) im_36_field_themes
$value (string:2) 46
$values Array [5]
0 (string:2) 46
1 (string:2) 46
2 (string:2) 47
3 (string:2) 48
4 (string:2) 49
$pos (string:18) im_36_field_themes
Comments
Comment #1
alexander allen commentedI don't have a working copy of this module in Git (we're currently using SVN in my company), so I submitted an SVN patch instead. The attached patch fixed the PHP notice.
Thank you.
Comment #2
nick_vhAfter some digging this is appearently code from the 6.x branch so setting the right tags here. On first sight I only see one problem if you want to do this right :
Should become
Comment #3
nick_vhComment #4
nick_vhReworked it a bit to be readable and clear
Comment #5
nick_vhCommitted, thanks!
Comment #6
nick_vhComment #6.0
nick_vhAdded comment to code.