My apologize for my english.

I received this message in block section and I see the code say FIXME, so I want give a hand in this.

warning: preg_match() expects parameter 2 to be string, array given in D:\www\clientes2009\drupalargentina\v6\includes\bootstrap.inc on line 777.

/**
 * Implementation of after_build callback
 */
function drupal_tweaks_block_tweak($form, $form_state) {
  foreach ($form as $block_name => $block_data) {
    if (is_array($block_data)) {
      $module_name = $block_data['module']['#value'];
      $form[$block_name]['info']['#suffix'] .= ' ' . sprintf(t('(module: %s)'), $module_name);
      // FIXME: Why #suffix generates: warning: preg_match() expects parameter 2 to be string, array given in includes/bootstrap.inc on line 777 ?
    }
  }
  return $form;
}

Y changed for this and it look like

/**
 * Implementation of after_build callback
 */
function drupal_tweaks_block_tweak($form, $form_state) {
  foreach ($form as $block_name => $block_data) {
    if (is_array($block_data) && $block_data['module']['#value']) { //Not all the array is about modules blocks
      $module_name = $block_data['module']['#value'];
      $form[$block_name]['info']['#suffix'] .= ' ' . t('(module: %module)', array('%module' => $module_name)); //Minor change to t()
      // FIXME: Why #suffix generates: warning: preg_match() expects parameter 2 to be string, array given in includes/bootstrap.inc on line 777 ?
    }
  }
  return $form;
}

And it work like a charm

Comments

espirates’s picture

I get this one
warning: preg_match() expects parameter 2 to be string, array given in /drupal/includes/bootstrap.inc on line 1032.

Your fix worked for me

kenorb’s picture

Status: Active » Needs review

Thank you, I'd no time to look after this.
Regarding t(), I don't wanted to use it, because it's adding unnecessary html code (some spans in some themes) and it's breaking the line.
Committed.
http://drupal.org/cvs?commit=314882

kenorb’s picture

Status: Needs review » Fixed
dariogcode’s picture

I don't sure but if you use !module in t() it don't add html code.

kenorb’s picture

Thanks, I'll check that.

RaRi’s picture

As I am not using the Drupal Tweak module, I assume the fix is nothing for me. Correct?

Status: Fixed » Closed (fixed)

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

kenorb’s picture

RaRi: yes, usually following error:
warning: preg_match() expects parameter 2 to be string, array given in bootstrap.inc
is caused by some bug in contributed module.
You need to find other issue related to module that you using where this error appears.