Posted by swentel on December 21, 2009 at 11:10am
| Project: | Apache Solr Search Integration |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Notice: Undefined index: field_page_attachments in /var/www/glowbox/company/sites/all/modules/contrib/apachesolr/apachesolr.module on line 1551
If a module is implementing hook_apachesolr_cck_fields_alter line 1551 throws errors because any added fields in the alter don't exist in $fields[$row->field_name]. Patch attached fixes this issue.
Note, this might be related also (I think) with #664866: Multiple indexes for one CCK field.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| apachesolr_cck_fields_alter_notices.patch | 840 bytes | Ignored: Check issue status. | None | None |
Comments
#1
Can you paste some example implementation that causes the error for my testing? Thanks.
#2
Taken from nd_search.module (from nd_contrib branch 6--2)
<?php
/**
* Implementation of hook_apachesolr_cck_fields_alter.
* Add the required CCK fields to apache solr.
*/
function nd_search_apachesolr_cck_fields_alter(&$mappings) {
$fields = content_fields();
foreach ($fields as $field) {
$mappings['per-field'][$field['field_name']] = array(
'display callback' => '',
// The callback function gets called at indexing time to get the values.
'indexing callback' => 'nd_search_indexing_callback',
// Common types are 'text', 'string', 'integer',
// 'double', 'float', 'date', 'boolean'
'index_type' => _get_solr_type($field['type']),
);
}
}
/**
* Get the corresponding apache solr type from a cck type.
*
* @param string $type CCK field type.
* @return array with type and prefix in apache solr.
*/
function _get_solr_type($type) {
$types = array(
'text' => 'string',
'number_integer' => 'integer',
'number_float' => 'float',
'filefield' => 'string',
'imagefield' => 'string',
'date' => 'date',
);
// Default type is text
if (!isset($types[$type])) {
return 'string';
}
return $types[$type];
}
?>
#3
I've attached two other patches fixing other notices. I did them seperately so you can review them easier, changed title to reflect that we're trying to fix several notices at once :)
I found two others which I couldn't fix immediately or didn't really understand what exactly was going on in there:
For the second notice, a backtrace leads to ../Solr_Base_Query.php:388 where the $themed variable has become an array instead of text. Probably the theme($breadcrum_name, $field) function errors here. The backtrace for the first one seems related too
1 0.0001 57840 {main}( ) ../index.php:02 0.0884 1497084 menu_execute_active_handler( ) ../index.php:18
3 0.0885 1497468 call_user_func_array ( ) ../menu.inc:348
4 0.0885 1497760 apachesolr_search_view( ) ../menu.inc:0
5 0.0902 1502832 apachesolr_search_search( ) ../apachesolr_search.module:168
6 0.0902 1503244 apachesolr_search_execute( ) ../apachesolr_search.module:129
7 0.1251 1893332 Solr_Base_Query->get_breadcrumb( ) ../apachesolr_search.module:382
8 0.1257 1894800 theme( ) ../Solr_Base_Query.php:387
9 0.1316 2359388 call_user_func_array ( ) ../theme.inc:617
10 0.1316 2359696 theme_apachesolr_breadcrumb_language( ) ../theme.inc:0
11 0.1316 2359820 apachesolr_search_language_name( ) ../apachesolr_search.module:1313
#4
Unified patch.
#5
#664884 by swentel: Fixed Several php notices.
Committing to 6.2. Thanks!
#6
Don't think these need porting.
#7
Looks like the code is rather different in 6.x-1.x
#8
Automatically closed -- issue fixed for 2 weeks with no activity.