When loading the import configuration form 'admin/settings/hierarchical_select/import/MYTAXONOMYNAME' a PHP warning is generated:

warning: preg_match() expects parameter 2 to be string, array given in C:\wamp\www\patterndestination\includes\bootstrap.inc on line 777. 

This can be duplicated on a bare drupal install with 'Hierarchical Select' and 'Hierarchical Select Taxonomy' enabled.

Steps to reproduce:
1. Create a bare drupal install
2. Enable 'Hierarchical Select' and 'Hierarchical Select Taxonomy'
3. Create a vocabulary and tick the option allowing hierarchical select to control it
4. Go to the import configuration form 'admin/settings/hierarchical_select/import/MYTAXONOMYNAME' to see the warning displayed.

The effect of this is that when settings for hierarchical select are imported through the patterns module the import fails because of the PHP warning generated by the form

Comments

Shawn_S’s picture

This bug seems to be cause by the code in hierarchical_select.admin.inc line 187 to 191

There are two variables passed to the function hierarchical_select_admin_import but it's function signature only specifies one. The second variable contains the name of the configuration which can be used in the Description field e.g. this seems to work:


function hierarchical_select_admin_import($config_id, $formid) {                                                //ADD A SECOND VARIABLE TO THE FUNCTION <---------------------
  require_once(drupal_get_path('module', 'hierarchical_select') .'/includes/common.inc');

  drupal_add_css(drupal_get_path('module', 'hierarchical_select') .'/hierarchical_select.css');
  drupal_add_js('$(document).ready(function() { $(".hierarchical-select-code").focus(); });', 'inline');

  $form['config'] = array(
    '#type' => 'textarea',
    '#title' => t('Import Hierarchical Select configuration code'),
    '#cols' => 60,
    '#rows' => 15,
    '#description' => t('Copy and paste the results of an exported
      Hierarchical Select configuration here.<br />This will override the
      current Hierarchical Select configuration for %config_id.',
      array('%config_id' => $formid)                                                 //USE THAT VARIABLE FOR THE t() FUNCTION <------------------------------------------
    ),
    '#attributes' => array('class' => 'hierarchical-select-config-code'),
  );
  $form['interpreted_config'] = array('#type' => 'value', '#value' => NULL);
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t("Import"),
  );
  $form['#redirect'] = NULL;
  return $form;
}

wim leers’s picture

Assigned: Unassigned » wim leers
Status: Active » Fixed

Fixed!

http://drupal.org/cvs?commit=334938

You were looking in the right direction, but you unfortunately got it wrong :) You made it super easy for me to find the exact cause though, so thanks!

Status: Fixed » Closed (fixed)

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