warning: preg_match() expects parameter 2 to be string, array given in bootstrap.inc on line 777

darioarg - January 15, 2010 - 21:38
Project:Drupal tweaks
Version:6.x-1.x-dev
Component:PHP
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

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.

<?php

/**
* 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

<?php
/**
* 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

#1

espirates - January 16, 2010 - 14:59

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

#2

kenorb - January 16, 2010 - 15:15
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

#3

kenorb - January 16, 2010 - 15:17
Status:needs review» fixed

#4

darioarg - January 18, 2010 - 14:06

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

#5

kenorb - January 18, 2010 - 14:42

Thanks, I'll check that.

#6

RaRi - January 29, 2010 - 12:33

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

#7

System Message - February 12, 2010 - 12:40
Status:fixed» closed

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

#8

kenorb - March 9, 2010 - 14:22

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.

 
 

Drupal is a registered trademark of Dries Buytaert.