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.

AttachmentSizeStatusTest resultOperations
apachesolr_cck_fields_alter_notices.patch840 bytesIgnored: Check issue status.NoneNone

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

Title:PHP notices on line 1551» Several php notices

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 :)

  • apachesolr_operator_settings.patch : fixes a notice where $operator_settings[$module][$delta] might not be set. This check is also done in apachesolr_form_block_admin_configure_alter() for $form['block_settings']['apachesolr_operator']
  • apachesolr_filters_notices.patch : fixes a notice in Solr_Base_query where filters might be empty.

I found two others which I couldn't fix immediately or didn't really understand what exactly was going on in there:

  • Warning: Illegal offset type in isset or empty in /var/www/glowbox/company/sites/all/modules/contrib/apachesolr/apachesolr_search.module on line 927
  • Notice: Array to string conversion in /var/www/glowbox/company/includes/bootstrap.inc on line 77 :

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:0
2 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
AttachmentSizeStatusTest resultOperations
apachesolr_filters_notices.patch572 bytesIgnored: Check issue status.NoneNone
apachesolr_operator_settings.patch550 bytesIgnored: Check issue status.NoneNone

#4

Unified patch.

AttachmentSizeStatusTest resultOperations
apachesolr_notices.patch2.56 KBIgnored: Check issue status.NoneNone

#5

Version:6.x-2.x-dev» 6.x-1.x-dev
Status:needs review» patch (to be ported)

#664884 by swentel: Fixed Several php notices.
Committing to 6.2. Thanks!

#6

Status:patch (to be ported)» fixed

Don't think these need porting.

#7

Looks like the code is rather different in 6.x-1.x

#8

Status:fixed» closed (fixed)

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

nobody click here