on /drupal/admin/content/webform

notice: Array to string conversion in /*/drupal/includes/common.inc on line 941.

Webform 6.x-3.x-dev
Drupal 6.17-dev
PHP 5.3.2

Possible PHP 5.3 bug?

CommentFileSizeAuthor
#5 webform_array_to_string.patch1.23 KBquicksketch

Comments

quicksketch’s picture

I'm assuming that line 941 is part of the t() function? Giving the line contents are often more helpful, since what line 941 is depends on when you downloaded the dev version.

This is usually caused by an incorrect call to t(). From the error it sounds like there might be a call that is passing an array into t(), such as t(array('something')). However I reviewed the admin/content/webform page and I couldn't find any place where this might be the case. It also doesn't look like it would be an error at least *caused* by PHP 5.3, though I do not think 5.2 would report that error. I can't confirm it in any way though, do you have any blocks on that page? It might be caused by a block or something in your theme rather than what Webform is outputting. Try switching to Garland and see if the page works properly.

hawleyal’s picture

Sorry, I didn't notice the error was in a core file.

Is there a way to get a stack trace, so I can see the caller?

Line 941

function t($string, $args = array(), $langcode = NULL) {
...
    return strtr($string, $args); // line 941
...
}

Function

function t($string, $args = array(), $langcode = NULL) {
  global $language;
  static $custom_strings;

  $langcode = isset($langcode) ? $langcode : $language->language;

  // First, check for an array of customized strings. If present, use the array
  // *instead of* database lookups. This is a high performance way to provide a
  // handful of string replacements. See settings.php for examples.
  // Cache the $custom_strings variable to improve performance.
  if (!isset($custom_strings[$langcode])) {
    $custom_strings[$langcode] = variable_get('locale_custom_strings_'. $langcode, array());
  }
  // Custom strings work for English too, even if locale module is disabled.
  if (isset($custom_strings[$langcode][$string])) {
    $string = $custom_strings[$langcode][$string];
  }
  // Translate with locale module if enabled.
  elseif (function_exists('locale') && $langcode != 'en') {
    $string = locale($string, $langcode);
  }
  if (empty($args)) {
    return $string;
  }
  else {
    // Transform arguments before inserting them.
    foreach ($args as $key => $value) {
      switch ($key[0]) {
        case '@':
          // Escaped only.
          $args[$key] = check_plain($value);
          break;

        case '%':
        default:
          // Escaped and placeholder.
          $args[$key] = theme('placeholder', $value);
          break;

        case '!':
          // Pass-through.
      }
    }
    return strtr($string, $args); // line 941
  }
}
quicksketch’s picture

If you have devel module enabled, my favorite way of getting a stack track is dsm(debug_backtrace());. debug_backtrace() is a PHP function.

hawleyal’s picture

well, i coulda guessed.

wasn't sure if that would give me all i needed.

thanks.

quicksketch’s picture

Status: Active » Fixed
StatusFileSize
new1.23 KB

I think I found the source of this problem while working on the Drupal 7 version. It looks like we've simply passed an array into url() (which ultimately must run through t() at some point). I reproduced the problem and this patch seems to fix it. Please reopen if the issue persists after this patch.

quicksketch’s picture

Pardon, it looks like we were passing in an array into t() instead of the result of url(). Sort of like I suggested in #1. The patch in #5 has been committed.

Status: Fixed » Closed (fixed)

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