Ex d'utilisation de devel et dpm

Lors débug d'un drupal 6 (htmlspecialchars() expects parameter 1 to be string in .../includes/bootstrap.inc) pour afficher la "non-string" qui pourrait provoquer l'erreur :

Source: https://www.drupal.org/node/829250

<?php
  // Arround line 840 in drupal/includes/bootstrap.inc

  if ($php525) {
    if (is_array($text)) {  //add
      dsm($text);         //this
    }                   //lines
    return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
  }
?>

et  

if ($php525) {
    if (is_array($text)) {  //add
      dsm($text);         //this
      dsm(views_trace());
    }                   //lines
    return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');

 

sur check_plain :

<?php
if ( !is_string($text) ) {
  $bt = debug_backtrace() ;
  dpm($bt);
}
?>

 

Source https://www.drupal.org/node/525036

en utilisant debug_print_backtrace() encore un soucis lié à la fonction check_plain:

Pour trouver d'où vient l'erreur "Array (or not-string) variable" : modifier includes/bootstrap.inc vers la ligne 842  en ajoutant ce code entre les lignes  "static $php525" et "if (isset($php525)) {" tq:

function check_plain($text) {
  static $php525;

  if ( !is_string($text) && is_array($text) ) {
    echo "<pre>";
    print_r($text);
    debug_print_backtrace();
    echo "</pre>";
  }
  if (!isset($php525)) {
    $php525 = version_compare(PHP_VERSION, '5.2.5', '>=');
  }
  // We duplicate the preg_match() to validate strings as UTF-8 from
  // drupal_validate_utf8() here. This avoids the overhead of an additional
  // function call, since check_plain() may be called hundreds of times during
  // a request. For PHP 5.2.5+, this check for valid UTF-8 should be handled
  // internally by PHP in htmlspecialchars().
  // @see http://www.php.net/releases/5_2_5.php
  // @todo remove this when support for either IE6 or PHP < 5.2.5 is dropped.

  if ($php525) {
    return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
  }
  return (preg_match('/^./us', $text) == 1) ? htmlspecialchars($text, ENT_QUOTES, 'UTF-8') : '';
}

logo drush